0xDing/wikipedia-cn-20230720-filtered
Viewer • Updated • 255k • 1.89k • 172
How to use Q1ngMang/LFM2.5-230M-PT-zh_CN with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Q1ngMang/LFM2.5-230M-PT-zh_CN")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Q1ngMang/LFM2.5-230M-PT-zh_CN")
model = AutoModelForCausalLM.from_pretrained("Q1ngMang/LFM2.5-230M-PT-zh_CN", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Q1ngMang/LFM2.5-230M-PT-zh_CN with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Q1ngMang/LFM2.5-230M-PT-zh_CN"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Q1ngMang/LFM2.5-230M-PT-zh_CN",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Q1ngMang/LFM2.5-230M-PT-zh_CN
How to use Q1ngMang/LFM2.5-230M-PT-zh_CN with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Q1ngMang/LFM2.5-230M-PT-zh_CN" \
--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": "Q1ngMang/LFM2.5-230M-PT-zh_CN",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Q1ngMang/LFM2.5-230M-PT-zh_CN" \
--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": "Q1ngMang/LFM2.5-230M-PT-zh_CN",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Q1ngMang/LFM2.5-230M-PT-zh_CN with Docker Model Runner:
docker model run hf.co/Q1ngMang/LFM2.5-230M-PT-zh_CN
基于 LiquidAI/LFM2.5-230M 进行 Pre-Training 的模型。
数据集 0xDing/wikipedia-cn-20230720-filtered
LFM 1.0 规定年收入小于1000万美元的公司的免费商用,收入大于1000万美元需要向LiquidAI购买商业许可证,而 CC BY-SA 3.0 规定可以商用,因此存在冲突。
该模型优先使用 CC BY-SA 3.0,但并不代表收入大于1000万美元不需要向LiquidAI购买商业许可证。
平台:LLaMA Factory
GPU:NVIDIA Tesla P100 SXM2
| 项 | 值 |
|---|---|
| 微调方法 | LoRA |
| 量化等级 | 4 |
| 量化方法 | bnb |
| 对话模板 | lfm2 |
| 训练阶段 | Pre-Training |
| 学习率 | 4.5e-4 |
| 训练轮数 | 1.0 |
| 计算类型 | pure_bf16 |
| 截断长度 | 1968 |
| 批处理大小 | 7 |
| 梯度累积 | 147 |
| 验证集比例 | 0.05 |
| 序列打包 | True |
| 额外参数 | {"optim": "paged_adamw_8bit"} |
| LoRA秩 | 16 |
| LoRA缩放系数 | 32 |
| 项 | 值 |
|---|---|
| 输入Token | 158,319,896 |
| 计算量 | 144,139,704GF |
| 训练损失 | 3.7876 |
| 训练耗时 | 12:35:07.48 |
| 每秒训练样本数 | 1.776 |
| 每秒训练步数 | 0.002 |
| 验证损失 | 3.6571 |
| 验证困惑度 | 38.7494 |
| 验证耗时 | 0:16:13.08 |
| 每秒验证样本数 | 4.409 |
| 每秒验证步数 | 0.63 |