🚀 ChemLLM-20B-Chat:用於化學和分子科學的大語言模型
ChemLLM是首個面向化學和分子科學領域的開源大語言模型,它基於InternLM-2構建,凝聚著開發者的心血。

🚀 快速開始
你可以立即嘗試在線演示,或者按照以下步驟進行本地部署:
安裝依賴庫
安裝transformers
庫:
pip install transformers
加載並運行ChemLLM-20B-Chat
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
import torch
model_name_or_id = "AI4Chem/ChemLLM-20B-Chat-SFT"
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評判)
專業翻譯測試

你可以在 在線演示 中體驗這些功能。
📄 許可證
本項目代碼採用Apache - 2.0許可證,模型權重完全開放用於學術研究,也允許免費商業使用。如需申請商業許可證或有其他問題及合作需求,請聯繫 support@chemllm.org。
📚 詳細文檔
引用方式
@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}
}
免責聲明
大語言模型可能會生成錯誤答案,請自行校對,風險自負。
演示地址
Agent Chepybara

聯繫方式
(AI4Physics Sciecne, 上海人工智能實驗室)[support@chemllm.org]