Edit model card

Tiny LLM 92M SFT

简介

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

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

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

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

模型细节

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

环境

只需要安装 transformers 即可运行

快速开始

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)
Downloads last month
16
Safetensors
Model size
92.1M params
Tensor type
BF16
·
Inference API
Input a message to start chatting with wdndev/tiny_llm_sft_92m.
Inference API (serverless) does not yet support model repos that contain custom code.