zjunlp / DeepKE

[EMNLP 2022] An Open Toolkit for Knowledge Graph Extraction and Construction
http://deepke.zjukg.cn/
MIT License
3.16k stars 653 forks source link

【可复现】调用OneKE模型库,输出内容不可解析的JSON,内容大量重复。 #543

Open CocoaML opened 6 days ago

CocoaML commented 6 days ago

Describe the bug

A clear and concise description of what the bug is. 【问题】 调用OneKE模型库,输出内容不可解析的JSON,内容大量重复。

Environment (please complete the following information):

Screenshots

If applicable, add screenshots to help explain your problem.

image

示例代码输出: {"person": ["Robert Allenby", "Allenby", "Miguel Angel Martin"], "organization": [], "else": [], "location": ["Australia", "Spain"]} {"person": ["Robert Allenby", "Allenby", "Miguel Angel Martin"], "organization": [], "else": [], "location": ["Australia", "Spain"]}»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» {"person": ["Robert Allenby", "Miguel Angel Martin"], "organization

【问题】:运行后输出内容有重复,且不是可解析的JSON。 期待反馈。

guihonghao commented 6 days ago

注意精度,oneke目前训练的精度是bf16,如果使用fp16会存在问题

CocoaML commented 6 days ago

注意精度,oneke目前训练的精度是bf16,如果使用fp16会存在问题

您好,OneKE: https://modelscope.cn/models/ZJUNLP/OneKE 使用示例代码,应该如何调整呢?

示例代码中如下:

# 4bit量化OneKE
quantization_config=BitsAndBytesConfig(     
    load_in_4bit=True,
    llm_int8_threshold=6.0,
    llm_int8_has_fp16_weight=False,
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4",
)

model = AutoModelForCausalLM.from_pretrained(
    model_path,
    config=config,
    device_map="auto",  
    quantization_config=quantization_config,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
)
model.eval()

应该如何修改呢? 期待您反馈。

guihonghao commented 6 days ago

此处使用的就是bf16精度。注意到你的输出日志中存在tensorflow相关的内容,这是怎么回事?我们的模型使用pytorch加载的

CocoaML commented 6 days ago

此处使用的就是bf16精度。注意到你的输出日志中存在tensorflow相关的内容,这是怎么回事?我们的模型使用pytorch加载的

我使用的OneKE:https://modelscope.cn/models/ZJUNLP/OneKE, 在modelscope社区使用【Notebook快速开发】集成实现的。 运行代码是:modelscope 提供的【快速运行】的代码。 运行环境具体来说是: 运行环境

【问题】:运行后输出内容有重复,且不是可解析的JSON。 期待您反馈。

guihonghao commented 4 days ago

请查看平台提供机器是否支持bf16精度运算。大部分上图中的离谱的输出结果是由于机器不支持bf16精度导致的。

zxlzr commented 3 days ago

建议您换台机器再重试下

CocoaML commented 2 days ago

是否支持bf16精度运算

您好,请问如何检查机器是否支持bf16精度运算呢?有测试代码吗?期待您回复。

请查看平台提供机器是否支持bf16精度运算。大部分上图中的离谱的输出结果是由于机器不支持bf16精度导致的。

感谢您反馈。我继续尝试了一下,发现:支持bf16精度运算。问题依然存在,具体描述及截图为:

官网:https://modelscope.cn/models/ZJUNLP/OneKE 使用modelscope提供的Notebook快速开发环境。

根据您提供的信息: 我对bf16进行了检查。截图如下: 环境检查

import torch
torch.finfo(torch.bfloat16)
输出:
finfo(resolution=0.01, min=-3.38953e+38, max=3.38953e+38, eps=0.0078125, smallest_normal=1.17549e-38, tiny=1.17549e-38, dtype=bfloat16)

import transformers
transformers.utils.import_utils.is_torch_bf16_gpu_available()
输出:
True

import torch
torch.finfo(torch.float32)
输出:
finfo(resolution=1e-06, min=-3.40282e+38, max=3.40282e+38, eps=1.19209e-07, smallest_normal=1.17549e-38, tiny=1.17549e-38, dtype=float32)

import torch
print(torch.cuda.is_available())
输出:
True

根据以上环境检查,平台提供的机器是支持cuda环境,支持bf16精度运算。

示例代码输出:

{"person": ["Robert Allenby", "Allenby", "Miguel Angel Martin"], "organization": [], "else": [], "location": ["Australia", "Spain"]}  {"person": ["Robert Allenby", "Allenby", "Miguel Angel Martin"], "organization": [], "else": [], "location": ["Australia", "Spain"]}»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» {"person": ["Robert Allenby", "Miguel Angel Martin"], "organization

【问题】:输出内容不可解析的JSON,内容大量重复。 期待您回复。

CocoaML commented 2 days ago

建议您换台机器再重试下

感谢您的反馈,我使用了modelscope提供的平台,也使用其他机器测试了一下,还是有问题。 期待您回复。

官网:https://modelscope.cn/models/ZJUNLP/OneKE 使用modelscope提供的Notebook快速开发环境。

guihonghao commented 2 days ago

你试试其他输入文本是否也存在这种问题,还是说这个例子才会。

CocoaML commented 1 day ago

你试试其他输入文本是否也存在这种问题,还是说这个例子才会。

很奇怪,目前测试来看,都有这样的问题。您可以使用以下环境测试以下:

官网:https://modelscope.cn/models/ZJUNLP/OneKE 使用modelscope提供的Notebook快速开发环境。

期待您的回复。

guihonghao commented 1 day ago

目前来看 modelscope 上部署的模型均会出现这一问题,我们在本地运行没有出现这种问题。