Update README.md
Browse files
README.md
CHANGED
|
@@ -7,15 +7,82 @@ tags:
|
|
| 7 |
- qwen2
|
| 8 |
license: apache-2.0
|
| 9 |
language:
|
| 10 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 20 |
|
| 21 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 7 |
- qwen2
|
| 8 |
license: apache-2.0
|
| 9 |
language:
|
| 10 |
+
- zho
|
| 11 |
+
- eng
|
| 12 |
+
- fra
|
| 13 |
+
- spa
|
| 14 |
+
- por
|
| 15 |
+
- deu
|
| 16 |
+
- ita
|
| 17 |
+
- rus
|
| 18 |
+
- jpn
|
| 19 |
+
- kor
|
| 20 |
+
- vie
|
| 21 |
+
- tha
|
| 22 |
+
- ara
|
| 23 |
+
datasets:
|
| 24 |
+
- nvidia/OpenCodeReasoning
|
| 25 |
---
|
| 26 |
|
| 27 |
+
# Qwen2.5_Coder_14B_CodingModel
|
| 28 |
|
| 29 |
+
**Developer:** `kamranrafi`
|
| 30 |
+
**Base model:** `Qwen/Qwen2.5-Coder-14B-Instruct`
|
| 31 |
+
**Objective:** Codegeneration with explanations.
|
| 32 |
+
**License:** Apache-2.0
|
| 33 |
+
**Dataset:** [`nvidia/OpenCodeReasoning`](https://huggingface.co/datasets/nvidia/OpenCodeReasoning)
|
| 34 |
+
|
| 35 |
+
## Quick Inference
|
| 36 |
+
|
| 37 |
+
### Transformers (PyTorch)
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 41 |
+
import torch
|
| 42 |
+
|
| 43 |
+
model_id = "kamranrafi/Qwen2.5_Coder_14B_CodingModel"
|
| 44 |
+
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 46 |
+
model_id,
|
| 47 |
+
torch_dtype=torch.float16,
|
| 48 |
+
device_map="cuda:1"
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
def chat(user_msg, max_new_tokens=512, temperature=0.2, top_p=0.9):
|
| 52 |
+
msgs = [
|
| 53 |
+
{"role":"system","content": "You are Qwen2.5 Coder 14B Coding Model, a smart coding assistant.\n"},
|
| 54 |
+
{"role":"user","content": user_msg},
|
| 55 |
+
]
|
| 56 |
+
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
|
| 57 |
+
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 58 |
+
out = model.generate(
|
| 59 |
+
**inputs,
|
| 60 |
+
max_new_tokens=max_new_tokens,
|
| 61 |
+
temperature=temperature,
|
| 62 |
+
top_p=top_p,
|
| 63 |
+
do_sample=temperature > 0
|
| 64 |
+
)
|
| 65 |
+
text = tok.decode(out[0], skip_special_tokens=True)
|
| 66 |
+
# Optional: trim everything before the assistant turn
|
| 67 |
+
return text.split("<|im_start|>assistant")[-1].strip()
|
| 68 |
+
|
| 69 |
+
print(chat("Create a function to return sorted list."))
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## 🧾 Citation
|
| 73 |
+
|
| 74 |
+
If you use this model, please cite:
|
| 75 |
+
|
| 76 |
+
```
|
| 77 |
+
@misc{
|
| 78 |
+
title = {Qwen2.5_Coder_14B_CodingModel},
|
| 79 |
+
author = {Muhammad Kamran Rafi},
|
| 80 |
+
year = {2025},
|
| 81 |
+
howpublished = {\url{https://huggingface.co/kamranrafi/Qwen2.5_Coder_14B_CodingModel}},
|
| 82 |
+
note = {Fine-tuned with Unsloth on nvidia/OpenCodeReasoning}
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
|
| 86 |
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 87 |
|
| 88 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|