🚀 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(Simplified Molecular Input Line Entry System)文字列を受け入れ、IUPAC名(International Union of Pure and Applied Chemistry nomenclature of organic chemistry)を出力することを好み、反応をSMARTS(SMILES arbitrary target specification)文字列で表現します。Self-Referencing Embedded Strings(SELFIES)も受け入れます。
- Chepybaraは常に問題を解決し、段階的に考えます。出力は *Let's think step by step* で始まります。
📚 ドキュメント
結果
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]