---
title: tiny_llm_sft_92m
canonical_url: "https://www.modelscope.cn/models/wdndev/tiny_llm_sft_92m"
md_url: "https://www.modelscope.cn/models/wdndev/tiny_llm_sft_92m.md"
repository: wdndev/tiny_llm_sft_92m
chinese_name: "Tiny LLM 92m 对话模型"
last_updated: 2024-05-27
license: other
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - tinyllm
architectures:
  - TinyllmForCausalLM
library_name:
  - transformer
language:
  - zh
downloads: 859
stars: 6
tags:
  - chat
---

# tiny_llm_sft_92m

> tiny_llm_sft_92m - wdndev 在 ModelScope 开源的模型。tiny_llm_sft_92m模型

wdndev/tiny_llm_sft_92m 是 ModelScope 魔搭社区上的text-generation模型，采用 other 许可。

- **Repository**: wdndev/tiny_llm_sft_92m
- **License**: other
- **Tasks**: text-generation
- **Tags**: chat
- **Downloads**: 859
- **Stars**: 6
- **Last updated**: 2024-05-27

Source: https://www.modelscope.cn/models/wdndev/tiny_llm_sft_92m

---

## Tiny LLM 92M SFT

### 简介

本项目[wdndev/tiny-llm-zh (github.com)](https://github.com/wdndev/tiny-llm-zh)旨在构建一个小参数量的中文语言大模型，用于快速入门学习大模型相关知识。

模型架构：整体模型架构采用开源通用架构，包括：RMSNorm，RoPE，MHA等

实现细节：实现大模型两阶段训练及后续人类对齐，即：预训练(PTM) -> 指令微调(SFT) -> 人类对齐(RLHF, DPO) -> 测评。

注意：因资源限制，本项目的第一要务是走通大模型整个流程，而不是调教比较好的效果，故评测结果分数较低，部分生成结构错误。


### 模型细节

大约在9B的中文预料中训练，主要包含百科内容，模型架构采用开源通用架构，包括：RMSNorm，RoPE，MHA等。

### 环境

只需要安装 `transformers` 即可运行

### 快速开始

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "wdndev/tiny_llm_sft_92m"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True)

sys_text = "你是由wdndev开发的个人助手。"
# user_text = "中国的首都是哪儿？"
# user_text = "你叫什么名字？"
user_text = "介绍一下中国"
input_txt = "\n".join(["<|system|>", sys_text.strip(), 
                        "<|user|>", user_text.strip(), 
                        "<|assistant|>"]).strip() + "\n"

model_inputs = tokenizer(input_txt, return_tensors="pt").to(model.device)
generated_ids = model.generate(model_inputs.input_ids, max_new_tokens=200)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
```
