BelleGroup/train_1M_CN
Viewer • Updated • 917k • 941 • 157
How to use yuanzhoulvpi/xiaoheizi-3b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="yuanzhoulvpi/xiaoheizi-3b") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("yuanzhoulvpi/xiaoheizi-3b")
model = AutoModelForCausalLM.from_pretrained("yuanzhoulvpi/xiaoheizi-3b")How to use yuanzhoulvpi/xiaoheizi-3b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "yuanzhoulvpi/xiaoheizi-3b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "yuanzhoulvpi/xiaoheizi-3b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/yuanzhoulvpi/xiaoheizi-3b
How to use yuanzhoulvpi/xiaoheizi-3b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "yuanzhoulvpi/xiaoheizi-3b" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "yuanzhoulvpi/xiaoheizi-3b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "yuanzhoulvpi/xiaoheizi-3b" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "yuanzhoulvpi/xiaoheizi-3b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use yuanzhoulvpi/xiaoheizi-3b with Docker Model Runner:
docker model run hf.co/yuanzhoulvpi/xiaoheizi-3b
xiaoheizi(小黑子),现在国内的大模型起的名字一个比一个厉害,那我们和别人做点不一样的,主打一个随意~3B的模型dolly_v2_3b模型,而dolly_v2_3b模型本质上就是gpt_neox模型BelleGroup/train_1M_CN数据做的训练git clone git@github.com:yuanzhoulvpi2017/zero_nlp.git
cd chinese_dolly_v2_3b
from transformers import GPTNeoXForCausalLM,AutoTokenizer
from dolly.generate import generate_response,load_model_tokenizer_for_generate
import torch
model, tokenizer = load_model_tokenizer_for_generate(pretrained_model_name_or_path="yuanzhoulvpi/xiaoheizi-3b")
for i in range(10):
print("*" * 100)
res = generate_response(instruction="列出三个在二十世纪被认为是最伟大的小说之一的书名,以及它们的作者。", model=model,tokenizer=tokenizer)
print(res)
torch.cuda.empty_cache()
# ****************************************************************************************************
# - 《致命招若众》 by 黄伟作为一部历史传说学者的作品,创作于 1898 年。
# - 《讲故事人生》 by 苏珊作为一部历史传说,近年的迈克尔·道尔莎尼的重装作品,创作于1999年。
# - 《金头银头》 by 洛克菲尔德·迪伊纳作为一部小说、小说之旅、花园小说家之一,创作于1958年。
trainer_dolly.py文件训练即可