Text Generation
Transformers
Safetensors
Chinese
qwen2
poetry
lora
chinese
conversational
text-generation-inference
Instructions to use qiangge2026/merged_qwen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use qiangge2026/merged_qwen with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="qiangge2026/merged_qwen") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("qiangge2026/merged_qwen") model = AutoModelForCausalLM.from_pretrained("qiangge2026/merged_qwen", 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 qiangge2026/merged_qwen with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "qiangge2026/merged_qwen" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "qiangge2026/merged_qwen", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/qiangge2026/merged_qwen
- SGLang
How to use qiangge2026/merged_qwen 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 "qiangge2026/merged_qwen" \ --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": "qiangge2026/merged_qwen", "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 "qiangge2026/merged_qwen" \ --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": "qiangge2026/merged_qwen", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use qiangge2026/merged_qwen with Docker Model Runner:
docker model run hf.co/qiangge2026/merged_qwen
Qwen2-0.5B 古诗词生成微调模型
这是一个基于 Qwen/Qwen2-0.5B 进行 LoRA 微调并合并后的古诗词生成模型。
模型介绍
本项目通过 LoRA (Low-Rank Adaptation) 技术,在少量古诗词数据集上对 Qwen2-0.5B 进行了微调,使其能够根据用户输入的主题(如“春天”、“夏天”等)生成对应风格的古诗词。
训练数据
- 数据集:自定义古诗词数据集(包含春夏秋冬等不同主题)。
- 训练轮次:50 Epochs。
- 最终训练损失:约 7.68。
使用方法
你可以使用 transformers 库直接加载此模型进行推理:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "qiangge2026/merged_qwen"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
prompt = "用户:写一首关于春天的诗\n助手:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Downloads last month
- 283
Model tree for qiangge2026/merged_qwen
Base model
Qwen/Qwen2-0.5B