Text Generation
Transformers
Safetensors
English
qwen2
code
qwen
qwen-coder
codeqwen
conversational
text-generation-inference
Instructions to use Qwen/Qwen2.5-Coder-1.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2.5-Coder-1.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen2.5-Coder-1.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-1.5B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-1.5B") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Qwen/Qwen2.5-Coder-1.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen2.5-Coder-1.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": "Qwen/Qwen2.5-Coder-1.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Qwen/Qwen2.5-Coder-1.5B
- SGLang
How to use Qwen/Qwen2.5-Coder-1.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 "Qwen/Qwen2.5-Coder-1.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": "Qwen/Qwen2.5-Coder-1.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 "Qwen/Qwen2.5-Coder-1.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": "Qwen/Qwen2.5-Coder-1.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Qwen/Qwen2.5-Coder-1.5B with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2.5-Coder-1.5B
feihu.hf commited on
Commit ·
6df6cbb
1
Parent(s): acb224f
update README.md
Browse files- README.md +5 -27
- config.json +1 -1
README.md
CHANGED
|
@@ -18,7 +18,7 @@ tags:
|
|
| 18 |
|
| 19 |
## Introduction
|
| 20 |
|
| 21 |
-
Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers.
|
| 22 |
|
| 23 |
- Significantly improvements in **code generation**, **code reasoning** and **code fixing**. Base on the strong Qwen2.5, we scale up the training tokens into 5.5 trillion including source code, text-code grounding, Synthetic data, etc. Qwen2.5-Coder-32B has become the current state-of-the-art open-source codeLLM, with its coding abilities matching those of GPT-4o.
|
| 24 |
- A more comprehensive foundation for real-world applications such as **Code Agents**. Not only enhancing coding capabilities but also maintaining its strengths in mathematics and general competencies.
|
|
@@ -32,7 +32,6 @@ Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (
|
|
| 32 |
- Number of Layers: 28
|
| 33 |
- Number of Attention Heads (GQA): 12 for Q and 2 for KV
|
| 34 |
- Context Length: Full 32,768 tokens
|
| 35 |
-
- Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
|
| 36 |
|
| 37 |
**We do not recommend using base language models for conversations.** Instead, you can apply post-training, e.g., SFT, RLHF, continued pretraining, etc., or fill in the middle tasks on this model.
|
| 38 |
|
|
@@ -47,27 +46,6 @@ With `transformers<4.37.0`, you will encounter the following error:
|
|
| 47 |
KeyError: 'qwen2'
|
| 48 |
```
|
| 49 |
|
| 50 |
-
### Processing Long Texts
|
| 51 |
-
|
| 52 |
-
The current `config.json` is set for context length up to 32,768 tokens.
|
| 53 |
-
To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
|
| 54 |
-
|
| 55 |
-
For supported frameworks, you could add the following to `config.json` to enable YaRN:
|
| 56 |
-
```json
|
| 57 |
-
{
|
| 58 |
-
...,
|
| 59 |
-
"rope_scaling": {
|
| 60 |
-
"factor": 4.0,
|
| 61 |
-
"original_max_position_embeddings": 32768,
|
| 62 |
-
"type": "yarn"
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
For deployment, we recommend using vLLM.
|
| 68 |
-
Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
|
| 69 |
-
Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
|
| 70 |
-
We advise adding the `rope_scaling` configuration only when processing long contexts is required.
|
| 71 |
|
| 72 |
## Evaluation & Performance
|
| 73 |
|
|
@@ -81,10 +59,10 @@ If you find our work helpful, feel free to give us a cite.
|
|
| 81 |
|
| 82 |
```
|
| 83 |
@article{hui2024qwen2,
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
}
|
| 89 |
@article{qwen2,
|
| 90 |
title={Qwen2 Technical Report},
|
|
|
|
| 18 |
|
| 19 |
## Introduction
|
| 20 |
|
| 21 |
+
Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:
|
| 22 |
|
| 23 |
- Significantly improvements in **code generation**, **code reasoning** and **code fixing**. Base on the strong Qwen2.5, we scale up the training tokens into 5.5 trillion including source code, text-code grounding, Synthetic data, etc. Qwen2.5-Coder-32B has become the current state-of-the-art open-source codeLLM, with its coding abilities matching those of GPT-4o.
|
| 24 |
- A more comprehensive foundation for real-world applications such as **Code Agents**. Not only enhancing coding capabilities but also maintaining its strengths in mathematics and general competencies.
|
|
|
|
| 32 |
- Number of Layers: 28
|
| 33 |
- Number of Attention Heads (GQA): 12 for Q and 2 for KV
|
| 34 |
- Context Length: Full 32,768 tokens
|
|
|
|
| 35 |
|
| 36 |
**We do not recommend using base language models for conversations.** Instead, you can apply post-training, e.g., SFT, RLHF, continued pretraining, etc., or fill in the middle tasks on this model.
|
| 37 |
|
|
|
|
| 46 |
KeyError: 'qwen2'
|
| 47 |
```
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
## Evaluation & Performance
|
| 51 |
|
|
|
|
| 59 |
|
| 60 |
```
|
| 61 |
@article{hui2024qwen2,
|
| 62 |
+
title={Qwen2. 5-Coder Technical Report},
|
| 63 |
+
author={Hui, Binyuan and Yang, Jian and Cui, Zeyu and Yang, Jiaxi and Liu, Dayiheng and Zhang, Lei and Liu, Tianyu and Zhang, Jiajun and Yu, Bowen and Dang, Kai and others},
|
| 64 |
+
journal={arXiv preprint arXiv:2409.12186},
|
| 65 |
+
year={2024}
|
| 66 |
}
|
| 67 |
@article{qwen2,
|
| 68 |
title={Qwen2 Technical Report},
|
config.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
"num_key_value_heads": 2,
|
| 18 |
"rms_norm_eps": 1e-06,
|
| 19 |
"rope_theta": 1000000.0,
|
| 20 |
-
"sliding_window":
|
| 21 |
"tie_word_embeddings": true,
|
| 22 |
"torch_dtype": "bfloat16",
|
| 23 |
"transformers_version": "4.44.0",
|
|
|
|
| 17 |
"num_key_value_heads": 2,
|
| 18 |
"rms_norm_eps": 1e-06,
|
| 19 |
"rope_theta": 1000000.0,
|
| 20 |
+
"sliding_window": 32768,
|
| 21 |
"tie_word_embeddings": true,
|
| 22 |
"torch_dtype": "bfloat16",
|
| 23 |
"transformers_version": "4.44.0",
|