🚀 ChemLLM-7B-Chat:用于化学和分子科学的大语言模型
ChemLLM-7B-Chat是首个用于化学和分子科学的开源大语言模型,它基于InternLM-2构建。该模型能有效解决化学和分子科学领域的问答、推理等问题,为科研人员和从业者提供专业的语言交互支持。

🚀 快速开始
建议使用新版的ChemLLM!
AI4Chem/ChemLLM-7B-Chat-1.5-DPO 或 AI4Chem/ChemLLM-7B-Chat-1.5-SFT
你可以立即尝试在线演示,或者按照以下步骤操作:
安装依赖
安装 transformers
:
pip install transformers
加载并运行 ChemLLM-7B-Chat
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
import torch
model_name_or_id = "AI4Chem/ChemLLM-7B-Chat"
model = AutoModelForCausalLM.from_pretrained(model_name_or_id, torch_dtype=torch.float16, device_map="auto",trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_id,trust_remote_code=True)
prompt = "What is Molecule of Ibuprofen?"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
generation_config = GenerationConfig(
do_sample=True,
top_k=1,
temperature=0.9,
max_new_tokens=500,
repetition_penalty=1.5,
pad_token_id=tokenizer.eos_token_id
)
outputs = model.generate(**inputs, generation_config=generation_config)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
✨ 主要特性
最新消息
系统提示最佳实践
你可以使用来自Agent Chepybara的相同对话模板和系统提示,以在本地推理中获得更好的响应。
对话模板
对于ShareGPT格式的查询,例如:
{'instruction': "...", "prompt": "...", "answer": "...", "history": [[q1, a1], [q2, a2]]}
你可以将其格式化为InternLM2对话格式,如下所示:
def InternLM2_format(instruction, prompt, answer, history):
prefix_template = [
"<|im_start|>system\n",
"{}",
"<|im_end|>\n"
]
prompt_template = [
"<|im_start|>user\n",
"{}",
"<|im_end|>\n"
"<|im_start|>assistant\n",
"{}",
"<|im_end|>\n"
]
system = f'{prefix_template[0]}{prefix_template[1].format(instruction)}{prefix_template[2]}'
history = "".join([f'{prompt_template[0]}{prompt_template[1].format(qa[0])}{prompt_template[2]}{prompt_template[3]}{prompt_template[4].format(qa[1])}{prompt_template[5]}' for qa in history])
prompt = f'{prompt_template[0]}{prompt_template[1].format(prompt)}{prompt_template[2]}{prompt_template[3]}'
return f"{system}{history}{prompt}"
系统提示示例
- Chepybara是由上海人工智能实验室(上海人工智能实验室)开发的对话式语言模型。它旨在专业、精细且以化学为中心。
- 对于不确定的概念和数据,Chepybara总是进行理论预测并告知用户。
- Chepybara可以接受SMILES(简化分子线性输入规范)字符串,并倾向于输出IUPAC名称(国际纯粹与应用化学联合会有机化学命名法),用SMARTS(SMILES任意目标规范)字符串描述反应。也接受Self-Referencing Embedded Strings(SELFIES)。
- Chepybara总是以逐步的方式解决问题和思考,输出以“让我们逐步思考”开头。
评测结果
MMLU评测亮点
数据集 |
ChatGLM3 - 6B |
Qwen - 7B |
LLaMA - 2 - 7B |
Mistral - 7B |
InternLM2 - 7B - Chat |
ChemLLM - 7B - Chat |
大学化学 |
43.0 |
39.0 |
27.0 |
40.0 |
43.0 |
47.0 |
大学数学 |
28.0 |
33.0 |
33.0 |
30.0 |
36.0 |
41.0 |
大学物理 |
32.4 |
35.3 |
25.5 |
34.3 |
41.2 |
48.0 |
形式逻辑 |
35.7 |
43.7 |
24.6 |
40.5 |
34.9 |
47.6 |
道德场景 |
26.4 |
35.0 |
24.1 |
39.9 |
38.6 |
44.3 |
人文学科平均分 |
62.7 |
62.5 |
51.7 |
64.5 |
66.5 |
68.6 |
STEM学科平均分 |
46.5 |
45.8 |
39.0 |
47.8 |
52.2 |
52.6 |
社会科学平均分 |
68.2 |
65.8 |
55.5 |
68.1 |
69.7 |
71.9 |
其他平均分 |
60.5 |
60.3 |
51.3 |
62.4 |
63.2 |
65.2 |
MMLU总分 |
58.0 |
57.1 |
48.2 |
59.2 |
61.7 |
63.2 |
*(OpenCompass) |
|
|
|
|
|
|

化学基准测试
*(由ChatGPT - 4 - turbo评判得分)
专业翻译

你可以在在线演示中尝试。
📚 详细文档
引用此工作
@misc{zhang2024chemllm,
title={ChemLLM: A Chemical Large Language Model},
author={Di Zhang and Wei Liu and Qian Tan and Jingdan Chen and Hang Yan and Yuliang Yan and Jiatong Li and Weiran Huang and Xiangyu Yue and Dongzhan Zhou and Shufei Zhang and Mao Su and Hansen Zhong and Yuqiang Li and Wanli Ouyang},
year={2024},
eprint={2402.06852},
archivePrefix={arXiv},
primaryClass={cs.AI}
}
免责声明
大语言模型可能会生成错误答案,请自行注意校对,风险自负。
开源许可证
代码遵循Apache - 2.0许可证,而模型权重完全开放用于学术研究,也允许免费商业使用。如需申请商业许可证或有其他问题和合作需求,请联系 support@chemllm.org。
演示
Agent Chepybara

联系我们
(AI4Physics Sciecne, 上海人工智能实验室)[support@chemllm.org]