a686d380/h-corpus-2023
Updated • 296 • 211
How to use shigureui/lightnovel_cpt with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="shigureui/lightnovel_cpt")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("shigureui/lightnovel_cpt")
model = AutoModelForCausalLM.from_pretrained("shigureui/lightnovel_cpt")
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 shigureui/lightnovel_cpt with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "shigureui/lightnovel_cpt"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "shigureui/lightnovel_cpt",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/shigureui/lightnovel_cpt
How to use shigureui/lightnovel_cpt with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "shigureui/lightnovel_cpt" \
--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": "shigureui/lightnovel_cpt",
"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 "shigureui/lightnovel_cpt" \
--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": "shigureui/lightnovel_cpt",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use shigureui/lightnovel_cpt with Docker Model Runner:
docker model run hf.co/shigureui/lightnovel_cpt
使用了Pai Megatron + 32K Sequence Length + FP8 + H100 集群训练
这个模型是CPT版本。使用了32K为目标切分的小说,所以可以输入非常长的内容,不过int8量化的话我不好说 (24G卡BF16 32K content windows, 杂鱼!)
轻小说数据来源包括 https://github.com/ixinzhi/lightnovel-2023 清洗脚本晚些可能公开
7B模型整体效果感觉马马虎虎,不过由于整体数据没有太被污染,效果明显。
已经训练好32B的模型(TP=8 FP8),32B版本逻辑性明显好。(搬到huggingface比较久)
如果模型载入有问题的话,请用qwen2.5原本的tokenizer、vocab等等覆盖一下,我只有权重的megatron转换出来的。
模型的翻译腔是预期效果?