陈雨轩1,吕昌伟2,肖云铎2,严宇坤2,曾振宁*3,刘知远2
1北京大学深圳研究生院电子与计算机工程学院,中国深圳
2清华大学,中国北京
3南京大学智能科学与技术学院,中国南京
*通讯作者:zengzn@nju.edu.cn
大型语言模型(LLMs)在专业领域的应用日益广泛,但在处理异构科学数据时面临着一个根本性的认知矛盾:LLMs 是为离散的自然语言符号序列设计的,而以分子为代表的科学实体本质上具有拓扑和几何特性。将这些结构强行转化为线性文本不可避免地会导致信息丢失,并且语义噪声会干扰 LLM 的认知推理。
我们提出了 SciCore-Mol,这是一种新颖的范式,通过可插拔的外部认知模块来增强 LLM,包括 GVP 编码器、扩散生成器和数值敏感型 Transformer(Reaction Transformer)。该架构在保留 LLM 通用能力的同时,为其提供了专门的分子感知能力。通过两阶段对齐机制,外部模块通过特殊标记被调用,并在隐藏状态层面进行融合,使 LLM 能够深入理解分子信息,同时不牺牲其核心推理过程。
git clone https://github.com/ChenYX24/SciCore-Mol.git
cd SciCore-Mol
# Option A: Install with uv (recommended)
pip install uv
uv sync
uv sync --extra graph # GVP-GNN dependencies (torch-geometric, torch-scatter, torch-cluster)
uv sync --extra flashattn # FlashAttention (requires CUDA)
uv sync --group train # DeepSpeed for distributed training
# Option B: Install with pip
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -e ".[graph]" # optional: GVP-GNN
pip install -e ".[flashattn]" # optional: FlashAttention
pip install deepspeed swanlab # optional: distributed trainingcp configs/env.example.sh configs/env.sh
# Edit configs/env.sh to set your paths, then:
source configs/env.sh| 变量 | 描述 |
|---|---|
SCICORE_ROOT | 项目根目录 |
MODEL_DIR | 基础模型目录(例如,Qwen3-8B) |
CHECKPOINT_DIR | 训练后的 checkpoint 目录 |
DATA_DIR | 训练与评估数据 |
GVP_CHECKPOINT | 预训练的 GVP-GNN 权重 |
OPENAI_API_KEY | 用于 GPT 基线评估的 API 密钥 |
SciCore-Mol 采用三阶段训练流程(参见上图):
在联合训练前,独立预训练各个组件。
bash scripts/run/gvp_mlp_pretrain_qwen.shpython scripts/layer2/train_layer2.py \
--config scripts/layer2/layer2_train_config.yaml连接所有模块进行联合 SFT 训练。LLM 学习通过特殊的 <mol> 令牌调用外部模块。
# Configure training in configs/qwen3_sft_epoch2_1.yaml
# Uses DeepSpeed ZeRO-3 for multi-GPU training
torchrun --nproc_per_node=4 \
cotrain_llm_diffusion/train_step1_llm.py \
--config configs/qwen3_sft_epoch2_1.yaml关键配置字段(位于 configs/qwen3_sft_epoch2_*.yaml):
paths.llm_name_or_path:基础 LLM 检查点paths.gnn_state_dict_path:预训练 GVP 权重paths.deepspeed_config:DeepSpeed 配置(ZeRO-2 或 ZeRO-3)training.freeze_strategy:控制哪些模块被冻结/可训练在下游任务上微调 Layer2(反应转换器),支持可配置的模块冻结:
python scripts/layer2/train_layer2.py \
--config scripts/layer2/layer2_train_config_stage2_v7b.yaml训练完成后,将检查点拆分为 LLM 和额外组件:
python scripts/ckpt/split_llm_extras.py \
--checkpoint_path ${CHECKPOINT_DIR}/your-checkpoint/ \
--output_dir ${CHECKPOINT_DIR}/your-checkpoint/# Evaluate all 5 tasks with logprob scoring
bash scripts/run/run_chembench_all_tasks.sh
# Or run individual tasks:
python scripts/eval/eval_layer2_chembench.py \
--checkpoint_dir ${CHECKPOINT_DIR}/your-checkpoint \
--task product \
--output_dir eval_results/chembench/python scripts/eval/eval_mmlu_interns1mini_5subsets.py \
--model_path ${MODEL_DIR}/your-model \
--output_dir eval_results/mmlu/# Run Layer2-LLM integrated pipeline
bash scripts/layer2_llm/run_full_pipeline.sh
# Score predictions
python scripts/postprocess/score_only.py \
--pred_dir eval_results/ord/# Automated multi-task evaluation with GPU scheduling
bash scripts/run/eval_smol_task_list.sh# LLM-based drug optimization
python eval/drug_optim/eval_admet.py \
--config eval/drug_optim/config/llm_cpt_sft.yaml
# Diffusion-based drug optimization
python eval/drug_optim/eval_diffusion.py \
--config eval/drug_optim/config/diffusion_sft.yaml@article{chen2026scicoremol,
title={SciCore-Mol: Augmenting Large Language Models with Pluggable Molecular Cognition Modules},
author={},
journal={arXiv preprint arXiv:XXXX.XXXXX},
year={2026}
}如果您有任何问题、建议或错误报告,请提交 issue 或发送邮件至:
chenyuxuan225@gmail.com本项目采用 MIT 和 Apache 2.0 双许可证授权。