初始化项目,由ModelHub XC社区提供模型
Model: ynanxiu/olmo3-190M-zh-sft Source: Original Platform
This commit is contained in:
136
README.md
Normal file
136
README.md
Normal file
@@ -0,0 +1,136 @@
|
||||
---
|
||||
language:
|
||||
- zh
|
||||
tags:
|
||||
- olmo3
|
||||
- chinese
|
||||
- sft
|
||||
- chat
|
||||
- fine-tuned
|
||||
- rtx4060
|
||||
license: apache-2.0
|
||||
pipeline_tag: text-generation
|
||||
base_model: ynanxiu/olmo3-190M-zh-full
|
||||
---
|
||||
|
||||
# OLMo3-190M-zh-sft
|
||||
|
||||
**187M 参数中文 SFT 对话模型**——让预训练模型学会聊天。
|
||||
|
||||
基于 [OLMo3-190M-zh-full](https://huggingface.co/ynanxiu/olmo3-190M-zh-full) 进行有监督微调(SFT),专为中文对话场景训练。
|
||||
|
||||
## 📊 模型信息
|
||||
|
||||
| 项目 | 详情 |
|
||||
|------|------|
|
||||
| **基座模型** | [ynanxiu/olmo3-190M-zh-full](https://huggingface.co/ynanxiu/olmo3-190M-zh-full) |
|
||||
| **架构** | OLMo3, 12层, d=768, 12头, SwiGLU |
|
||||
| **参数量** | 187M |
|
||||
| **词表大小** | 48,000 |
|
||||
| **训练方式** | SFT(Supervised Fine-Tuning) |
|
||||
| **训练数据** | `cmz1024/llm101-olmo3-zh-demo-data` (SFT 对话格式) |
|
||||
| **格式** | ChatML (`<|user|>...<|assistant|>...`) |
|
||||
|
||||
## 🏋️ 训练详情
|
||||
|
||||
| 参数 | 值 |
|
||||
|------|-----|
|
||||
| 硬件 | NVIDIA RTX 4060 (8GB) |
|
||||
| 精度 | bfloat16 |
|
||||
| Batch Size | 1 × 32 (gradient_accumulation) |
|
||||
| 学习率 | 2e-5 |
|
||||
| LR Schedule | cosine + warmup (5%) |
|
||||
| Epochs | 2 |
|
||||
| 总步数 | 56,470 |
|
||||
| 训练耗时 | 31 小时 |
|
||||
|
||||
## 📈 训练指标
|
||||
|
||||
| 阶段 | Eval Loss | Accuracy | Entropy |
|
||||
|------|-----------|----------|---------|
|
||||
| 初始 (500步) | 3.36 | 43.1% | 3.388 |
|
||||
| 最终 (56,470步) | **2.24** | **54.6%** | **2.572** |
|
||||
|
||||
Loss 从 3.36 降至 2.24,下降 33%;accuracy 从 43% 升至 55%。
|
||||
|
||||
## 💬 使用方法
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
import torch
|
||||
|
||||
model_id = "ynanxiu/olmo3-190M-zh-sft"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_id,
|
||||
torch_dtype=torch.bfloat16,
|
||||
attn_implementation="sdpa",
|
||||
trust_remote_code=True,
|
||||
)
|
||||
|
||||
# 对话模式(推荐)
|
||||
messages = [{"role": "user", "content": "你好,请用简单的语言解释什么是机器学习"}]
|
||||
formatted = tokenizer.apply_chat_template(
|
||||
messages, tokenize=False, add_generation_prompt=True
|
||||
)
|
||||
inputs = tokenizer(formatted, return_tensors="pt")
|
||||
|
||||
with torch.no_grad():
|
||||
outputs = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=200,
|
||||
temperature=0.3, # ⚠️ 推荐 0.3,避免重复
|
||||
top_p=0.9,
|
||||
do_sample=True,
|
||||
repetition_penalty=1.15,
|
||||
pad_token_id=tokenizer.pad_token_id,
|
||||
)
|
||||
|
||||
response = tokenizer.decode(outputs[0][len(inputs["input_ids"][0]):], skip_special_tokens=True)
|
||||
print(response)
|
||||
```
|
||||
|
||||
### ⚙️ 推荐生成参数
|
||||
|
||||
| 参数 | 推荐值 | 说明 |
|
||||
|------|--------|------|
|
||||
| temperature | **0.3** | 190M 模型不建议超过 0.5,高温导致严重重复 |
|
||||
| repetition_penalty | 1.15~1.2 | 抑制重复 |
|
||||
| top_p | 0.9 | 标准核采样 |
|
||||
| max_new_tokens | 150~200 | 太长容易退化 |
|
||||
|
||||
## 🎮 在线体验
|
||||
|
||||
👉 **[HuggingFace Space](https://huggingface.co/spaces/ynanxiu/olmo3-190M-zh-sft)** — 直接在浏览器里对话
|
||||
|
||||
## 📝 生成效果
|
||||
|
||||
### 成功案例 ✅
|
||||
|
||||
```
|
||||
用户:你好,请问你能帮我做什么?
|
||||
助手:当然可以!请告诉我你最近在做什么,或者有什么具体问题
|
||||
我可以帮你解决?我会尽力提供帮助。
|
||||
|
||||
用户:今天天气不错,我准备
|
||||
助手:我无法提供实时天气信息或天气预报。建议您查看天气应用
|
||||
或网站获取最新天气信息。如果您有其他问题,欢迎随时提问!
|
||||
```
|
||||
|
||||
### 已知限制 ⚠️
|
||||
|
||||
- **重复问题**:190M 参数较小,长回复可能出现重复。建议 temperature ≤ 0.3 + repetition_penalty ≥ 1.15。
|
||||
- **知识幻觉**:可能生成不准确的事实(如自称 "minimind"),SFT 数据影响了模型认知。
|
||||
- **复杂推理**:190M 参数量不适合复杂多轮推理任务。
|
||||
|
||||
## 🔗 相关模型
|
||||
|
||||
| 模型 | 类型 | 链接 |
|
||||
|------|------|------|
|
||||
| OLMo3-190M-zh-full | 基础预训练 | [HF](https://huggingface.co/ynanxiu/olmo3-190M-zh-full) |
|
||||
| OLMo3-190M-zh-nano | 小模型持续预训练 | [HF](https://huggingface.co/ynanxiu/olmo3-190M-zh-nano) |
|
||||
|
||||
## 📜 License
|
||||
|
||||
Apache 2.0
|
||||
Reference in New Issue
Block a user