初始化项目,由ModelHub XC社区提供模型
Model: Nwna/olmo3-190m-zh-v2-continue Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
230
README.md
Normal file
230
README.md
Normal file
@@ -0,0 +1,230 @@
|
||||
---
|
||||
base_model: Nwna/olmo3-190m-zh-v2-base
|
||||
license: apache-2.0
|
||||
language:
|
||||
- zh
|
||||
tags:
|
||||
- pretrained
|
||||
- olmo3
|
||||
- chinese
|
||||
- continue-pretrain
|
||||
- mid-training
|
||||
- llm001
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
datasets:
|
||||
- Nwna/olmo3-190m-zh-v2-continue-data
|
||||
- wikimedia/wikipedia
|
||||
- opencsg/chinese-cosmopedia
|
||||
---
|
||||
|
||||
# OLMo3-190M-zh-v2-continue
|
||||
|
||||
**中文 continue-pretrain 教学模型**,基于 `Nwna/olmo3-190m-zh-v2-base`,继续注入 **Wikipedia-zh + Cosmopedia-Chinese + base replay** 组成的 1.194B tokens 中文语料。
|
||||
|
||||
> 这是《零基础 AI 大模型研发训练营》第 04 讲进阶作业模型。它是 continue-pretrained base model,不是 instruction/chat model。
|
||||
|
||||
## 来源与动机
|
||||
|
||||
本模型的目标是验证 continue pretrain / mid-training 的工业范式:在已有 base model 上继续训练较小规模但更高事实密度、更强解释风格的数据,以较低成本改变模型的数据分布和表达风格。
|
||||
|
||||
本次实验特别关注:
|
||||
|
||||
```text
|
||||
1. 是否能从 base checkpoint 正确继续训练,而不是重新随机初始化。
|
||||
2. tokenizer 是否和 base 模型严格一致。
|
||||
3. Wiki / Cosmopedia 是否能提升事实密度和解释型表达。
|
||||
4. continue pretrain 是否能替代 SFT。
|
||||
```
|
||||
|
||||
结论简述:
|
||||
|
||||
- ✅ 训练链路健康,loss 从 smoke 阶段约 3.42 降到 full final 约 3.04。
|
||||
- ✅ Continue 模型更容易生成教材式、百科式长段落。
|
||||
- ⚠️ 事实问答仍不可靠,例如“北京大学位于”“四大发明是”仍可能答错。
|
||||
- ⚠️ 该模型不能替代 SFT;后续仍需要监督微调来学习问答格式和事实表达。
|
||||
|
||||
## 架构
|
||||
|
||||
与 `Nwna/olmo3-190m-zh-v2-base` 相同:
|
||||
|
||||
| 字段 | 值 |
|
||||
|---|---:|
|
||||
| `architectures` | `["Olmo3ForCausalLM"]` |
|
||||
| `hidden_size` | 768 |
|
||||
| `num_hidden_layers` | 12 |
|
||||
| `num_attention_heads` | 12 |
|
||||
| `intermediate_size` | 3072 |
|
||||
| `vocab_size` | 48,000 |
|
||||
| `max_position_embeddings` | 4096 |
|
||||
| training seq_len | 2048 |
|
||||
| total params | ~187M |
|
||||
|
||||
## 使用
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
tok = AutoTokenizer.from_pretrained("Nwna/olmo3-190m-zh-v2-continue")
|
||||
model = AutoModelForCausalLM.from_pretrained("Nwna/olmo3-190m-zh-v2-continue")
|
||||
|
||||
inputs = tok("人工智能是", return_tensors="pt")
|
||||
outputs = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=120,
|
||||
do_sample=True,
|
||||
temperature=0.8,
|
||||
top_p=0.9,
|
||||
)
|
||||
print(tok.decode(outputs[0], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
### 用于 SFT
|
||||
|
||||
v2-continue 是 continue-pretrained base model。它可以作为后续 SFT 底座:
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained("Nwna/olmo3-190m-zh-v2-continue")
|
||||
# ... 用 SFTTrainer / 自定义 Trainer 做监督微调
|
||||
```
|
||||
|
||||
## 训练配方
|
||||
|
||||
### 数据混合(1.194B tokens)
|
||||
|
||||
| 数据源 | 来源 | tokens | 作用 |
|
||||
|---|---|---:|---|
|
||||
| base replay | base raw 抽样 | 300M | 防止灾难性遗忘,保留通用中文能力 |
|
||||
| Wikipedia-zh | `wikimedia/wikipedia` config `20231101.zh` | 394M | 注入实体、地点、历史、文学等百科事实 |
|
||||
| Cosmopedia-Chinese | `opencsg/chinese-cosmopedia` | 500M | 注入解释型、教材型、知识组织文本 |
|
||||
| 合计 | - | 1.194B | continue pretrain full data |
|
||||
|
||||
所有 continue 数据都使用 `Nwna/olmo3-190m-zh-v2-tokenizer` 重新编码,没有直接复用其他模型或数据集中的 tokenized `.bin`。这是必须条件:token id 的语义由 tokenizer 决定,混用 tokenizer 会导致 embedding / lm_head 语义错位。
|
||||
|
||||
### 数据健康检查
|
||||
|
||||
```text
|
||||
actual_tokens: 1,194,000,000
|
||||
documents: 1,203,778
|
||||
file_size_bytes: 2,388,000,000
|
||||
max_token_id: 47,999
|
||||
eos_token_id: 0
|
||||
avg_traditional_probe_ratio: 0.000508
|
||||
noise_pattern_hit: false
|
||||
```
|
||||
|
||||
定向抽查覆盖了 `北京大学`、`四大发明`、`造纸术`、`印刷术`、`火药`、`指南针`、`红楼梦`、`贾宝玉`、`林黛玉`、`Python`、`人工智能` 等关键词。抽查只能证明语料中有覆盖,不能保证模型一定稳定回答。
|
||||
|
||||
### 超参
|
||||
|
||||
| 项目 | 值 |
|
||||
|---|---:|
|
||||
| base checkpoint | `Nwna/olmo3-190m-zh-v2-base` |
|
||||
| GPU | H100 |
|
||||
| precision | bf16 |
|
||||
| attention | SDPA |
|
||||
| epochs | 1.0 |
|
||||
| total steps | 4,328 |
|
||||
| per-device batch | 16 |
|
||||
| grad accumulation | 8 |
|
||||
| effective batch | 128 sequences |
|
||||
| tokens / step | 262,144 |
|
||||
| peak lr | 2e-4 |
|
||||
| min lr | 2e-5 |
|
||||
| warmup ratio | 10% |
|
||||
| scheduler | warmup + cosine |
|
||||
| optimizer | AdamW |
|
||||
| weight decay | 0.1,embedding / norm / bias excluded |
|
||||
|
||||
为什么学习率低于 base:continue 阶段模型已有中文语言建模能力,过大学习率容易破坏已有能力;因此使用更低 peak lr 和更长 warmup,使模型更平滑地适应新分布。
|
||||
|
||||
## Loss 轨迹
|
||||
|
||||
### 20-step smoke
|
||||
|
||||
| steps | train_loss | eval_loss | GPU |
|
||||
|---:|---:|---:|---|
|
||||
| 20 | 3.4235 | 3.3283 | A100-80G |
|
||||
|
||||
A100 40G 在同样 batch 配置下 OOM;A100-80G 可跑通;正式 full 使用 H100。
|
||||
|
||||
### Full 1 epoch
|
||||
|
||||
| metric | value |
|
||||
|---|---:|
|
||||
| total steps | 4,328 |
|
||||
| train_runtime | 8,964.52s |
|
||||
| train_steps_per_second | 0.483 |
|
||||
| train_loss | 3.0431 |
|
||||
| last_eval_loss | 2.9404 |
|
||||
| final learning_rate | 2.0002e-05 |
|
||||
| final grad_norm | 0.2779 |
|
||||
|
||||
|
||||
## Base → Continue 7-prompt 抽测
|
||||
|
||||
使用 `src/eval.py` 的采样生成设置:
|
||||
|
||||
```text
|
||||
max_new_tokens=120
|
||||
do_sample=True
|
||||
temperature=0.8
|
||||
top_p=0.9
|
||||
repetition_penalty=1.1
|
||||
```
|
||||
|
||||
| Prompt | Base | Continue | 变化 |
|
||||
|---|---|---|---|
|
||||
| 人工智能是 | 🟡 可生成科普,但较泛 | 🟡 更像教材式分领域展开 | 风格增强 |
|
||||
| 山里有座庙 | 🟡 偏文物/寺庙说明 | 🟡 更像故事长叙事 | 续写更长,但仍虚构 |
|
||||
| 今天天气不错,我准备 | 🟡 对话关系混乱 | 🟡 叙事更完整但漂移到奇幻故事 | 表达增强,控制仍弱 |
|
||||
| 北京大学位于 | 🔴 答错地点 | 🔴 仍答错地点 | 未解决事实问答 |
|
||||
| 四大发明是 | 🔴 错到电力设备列表 | 🔴 错到科学史人物 | 未解决事实问答 |
|
||||
| 《红楼梦》人物 | 🔴 标题式重复 | 🔴 输出过短,未答人物 | 未解决文学知识 |
|
||||
| Python 是一种 | 🟡 知道与编程相关但定义混乱 | 🟡 更像解释型文本,但仍不准确 | 小幅改善 |
|
||||
|
||||
关键 takeaways:
|
||||
|
||||
- ✅ Continue pretrain 改变了表达风格,模型更容易生成解释型、教材型文本。
|
||||
- ⚠️ Continue pretrain 没有把模型变成可靠问答模型。
|
||||
- ⚠️ 事实问答、格式控制和重复控制应交给后续 SFT。
|
||||
|
||||
## 限制
|
||||
|
||||
1. **事实记忆上限**:190M 参数规模较小,即使语料中包含事实,也不保证稳定召回。
|
||||
2. **未做 SFT**:该模型不是 chat model,不会稳定遵循指令。
|
||||
3. **采样评估会波动**:`do_sample=True` 时,同一 prompt 多次生成可能不同。
|
||||
4. **Wiki / 网页格式风险**:尽管已清洗,仍可能出现标题腔、列表腔或重复。
|
||||
5. **in-domain eval 不能等同通用能力**:continue eval loss 在 continue 数据分布上更低,不能直接代表所有下游任务变好。
|
||||
|
||||
## License
|
||||
|
||||
- **模型权重**:Apache-2.0
|
||||
- **训练数据**:混合 license
|
||||
- base replay 来自 base 阶段中文网页/教育数据
|
||||
- Cosmopedia-Chinese:请参考原数据集许可
|
||||
- Wikipedia-zh:含 CC-BY-SA-3.0 + GFDL 许可风险,商用前请咨询法律
|
||||
|
||||
权重声明为 Apache-2.0,但训练数据含 Wikipedia-zh,使用者应自行评估 share-alike 数据对下游使用的影响。
|
||||
|
||||
## 配套资源
|
||||
|
||||
- Base model: <https://huggingface.co/Nwna/olmo3-190m-zh-v2-base>
|
||||
- Tokenizer: <https://huggingface.co/Nwna/olmo3-190m-zh-v2-tokenizer>
|
||||
- Continue data card: <https://huggingface.co/datasets/Nwna/olmo3-190m-zh-v2-continue-data>
|
||||
- Space demo: <https://huggingface.co/spaces/Nwna/olmo3-190m-zh-v2-continue>
|
||||
- 作业报告:`ch04(下)进阶作业:持续预训练_v2.md`
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@misc{nwna-olmo3-190m-zh-v2-continue,
|
||||
title={OLMo3-190M-zh-v2-continue: Chinese Continue-Pretrained Teaching Model},
|
||||
author={Nwna},
|
||||
year={2026},
|
||||
howpublished={\url{https://huggingface.co/Nwna/olmo3-190m-zh-v2-continue}},
|
||||
note={LLM001 Course, Lecture 04 advanced homework}
|
||||
}
|
||||
```
|
||||
8
chat_template.jinja
Normal file
8
chat_template.jinja
Normal file
@@ -0,0 +1,8 @@
|
||||
{% for message in messages %}{% if message['role'] == 'system' %}<|im_start|>system
|
||||
{{ message['content'] }}<|im_end|>
|
||||
{% elif message['role'] == 'user' %}<|im_start|>user
|
||||
{{ message['content'] }}<|im_end|>
|
||||
{% elif message['role'] == 'assistant' %}{% generation %}<|im_start|>assistant
|
||||
{{ message['content'] }}<|im_end|>
|
||||
{% endgeneration %}{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
||||
{% endif %}
|
||||
43
config.json
Normal file
43
config.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Olmo3ForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"attn_implementation": "sdpa",
|
||||
"bos_token_id": 2,
|
||||
"dtype": "float32",
|
||||
"eos_token_id": 0,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 768,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 3072,
|
||||
"layer_types": [
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"sliding_attention",
|
||||
"full_attention"
|
||||
],
|
||||
"max_position_embeddings": 4096,
|
||||
"model_type": "olmo3",
|
||||
"num_attention_heads": 12,
|
||||
"num_hidden_layers": 12,
|
||||
"num_key_value_heads": 12,
|
||||
"pad_token_id": 1,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 500000,
|
||||
"sliding_window": 4096,
|
||||
"tie_word_embeddings": false,
|
||||
"transformers_version": "4.57.6",
|
||||
"use_cache": true,
|
||||
"vocab_size": 48000
|
||||
}
|
||||
9
generation_config.json
Normal file
9
generation_config.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 2,
|
||||
"eos_token_id": [
|
||||
0
|
||||
],
|
||||
"pad_token_id": 1,
|
||||
"transformers_version": "4.57.6"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:31887a6e73517420b7e6e3f5772c9a861774fd52eb8d4b903a19effe7a7933c9
|
||||
size 748062408
|
||||
36
special_tokens_map.json
Normal file
36
special_tokens_map.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<|im_start|>",
|
||||
"<|im_end|>",
|
||||
"<think>",
|
||||
"</think>"
|
||||
],
|
||||
"bos_token": {
|
||||
"content": "<|bos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"unk_token": {
|
||||
"content": "<|unk|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
239066
tokenizer.json
Normal file
239066
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
82
tokenizer_config.json
Normal file
82
tokenizer_config.json
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"added_tokens_decoder": {
|
||||
"0": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"1": {
|
||||
"content": "<|pad|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"2": {
|
||||
"content": "<|bos|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"3": {
|
||||
"content": "<|unk|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"4": {
|
||||
"content": "<|im_start|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"5": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"6": {
|
||||
"content": "<think>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"7": {
|
||||
"content": "</think>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [
|
||||
"<|im_start|>",
|
||||
"<|im_end|>",
|
||||
"<think>",
|
||||
"</think>"
|
||||
],
|
||||
"bos_token": "<|bos|>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "<|endoftext|>",
|
||||
"extra_special_tokens": {},
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"pad_token": "<|pad|>",
|
||||
"tokenizer_class": "PreTrainedTokenizerFast",
|
||||
"unk_token": "<|unk|>"
|
||||
}
|
||||
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6295343afafd17eb1bdf3ce051ec5c141f5e75de998f082b7b0d30a3447325f1
|
||||
size 5432
|
||||
Reference in New Issue
Block a user