File size: 5,069 Bytes
ea37813 385c33a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | ---
library_name: keras-hub
pipeline_tag: text-generation
---
### Model Overview
# Model Summary
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:
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.
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.
**Long-context Support** up to 128K tokens.
For more details, please refer to Qwen [Blog](https://qwenlm.github.io/blog/qwen2.5/), [GitHub](https://github.com/keras-team/keras-hub/tree/master/keras_hub/src/models/qwen), and [Documentation](https://qwen.readthedocs.io/en/latest/).
Weights are released under the [Apache 2 License](https://github.com/keras-team/keras-hub/blob/master/LICENSE) . Keras model code is released under the [Apache 2 License](https://github.com/keras-team/keras-hub/blob/master/LICENSE).
## Links
* [Qwen 2.5 Coder Quickstart Notebook](https://www.kaggle.com/code/laxmareddypatlolla/qwen2-5-coder-quickstart-notebook)
* [Qwen 2.5 Coder API Documentation](https://keras.io/keras_hub/api/models/qwen/)
* [Qwen 2.5 Coder Model Card](https://qwenlm.github.io/blog/qwen2.5/)
* [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/)
* [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/)
## Installation
Keras and KerasHub can be installed with:
```
pip install -U -q keras-hub
pip install -U -q keras
```
Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the [Keras Getting Started](https://keras.io/getting_started/) page.
## Presets
The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
| Preset name | Parameters | Description |
|---------------------------------------|------------|--------------------------------------------------------------------------------------------------------------|
| qwen2.5_coder_0.5b | 0.5B | 24-layer with 0.5 billion parameters. Code-Specific large language models base on the strong Qwen2.5 |
| qwen2.5_coder_instruct_0.5b | 0.5B | 24-layer with 0.5 billion parameters. Code-Specific large language models base on the strong Qwen2.5. |
| qwen2.5_coder_1.5b | 1.5B | 28-layer with 1.5 billion parameters. Code-Specific large language models base on the strong Qwen2.5. |
| qwen2.5_coder_instruct_1.5b | 1.5B | 28-layer with 1.5 billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_3b | 3B | 36-layer with 3 billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_instruct_3b | 3B | 36-layer with 3 billion parameters. Code-Specific large language models base on the strong Qwen2.5. |
| qwen2.5_coder_7b | 7B | 28-layer with 7B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_instruct_7b | 7B | 28-layer with 7B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_14b | 14B | 48-layer with 14B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_instruct_14b | 14B | 48-layer with 14B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_32b | 32B | 64-layer with 32B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
| qwen2.5_coder_instruct_32b | 32B | 64-layer with 32B billion parameters. Code-Specific large language models base on the strong Qwen2.5.|
## Example Usage
```Python
import keras
import keras_hub
import numpy as np
# Use generate() to do code generation.
qwen_lm = keras_hub.models.QwenCausalLM.from_preset("qwen2.5_coder_7b")
qwen_lm.generate(" write a quick sort algorithm in python.", max_length=512)
```
## Example Usage with Hugging Face URI
```Python
import keras
import keras_hub
import numpy as np
# Use generate() to do code generation.
qwen_lm = keras_hub.models.QwenCausalLM.from_preset("hf://keras/qwen2.5_coder_7b")
qwen_lm.generate(" write a quick sort algorithm in python.", max_length=512)
```
|