|
|
--- |
|
|
base_model: unsloth/qwen2.5-coder-14b-instruct-bnb-4bit |
|
|
tags: |
|
|
- text-generation-inference |
|
|
- transformers |
|
|
- unsloth |
|
|
- qwen2 |
|
|
license: apache-2.0 |
|
|
language: |
|
|
- zho |
|
|
- eng |
|
|
- fra |
|
|
- spa |
|
|
- por |
|
|
- deu |
|
|
- ita |
|
|
- rus |
|
|
- jpn |
|
|
- kor |
|
|
- vie |
|
|
- tha |
|
|
- ara |
|
|
datasets: |
|
|
- nvidia/OpenCodeReasoning |
|
|
--- |
|
|
|
|
|
# Qwen2.5_Coder_14B_CodingModel |
|
|
|
|
|
**Developer:** `kamranrafi` |
|
|
**Base model:** `Qwen/Qwen2.5-Coder-14B-Instruct` |
|
|
**Objective:** Codegeneration with explanations. |
|
|
**License:** Apache-2.0 |
|
|
**Dataset:** [`nvidia/OpenCodeReasoning`](https://huggingface.co/datasets/nvidia/OpenCodeReasoning) |
|
|
|
|
|
## Quick Inference |
|
|
|
|
|
### Transformers (PyTorch) |
|
|
|
|
|
```python |
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
import torch |
|
|
|
|
|
model_id = "kamranrafi/Qwen2.5_Coder_14B_CodingModel" |
|
|
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True) |
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
|
model_id, |
|
|
torch_dtype=torch.float16, |
|
|
device_map="cuda:1" |
|
|
) |
|
|
|
|
|
def chat(user_msg, max_new_tokens=512, temperature=0.2, top_p=0.9): |
|
|
msgs = [ |
|
|
{"role":"system","content": "You are Qwen2.5 Coder 14B Coding Model, a smart coding assistant.\n"}, |
|
|
{"role":"user","content": user_msg}, |
|
|
] |
|
|
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True) |
|
|
inputs = tok(prompt, return_tensors="pt").to(model.device) |
|
|
out = model.generate( |
|
|
**inputs, |
|
|
max_new_tokens=max_new_tokens, |
|
|
temperature=temperature, |
|
|
top_p=top_p, |
|
|
do_sample=temperature > 0 |
|
|
) |
|
|
text = tok.decode(out[0], skip_special_tokens=True) |
|
|
# Optional: trim everything before the assistant turn |
|
|
return text.split("<|im_start|>assistant")[-1].strip() |
|
|
|
|
|
print(chat("Create a function to return sorted list.")) |
|
|
``` |
|
|
|
|
|
## 🧾 Citation |
|
|
|
|
|
If you use this model, please cite: |
|
|
|
|
|
``` |
|
|
@misc{ |
|
|
title = {Qwen2.5_Coder_14B_CodingModel}, |
|
|
author = {Muhammad Kamran Rafi}, |
|
|
year = {2025}, |
|
|
howpublished = {\url{https://huggingface.co/kamranrafi/Qwen2.5_Coder_14B_CodingModel}}, |
|
|
note = {Fine-tuned with Unsloth on nvidia/OpenCodeReasoning} |
|
|
} |
|
|
``` |
|
|
|
|
|
This qwen2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library. |
|
|
|
|
|
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth) |