Update README.md
Browse files
README.md
CHANGED
|
@@ -1,138 +1,55 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
-
license_link: https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct/blob/main/LICENSE
|
| 4 |
-
language:
|
| 5 |
-
- en
|
| 6 |
-
base_model:
|
| 7 |
-
- Qwen/Qwen2.5-Coder-7B
|
| 8 |
-
pipeline_tag: text-generation
|
| 9 |
-
library_name: transformers
|
| 10 |
tags:
|
| 11 |
-
- code
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
---
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
<a href="https://chat.qwenlm.ai/" target="_blank" style="margin: 2px;">
|
| 21 |
-
<img alt="Chat" src="https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5" style="display: inline-block; vertical-align: middle;"/>
|
| 22 |
-
</a>
|
| 23 |
-
|
| 24 |
-
## Introduction
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- Type: Causal Language Models
|
| 34 |
-
- Training Stage: Pretraining & Post-training
|
| 35 |
-
- Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
|
| 36 |
-
- Number of Parameters: 7.61B
|
| 37 |
-
- Number of Paramaters (Non-Embedding): 6.53B
|
| 38 |
-
- Number of Layers: 28
|
| 39 |
-
- Number of Attention Heads (GQA): 28 for Q and 4 for KV
|
| 40 |
-
- Context Length: Full 131,072 tokens
|
| 41 |
-
- Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
|
| 42 |
-
|
| 43 |
-
For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/), [GitHub](https://github.com/QwenLM/Qwen2.5-Coder), [Documentation](https://qwen.readthedocs.io/en/latest/), [Arxiv](https://arxiv.org/abs/2409.12186).
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
```
|
| 51 |
-
KeyError: 'qwen2'
|
| 52 |
-
```
|
| 53 |
|
| 54 |
-
##
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
```python
|
| 59 |
-
from
|
| 60 |
-
|
| 61 |
-
model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
|
| 62 |
-
|
| 63 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 64 |
-
model_name,
|
| 65 |
-
torch_dtype="auto",
|
| 66 |
-
device_map="auto"
|
| 67 |
-
)
|
| 68 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
messages = [
|
| 72 |
-
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
| 73 |
-
{"role": "user", "content": prompt}
|
| 74 |
-
]
|
| 75 |
-
text = tokenizer.apply_chat_template(
|
| 76 |
-
messages,
|
| 77 |
-
tokenize=False,
|
| 78 |
-
add_generation_prompt=True
|
| 79 |
-
)
|
| 80 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
)
|
| 86 |
-
generated_ids = [
|
| 87 |
-
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 88 |
-
]
|
| 89 |
|
| 90 |
-
|
| 91 |
-
```
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
The current `config.json` is set for context length up to 32,768 tokens.
|
| 96 |
-
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.
|
| 97 |
-
|
| 98 |
-
For supported frameworks, you could add the following to `config.json` to enable YaRN:
|
| 99 |
-
```json
|
| 100 |
-
{
|
| 101 |
-
...,
|
| 102 |
-
"rope_scaling": {
|
| 103 |
-
"factor": 4.0,
|
| 104 |
-
"original_max_position_embeddings": 32768,
|
| 105 |
-
"type": "yarn"
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
For deployment, we recommend using vLLM.
|
| 111 |
-
Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
|
| 112 |
-
Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
|
| 113 |
-
We advise adding the `rope_scaling` configuration only when processing long contexts is required.
|
| 114 |
-
|
| 115 |
-
## Evaluation & Performance
|
| 116 |
-
|
| 117 |
-
Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5-coder-family/).
|
| 118 |
-
|
| 119 |
-
For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
|
| 120 |
-
|
| 121 |
-
## Citation
|
| 122 |
-
|
| 123 |
-
If you find our work helpful, feel free to give us a cite.
|
| 124 |
-
|
| 125 |
-
```
|
| 126 |
-
@article{hui2024qwen2,
|
| 127 |
-
title={Qwen2. 5-Coder Technical Report},
|
| 128 |
-
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},
|
| 129 |
-
journal={arXiv preprint arXiv:2409.12186},
|
| 130 |
-
year={2024}
|
| 131 |
-
}
|
| 132 |
-
@article{qwen2,
|
| 133 |
-
title={Qwen2 Technical Report},
|
| 134 |
-
author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
|
| 135 |
-
journal={arXiv preprint arXiv:2407.10671},
|
| 136 |
-
year={2024}
|
| 137 |
-
}
|
| 138 |
```
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- code
|
| 6 |
+
- coding-agent
|
| 7 |
+
- instruction-tuned
|
| 8 |
+
- hermit-code
|
| 9 |
+
pipeline_tag: text-generation
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Hermit Code 7B
|
| 13 |
|
| 14 |
+
**Hermit Code** is the official coding model for the [Hermit AI Agent](https://github.com/Soloman2002/hermit-agent).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
## Model Details
|
| 17 |
|
| 18 |
+
| Property | Value |
|
| 19 |
+
|---|---|
|
| 20 |
+
| **Base Model** | [Qwen/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) |
|
| 21 |
+
| **Architecture** | Qwen2.5 (Dense Transformer) |
|
| 22 |
+
| **Parameters** | 7.6B |
|
| 23 |
+
| **Context Length** | 128K tokens |
|
| 24 |
+
| **License** | Apache 2.0 |
|
| 25 |
+
| **Format** | Safetensors |
|
| 26 |
|
| 27 |
+
## Capabilities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
- Python, JavaScript, TypeScript, Go, Rust, C++, Java code generation
|
| 30 |
+
- Code explanation and documentation
|
| 31 |
+
- Bug fixing and debugging
|
| 32 |
+
- Refactoring and optimization
|
| 33 |
+
- Multi-file project understanding
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
## Usage
|
| 36 |
|
| 37 |
+
### Via Hugging Face Inference API
|
| 38 |
|
| 39 |
```python
|
| 40 |
+
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
client = InferenceClient(token="hf_YOUR_TOKEN")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
response = client.text_generation(
|
| 45 |
+
model="Soloman2002/hermit-code-7b",
|
| 46 |
+
prompt="<|im_start|>user\nWrite a Python function to sort a list<|im_end>\n<|im_start>assistant\n",
|
| 47 |
+
max_new_tokens=512,
|
| 48 |
+
temperature=0.2
|
| 49 |
)
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
## Acknowledgments
|
|
|
|
| 52 |
|
| 53 |
+
Original model: [Qwen team](https://huggingface.co/Qwen)
|
| 54 |
+
Hermit AI Agent: Built by the Hermit team
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
```
|