Text Generation
Transformers
Safetensors
English
Chinese
qwen2
chat
conversational
text-generation-inference
Instructions to use deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct") model = AutoModelForCausalLM.from_pretrained("deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct", 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 deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct
- SGLang
How to use deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct 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 "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct" \ --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": "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct", "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 "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct" \ --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": "deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct with Docker Model Runner:
docker model run hf.co/deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct
Update README.md
Browse files
README.md
CHANGED
|
@@ -61,20 +61,16 @@ Here provides a code snippet with `apply_chat_template` to show you how to load
|
|
| 61 |
```python
|
| 62 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 63 |
|
| 64 |
-
model_name =
|
| 65 |
-
|
| 66 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 67 |
-
model_name,
|
| 68 |
-
torch_dtype="auto",
|
| 69 |
-
device_map="auto"
|
| 70 |
-
)
|
| 71 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 72 |
|
| 73 |
-
prompt =
|
| 74 |
messages = [
|
| 75 |
-
{"role": "system", "content": "You are
|
| 76 |
{"role": "user", "content": prompt}
|
| 77 |
]
|
|
|
|
| 78 |
text = tokenizer.apply_chat_template(
|
| 79 |
messages,
|
| 80 |
tokenize=False,
|
|
@@ -91,6 +87,8 @@ generated_ids = [
|
|
| 91 |
]
|
| 92 |
|
| 93 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
|
|
|
|
| 94 |
```
|
| 95 |
|
| 96 |
|
|
|
|
| 61 |
```python
|
| 62 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 63 |
|
| 64 |
+
model_name = 'deeptoken/Qwen2.5-3B-RuoZhiBa-Instruct'
|
| 65 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype='auto', device_map='auto')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 67 |
|
| 68 |
+
prompt = '鸡柳是鸡的哪个部位?'
|
| 69 |
messages = [
|
| 70 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 71 |
{"role": "user", "content": prompt}
|
| 72 |
]
|
| 73 |
+
|
| 74 |
text = tokenizer.apply_chat_template(
|
| 75 |
messages,
|
| 76 |
tokenize=False,
|
|
|
|
| 87 |
]
|
| 88 |
|
| 89 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 90 |
+
|
| 91 |
+
print(response)
|
| 92 |
```
|
| 93 |
|
| 94 |
|