Text Generation
Transformers
Safetensors
Chinese
English
mindlm
causal-lm
chat
qwen3-tokenizer
gated-delta-net
linear-attention
conversational
custom_code
Instructions to use syjarvis/MindLM1-0.2B-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use syjarvis/MindLM1-0.2B-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="syjarvis/MindLM1-0.2B-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("syjarvis/MindLM1-0.2B-SFT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use syjarvis/MindLM1-0.2B-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "syjarvis/MindLM1-0.2B-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "syjarvis/MindLM1-0.2B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/syjarvis/MindLM1-0.2B-SFT
- SGLang
How to use syjarvis/MindLM1-0.2B-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "syjarvis/MindLM1-0.2B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "syjarvis/MindLM1-0.2B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "syjarvis/MindLM1-0.2B-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "syjarvis/MindLM1-0.2B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use syjarvis/MindLM1-0.2B-SFT with Docker Model Runner:
docker model run hf.co/syjarvis/MindLM1-0.2B-SFT
MindLM1-0.2B-SFT
模型概述
MindLM1-0.2B-SFT 是 MindLM1 系列的首个公开权重:一个约 0.2B 参数(206.83M)的中文聊天模型,面向中文短问答、闲聊与简单事实查询。
它验证了一条低成本路线——用混合线性注意力把 0.2B 模型塞进 2GiB 内存的 CPU 环境。无需 GPU 即可运行,适合在资源受限的本地环境中部署与实验。
模型信息
| 项 | 值 |
|---|---|
| 参数量 | 206.83M |
| 隐藏维度 / 层数 / Q 头 / KV 头 | 768 / 16 / 12 / 3 |
| 层排布 | linear×3 + attention 为一组,共 4 组 |
| 线性注意力 | Gated DeltaNet,chunk size 64 |
| 标准注意力 | RoPE + RMSNorm,后端 flash_attn_4(CPU 自动降级 SDPA) |
| FFN | SwiGLU,hidden 2048 |
| MoE / dropout | 无 MoE;dropout=0.0 |
| 词表 | 151,669 |
| 上下文 | 4096 |
| 精度 | bfloat16 |
| 推理特性 | 无 KV cache,generate() 每步重算全量上下文,长输出偏慢 |
快速开始
# pip install "transformers>=4.57.6" torch safetensors
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "syjarvis/MindLM1-0.2B-SFT"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype="bfloat16",
).eval()
messages = [
{"role": "user", "content": "你好,你是谁?"}
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False
)
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(model.device)
outputs = model.generate(
input_ids=input_ids,
max_new_tokens=256,
do_sample=False # do_sample=False,贪心解码,do_sample=True,随机采样
)
print(tokenizer.decode(outputs[0, input_ids.size(1):], skip_special_tokens=True))
# 你好!我是一个人工智能助手。有什么我可以帮助你的吗?
环境要求:transformers>=4.57.6(4.x / 5.x 均已验证)、torch、safetensors。
必须 trust_remote_code=True(模型代码在 modeling_mindlm.py 中)。
后端说明
config.json 默认 attention_backend="flash_attn_4"、linear_attn_backend="fla":
- CPU:自动走 SDPA + 参考实现,无需任何自定义 kernel。
- **CUDA 且装有
flash-attn(含flash_attn.cute)与flash-linear-attention**:按默认配置运行。 - CUDA 但没装上述 kernel:用纯 PyTorch 后端覆盖即可,无需重新导出:
model = AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype="bfloat16",
attention_backend="sdpa",
linear_attn_backend="reference",
).eval()
最佳实践(中文短问答)
import torch
torch.manual_seed(42) # 固定采样时使用
outputs = model.generate(
input_ids=input_ids, max_new_tokens=256, do_sample=True,
temperature=0.3, top_k=20, top_p=0.9, min_p=0.0,
eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id,
)
temperature是主导因素:0–0.3 稳,0.5 开始掺假,0.7 编造菜名,1.0 拒答/造谣并存。top_k=20比官方top_k=8菜品更多样;min_p=0.0等于不截断;top_p=0.9配合低温安全。
对话示例
以下为最佳实践参数(temperature=0.3, top_k=20, top_p=0.9, min_p=0.0, seed=42, max_new_tokens=256, enable_thinking=False)实测原样输出。
user> 请为我讲解"大语言模型"这个概念
assistant> "大语言模型"是指一种基于语言模型的模型,它能够预测一个特定语言的语义、语法、语义等信息。这种模型通常由多个语言模型组成,每个模型都由多个语料库组成,这些语料库包括了从文本中提取的词汇、语法结构和语义信息。通过训练模型,模型可以预测一个特定语言的语义、语法、语义等信息,从而实现对语言的预测和分析。
user> 你知道太阳吗
assistant> 你知道太阳吗
user> 你知道杭州在哪里嘛
assistant> 杭州位于中国浙江省,是中国最著名的城市之一。它位于长江口,东临杭州湾,南接杭州湾,西靠杭州湾。杭州是中国历史文化名城之一,也是中国著名的旅游城市之一。它拥有丰富的历史和文化遗产,包括西湖、灵隐寺、千岛湖、千岛湖等景点。
user> 中国的首都在哪里
assistant> 中国的首都是北京。
user> 你好
assistant> 你好,有什么我可以帮助你的吗?
user> 苹果是什么颜色的
assistant> 苹果的颜色因品种而异,但通常为红色、绿色或黄色。
局限
- 中文闲聊可用,存在复读情况。
- 没见过的工具 schema(如
calculate_math、random_number)基本调不动; 英文无工具场景可能幻觉<tool_call>(如历史问题调出不存在的get_history_by_id)。
License
MIT License
- Downloads last month
- -