Instructions to use tiny-random/qwen2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/qwen2.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/qwen2.5") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/qwen2.5") model = AutoModelForCausalLM.from_pretrained("tiny-random/qwen2.5", 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 tiny-random/qwen2.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/qwen2.5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/qwen2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/qwen2.5
- SGLang
How to use tiny-random/qwen2.5 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 "tiny-random/qwen2.5" \ --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": "tiny-random/qwen2.5", "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 "tiny-random/qwen2.5" \ --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": "tiny-random/qwen2.5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/qwen2.5 with Docker Model Runner:
docker model run hf.co/tiny-random/qwen2.5
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -112,6 +112,40 @@ model.save_pretrained(save_folder)
|
|
| 112 |
|
| 113 |
</details>
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
### Test environment:
|
| 117 |
|
|
|
|
| 112 |
|
| 113 |
</details>
|
| 114 |
|
| 115 |
+
### Printing the model:
|
| 116 |
+
|
| 117 |
+
<details><summary>Click to expand</summary>
|
| 118 |
+
|
| 119 |
+
```text
|
| 120 |
+
Qwen2ForCausalLM(
|
| 121 |
+
(model): Qwen2Model(
|
| 122 |
+
(embed_tokens): Embedding(152064, 8)
|
| 123 |
+
(layers): ModuleList(
|
| 124 |
+
(0-3): 4 x Qwen2DecoderLayer(
|
| 125 |
+
(self_attn): Qwen2Attention(
|
| 126 |
+
(q_proj): Linear(in_features=8, out_features=256, bias=True)
|
| 127 |
+
(k_proj): Linear(in_features=8, out_features=128, bias=True)
|
| 128 |
+
(v_proj): Linear(in_features=8, out_features=128, bias=True)
|
| 129 |
+
(o_proj): Linear(in_features=256, out_features=8, bias=False)
|
| 130 |
+
)
|
| 131 |
+
(mlp): Qwen2MLP(
|
| 132 |
+
(gate_proj): Linear(in_features=8, out_features=32, bias=False)
|
| 133 |
+
(up_proj): Linear(in_features=8, out_features=32, bias=False)
|
| 134 |
+
(down_proj): Linear(in_features=32, out_features=8, bias=False)
|
| 135 |
+
(act_fn): SiLUActivation()
|
| 136 |
+
)
|
| 137 |
+
(input_layernorm): Qwen2RMSNorm((8,), eps=1e-06)
|
| 138 |
+
(post_attention_layernorm): Qwen2RMSNorm((8,), eps=1e-06)
|
| 139 |
+
)
|
| 140 |
+
)
|
| 141 |
+
(norm): Qwen2RMSNorm((8,), eps=1e-06)
|
| 142 |
+
(rotary_emb): Qwen2RotaryEmbedding()
|
| 143 |
+
)
|
| 144 |
+
(lm_head): Linear(in_features=8, out_features=152064, bias=False)
|
| 145 |
+
)
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
</details>
|
| 149 |
|
| 150 |
### Test environment:
|
| 151 |
|