Text Generation
Transformers
Safetensors
Chinese
qwen2
chinese-novel
chinese-fantasy
qwen
lora-finetuned
conversational
text-generation-inference
Instructions to use skyjilygao/JianLai-qwen0.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use skyjilygao/JianLai-qwen0.5b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="skyjilygao/JianLai-qwen0.5b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("skyjilygao/JianLai-qwen0.5b") model = AutoModelForCausalLM.from_pretrained("skyjilygao/JianLai-qwen0.5b", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use skyjilygao/JianLai-qwen0.5b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "skyjilygao/JianLai-qwen0.5b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "skyjilygao/JianLai-qwen0.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/skyjilygao/JianLai-qwen0.5b
- SGLang
How to use skyjilygao/JianLai-qwen0.5b 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 "skyjilygao/JianLai-qwen0.5b" \ --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": "skyjilygao/JianLai-qwen0.5b", "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 "skyjilygao/JianLai-qwen0.5b" \ --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": "skyjilygao/JianLai-qwen0.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use skyjilygao/JianLai-qwen0.5b with Docker Model Runner:
docker model run hf.co/skyjilygao/JianLai-qwen0.5b
JianLai-Qwen0.5B
🏮 剑来小说专业问答模型
📖 模型介绍
这是一个专门为小说《剑来》进行微调的中文语言模型,基于Qwen2.5-0.5B-Instruct模型使用LoRA方法训练而成。
✨ 主要特性
- 剑来知识专家: 深入理解剑来小说的人物、情节、世界观
- 专业问答: 能够回答关于剑来小说的各类问题
- 情节分析: 可以分析小说片段的意义和重要信息
- 人物关系: 了解复杂的人物关系网络
- 文化底蕴: 理解小说中的传统文化内涵
🎯 适用场景
- 剑来小说内容与情节问答
- 人物性格与关系分析
- 小说世界观理解
- 文学分析与讨论
🔧 使用方法
环境要求
pip install transformers peft torch
Python代码示例
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# 加载模型
model_name = "your-huggingface-username/JianLai-Qwen0.5B" # 修改为实际名称
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
# 提问
question = "剑来的主人公是谁?"
prompt = f"### 用户:{question}\n### 助手:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=200,
do_sample=True,
temperature=0.7,
top_p=0.9
)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
answer = result.split("### 助手:")[-1].strip()
print(f"回答: {answer}")
🤗 HuggingFace推理
您也可以直接使用HuggingFace上的在线推理API:
from transformers import pipeline
gen = pipeline("text-generation", model="your-huggingface-username/JianLai-Qwen0.5B")
result = gen("### 用户:陈平安来自哪里?\n### 助手:")
🎓 训练详情
基础模型
- 模型: Qwen/Qwen2.5-0.5B-Instruct
- 训练方法: LoRA (Low-Rank Adaptation)
- 参数数量: 约4.4M个可训练参数
训练数据
- 数据规模: 61,514个问答对
- 数据来源: 《剑来》小说内容分析
- 问题类型: 情节理解、人物分析、场景描述等
训练配置
- 训练步数: 1000步
- 学习率: 2e-4
- LoRA配置: r=8, alpha=16, dropout=0.05
- 序列长度: 512 tokens
⚠️ 限制与注意事项
- 知识边界: 仅针对剑来小说内容,不了解其他虚构作品
- 事实准确性: 基于训练数据提供信息,建议与原著核实重要细节
- 创作风格: 主要用于情节问答,不支持直接创作
- 内存需求: 建议使用GPU进行推理,CPU可能较慢
📝 示例问答
问: 剑来的主人公是谁?
答: 剑来小说的主人公是陈平安,来自骊珠洞天的一个小镇,是故事的核心人物...
问: 剑气长城是什么地方?
答: 剑气长城是剑来世界中的超级宗派之一,是人族抵御妖族的重要防线...
🤝 贡献与反馈
如果您在使用过程中有任何问题或建议,欢迎:
- 在HuggingFace社区讨论
- 提交Issue或PR
- 提供使用反馈
📜 许可
本模型基于Apache 2.0许可证发布,与基础模型Qwen保持一致。
🏮 用AI理解经典,让文化焕发新生 🏮
- Downloads last month
- 7