@lzhzzzzwill/cofos 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -10
- package/RUNTIME.md +38 -0
- package/bin/cofos.js +80 -20
- package/package.json +16 -4
- package/requirements.txt +0 -3
- package/runtime/config/config.yaml +73 -260
- package/runtime/config/prompt_templates.yaml +73 -369
- package/runtime/src/data_processing/__init__.py +2 -27
- package/runtime/src/data_processing/utils.py +22 -1
- package/runtime/src/inference/__init__.py +2 -6
- package/runtime/src/inference/query_router.py +23 -11
- package/runtime/src/inference/student_adapter_inference.py +312 -61
- package/runtime/src/retrieval/__init__.py +14 -7
- package/runtime/src/retrieval/retrieve_evidence.py +84 -25
- package/scripts/chat.py +91 -28
- package/scripts/sync_runtime.py +45 -0
- package/runtime/config/qwen3_5_config.md +0 -46
- package/runtime/src/data_processing/clean_json_records.py +0 -387
- package/runtime/src/data_processing/parse_wos_xlsx.py +0 -255
- package/runtime/src/data_processing/schema_utils.py +0 -56
- package/runtime/src/inference/run_kg_grounded_inference.py +0 -370
- package/runtime/src/retrieval/build_faiss_index.py +0 -328
|
@@ -1,144 +1,32 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# COFOS standalone runtime config.
|
|
2
|
+
# This file is generated by scripts/sync_fwdemo_runtime.py for the npm CLI.
|
|
3
|
+
# It intentionally omits full-project training, extraction, and Ollama teacher settings.
|
|
3
4
|
project_name: COF-ROS-Reasoner
|
|
4
5
|
version: 1.0.0
|
|
5
|
-
|
|
6
6
|
paths:
|
|
7
|
-
# 原始数据路径
|
|
8
7
|
raw_pdfs: data/raw_pdfs
|
|
9
8
|
raw_json: data/raw_json
|
|
10
9
|
raw_wos: data/raw_wos/wos_abstracts.xlsx
|
|
11
|
-
|
|
12
|
-
# 处理后数据路径
|
|
13
10
|
processed_dir: data/processed
|
|
14
11
|
sft_dir: data/sft
|
|
15
12
|
kg_dir: data/kg
|
|
16
13
|
eval_dir: data/eval
|
|
17
|
-
|
|
18
|
-
# 检索库路径
|
|
19
14
|
retrieval_store: retrieval_store/embedding
|
|
20
15
|
bm25_store: retrieval_store/bm25
|
|
21
|
-
|
|
22
|
-
# 模型和输出路径
|
|
23
16
|
checkpoints_dir: checkpoints
|
|
24
17
|
outputs_dir: outputs
|
|
25
18
|
logs_dir: outputs/logs
|
|
26
|
-
|
|
27
19
|
models:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# 独立 npx QA 不会调用这些内网 Ollama 模型。
|
|
31
|
-
teacher_model: qwen3.6:35b
|
|
32
|
-
student_model: qwen3.5:4b
|
|
33
|
-
|
|
34
|
-
# 如需启用 FAISS 向量检索,可改成本地 embedding 模型目录。
|
|
35
|
-
embedding_model: ""
|
|
36
|
-
reranker_model: ""
|
|
37
|
-
|
|
38
|
-
# 本地/内网 LLM 调用配置。fwdemo 独立 QA 路径不使用该配置;
|
|
39
|
-
# 它只保留给完整项目里的 Silver 抽取、教师蒸馏、KG-RAG 教师回答等流程。
|
|
40
|
-
llm:
|
|
41
|
-
provider: ollama
|
|
42
|
-
generate_url: http://10.161.138.150:11434/api/generate
|
|
43
|
-
teacher_model: qwen3.6:35b
|
|
44
|
-
student_model: qwen3.5:4b
|
|
45
|
-
extraction_model: qwen3.6:35b
|
|
46
|
-
inference_model: qwen3.6:35b
|
|
47
|
-
student_inference_model: qwen3.5:4b
|
|
48
|
-
timeout: 120
|
|
49
|
-
stream: false
|
|
50
|
-
temperature: 0.2
|
|
51
|
-
top_p: 0.9
|
|
52
|
-
|
|
53
|
-
extraction:
|
|
54
|
-
only_ros_related_chunks: true
|
|
55
|
-
resume: true
|
|
56
|
-
save_every: 10
|
|
57
|
-
progress_every: 1
|
|
58
|
-
max_chunks: null
|
|
59
|
-
|
|
60
|
-
distillation:
|
|
61
|
-
input_file: data/sft/cofros_train.jsonl
|
|
62
|
-
output_file: data/sft/cofros_teacher_distill.jsonl
|
|
63
|
-
progress_file: data/sft/teacher_distillation_progress.json
|
|
64
|
-
resume: true
|
|
65
|
-
save_every: 10
|
|
66
|
-
max_samples: null
|
|
67
|
-
|
|
68
|
-
rag_sft:
|
|
69
|
-
output_file: data/sft/cofros_rag_sft.jsonl
|
|
70
|
-
max_records: null
|
|
71
|
-
max_evidence_items: 5
|
|
72
|
-
skip_generic_material: true
|
|
73
|
-
include_support_status:
|
|
74
|
-
- supported
|
|
75
|
-
- partially_supported
|
|
76
|
-
include_gold: true
|
|
77
|
-
|
|
78
|
-
# 训练配置
|
|
79
|
-
# Linux服务器 Qwen3.5 系列优化配置
|
|
80
|
-
training:
|
|
81
|
-
target_model: qwen3.5:4b
|
|
82
|
-
# QLoRA 训练需要 Transformers 格式的本地基础模型目录。
|
|
83
|
-
# 这里不要填 Ollama tag;请在服务器上改成实际模型目录,例如 /models/qwen3.5-4b-instruct。
|
|
84
|
-
base_model_path: ""
|
|
85
|
-
# 主训练集仍然是教师蒸馏数据;辅助集补充 RAG 输入格式、氧化还原基础和自然问答风格。
|
|
86
|
-
train_file: data/sft/cofros_teacher_distill.jsonl
|
|
87
|
-
aux_train_files:
|
|
88
|
-
- data/sft/cofros_rag_sft.jsonl
|
|
89
|
-
- data/sft/chem_redox_sft.jsonl
|
|
90
|
-
- data/sft/style_correction_sft.jsonl
|
|
91
|
-
output_dir: checkpoints/lora_adapter_natural_redox_mix
|
|
92
|
-
max_seq_length: 4096
|
|
93
|
-
learning_rate: 2.0e-4
|
|
94
|
-
num_train_epochs: 3
|
|
95
|
-
per_device_train_batch_size: 1
|
|
96
|
-
gradient_accumulation_steps: 8
|
|
97
|
-
lora_r: 32
|
|
98
|
-
lora_alpha: 64
|
|
99
|
-
lora_dropout: 0.05
|
|
100
|
-
load_in_4bit: true
|
|
101
|
-
bf16: true
|
|
102
|
-
fp16: false # Qwen3.5 推荐使用 bf16
|
|
103
|
-
seed: 42
|
|
104
|
-
logging_steps: 10
|
|
105
|
-
save_steps: 500
|
|
106
|
-
save_total_limit: 3
|
|
107
|
-
resume_from_checkpoint: auto
|
|
108
|
-
warmup_ratio: 0.03
|
|
109
|
-
weight_decay: 0.0
|
|
110
|
-
max_grad_norm: 0.3
|
|
111
|
-
local_files_only: true
|
|
112
|
-
trust_remote_code: true
|
|
113
|
-
gradient_checkpointing: true
|
|
114
|
-
target_modules:
|
|
115
|
-
- q_proj
|
|
116
|
-
- k_proj
|
|
117
|
-
- v_proj
|
|
118
|
-
- o_proj
|
|
119
|
-
- gate_proj
|
|
120
|
-
- up_proj
|
|
121
|
-
- down_proj
|
|
122
|
-
|
|
123
|
-
# Qwen3.5 专用配置
|
|
124
|
-
model_type: qwen3 # qwen, qwen2, qwen3
|
|
125
|
-
use_flash_attn: true # 启用 FlashAttention 加速
|
|
126
|
-
|
|
127
|
-
# 学生模型推理与部署路径。脚本参数可覆盖这些值。
|
|
20
|
+
embedding_model: ''
|
|
21
|
+
reranker_model: ''
|
|
128
22
|
student_inference:
|
|
129
|
-
# 独立 fwdemo 默认使用 Hugging Face 模型;若本地已有 merged checkpoint,可在 CLI 中传 --model 覆盖。
|
|
130
|
-
base_model_path: ""
|
|
131
|
-
adapter_path: ""
|
|
132
23
|
merged_model_path: Willlzh/COFOS
|
|
133
|
-
|
|
134
|
-
# 检索配置
|
|
135
24
|
retrieval:
|
|
136
25
|
enable_faiss: false
|
|
137
26
|
enable_bm25: true
|
|
138
27
|
vector_top_k: 20
|
|
139
28
|
bm25_top_k: 20
|
|
140
29
|
rerank_top_k: 5
|
|
141
|
-
# 无结果优于错误结果:低于阈值时不向模型注入 RAG 上下文。
|
|
142
30
|
min_bm25_score: 7.0
|
|
143
31
|
min_vector_score: 0.35
|
|
144
32
|
min_kg_confidence: 2.0
|
|
@@ -150,8 +38,6 @@ retrieval:
|
|
|
150
38
|
pdf_fulltext: 2
|
|
151
39
|
wos: 1
|
|
152
40
|
wos_abstract: 1
|
|
153
|
-
|
|
154
|
-
# 生成配置
|
|
155
41
|
generation:
|
|
156
42
|
temperature: 0.2
|
|
157
43
|
top_p: 0.9
|
|
@@ -163,151 +49,78 @@ generation:
|
|
|
163
49
|
min_new_tokens: 0
|
|
164
50
|
history_max_turns: 4
|
|
165
51
|
refine_answers: true
|
|
52
|
+
stream_refinement: true
|
|
166
53
|
refinement_max_new_tokens: 512
|
|
167
|
-
|
|
168
|
-
# 数据处理配置
|
|
169
54
|
data_processing:
|
|
170
|
-
# PDF chunk 配置
|
|
171
55
|
chunk_size: 768
|
|
172
56
|
chunk_overlap: 50
|
|
173
|
-
|
|
174
|
-
# ROS 物种标准化
|
|
175
57
|
ros_normalization:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"OH": "·OH"
|
|
204
|
-
"O2-": "O2·-"
|
|
205
|
-
"O2*": "*O2"
|
|
206
|
-
"OOH*": "*OOH"
|
|
207
|
-
"HOOH*": "*HOOH"
|
|
208
|
-
|
|
209
|
-
# ROS 关键词(用于段落筛选)
|
|
58
|
+
center dot OH: ·OH
|
|
59
|
+
OH·: ·OH
|
|
60
|
+
•OH: ·OH
|
|
61
|
+
⋅OH: ·OH
|
|
62
|
+
hydroxyl radical: ·OH
|
|
63
|
+
O2 center dot-: O2·-
|
|
64
|
+
O2•−: O2·-
|
|
65
|
+
•O2-: O2·-
|
|
66
|
+
superoxide: O2·-
|
|
67
|
+
superoxide radical: O2·-
|
|
68
|
+
1O2: 1O2
|
|
69
|
+
¹O₂: 1O2
|
|
70
|
+
singlet oxygen: 1O2
|
|
71
|
+
H2O2: H2O2
|
|
72
|
+
hydrogen peroxide: H2O2
|
|
73
|
+
SO4·-: SO4·-
|
|
74
|
+
SO4•−: SO4·-
|
|
75
|
+
sulfate radical: SO4·-
|
|
76
|
+
'*O2': '*O2'
|
|
77
|
+
'*OOH': '*OOH'
|
|
78
|
+
'*HOOH': '*HOOH'
|
|
79
|
+
OH: ·OH
|
|
80
|
+
O2-: O2·-
|
|
81
|
+
O2*: '*O2'
|
|
82
|
+
OOH*: '*OOH'
|
|
83
|
+
HOOH*: '*HOOH'
|
|
210
84
|
ros_keywords:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
# 证据方法关键词
|
|
85
|
+
- ROS
|
|
86
|
+
- reactive oxygen species
|
|
87
|
+
- H2O2
|
|
88
|
+
- hydrogen peroxide
|
|
89
|
+
- 2e- ORR
|
|
90
|
+
- oxygen reduction reaction
|
|
91
|
+
- superoxide
|
|
92
|
+
- O2·-
|
|
93
|
+
- singlet oxygen
|
|
94
|
+
- 1O2
|
|
95
|
+
- hydroxyl radical
|
|
96
|
+
- ·OH
|
|
97
|
+
- sulfate radical
|
|
98
|
+
- SO4·-
|
|
99
|
+
- PMS
|
|
100
|
+
- PDS
|
|
101
|
+
- EPR
|
|
102
|
+
- ESR
|
|
103
|
+
- DMPO
|
|
104
|
+
- TEMP
|
|
105
|
+
- TEMPO
|
|
106
|
+
- scavenger
|
|
107
|
+
- quenching
|
|
108
|
+
- probe
|
|
109
|
+
- photocatalysis
|
|
110
|
+
- photodynamic
|
|
111
|
+
- donor-acceptor
|
|
112
|
+
- COF
|
|
113
|
+
- covalent organic framework
|
|
242
114
|
evidence_methods:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
# KG 构建配置
|
|
257
|
-
kg:
|
|
258
|
-
progress_every: 100
|
|
259
|
-
node_types:
|
|
260
|
-
- Material
|
|
261
|
-
- Reaction_Condition
|
|
262
|
-
- Driving_Force
|
|
263
|
-
- Oxidant_Source
|
|
264
|
-
- ROS_or_Product
|
|
265
|
-
- Intermediate
|
|
266
|
-
- Evidence_Method
|
|
267
|
-
- Application
|
|
268
|
-
- Target
|
|
269
|
-
- Paper
|
|
270
|
-
relation_types:
|
|
271
|
-
- dominantly_generates
|
|
272
|
-
- secondarily_generates
|
|
273
|
-
- has_intermediate
|
|
274
|
-
- under_condition
|
|
275
|
-
- driven_by
|
|
276
|
-
- uses_oxidant
|
|
277
|
-
- evidenced_by
|
|
278
|
-
- reported_in
|
|
279
|
-
- applied_to
|
|
280
|
-
- targets
|
|
281
|
-
|
|
282
|
-
# 推理配置
|
|
283
|
-
inference:
|
|
284
|
-
# KG-RAG 配置
|
|
285
|
-
kg_rag:
|
|
286
|
-
top_k_facts: 10
|
|
287
|
-
top_k_evidence: 5
|
|
288
|
-
evidence_weight: 0.7
|
|
289
|
-
kg_weight: 0.3
|
|
290
|
-
|
|
291
|
-
# 幻觉检测配置
|
|
292
|
-
hallucination_detection:
|
|
293
|
-
check_ros_speices: true
|
|
294
|
-
check_evidence_methods: true
|
|
295
|
-
check_conditions: true
|
|
296
|
-
check_sources: true
|
|
297
|
-
|
|
298
|
-
# 评测配置
|
|
299
|
-
evaluation:
|
|
300
|
-
# 评测样本数量
|
|
301
|
-
num_samples: 100
|
|
302
|
-
|
|
303
|
-
# 幻觉类型
|
|
304
|
-
hallucination_types:
|
|
305
|
-
- fabricated_ros
|
|
306
|
-
- wrong_dominant_species
|
|
307
|
-
- h2o2_as_radical
|
|
308
|
-
- so4_for_pms_absent
|
|
309
|
-
- epr_fabricated
|
|
310
|
-
- condition_omitted
|
|
311
|
-
- abstract_as_evidence
|
|
312
|
-
- overconfident
|
|
313
|
-
- cross_cof_misattribution
|
|
115
|
+
- EPR
|
|
116
|
+
- ESR
|
|
117
|
+
- DMPO
|
|
118
|
+
- TEMP
|
|
119
|
+
- TEMPO
|
|
120
|
+
- scavenger
|
|
121
|
+
- quenching
|
|
122
|
+
- probe
|
|
123
|
+
- in situ
|
|
124
|
+
- DRIFTS
|
|
125
|
+
- DFT
|
|
126
|
+
- calculation
|