Update README.md
Browse files
README.md
CHANGED
|
@@ -2,27 +2,88 @@
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
license: apache-2.0
|
| 5 |
-
license_name: apache-2.0
|
| 6 |
-
license_link: https://www.apache.org/licenses/LICENSE-2.0
|
| 7 |
library_name: transformers
|
| 8 |
tags:
|
| 9 |
- code-generation
|
| 10 |
- python
|
| 11 |
-
- qwen
|
| 12 |
-
- fine-tuned
|
| 13 |
-
- lora
|
| 14 |
- programming
|
|
|
|
| 15 |
pipeline_tag: text-generation
|
| 16 |
-
datasets:
|
| 17 |
-
- CodeAlpaca-20k
|
| 18 |
-
- mbpp
|
| 19 |
-
- HumanEval
|
| 20 |
-
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 21 |
widget:
|
| 22 |
-
- text:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
license: apache-2.0
|
|
|
|
|
|
|
| 5 |
library_name: transformers
|
| 6 |
tags:
|
| 7 |
- code-generation
|
| 8 |
- python
|
|
|
|
|
|
|
|
|
|
| 9 |
- programming
|
| 10 |
+
- fine-tuned
|
| 11 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
widget:
|
| 13 |
+
- text: |-
|
| 14 |
+
### Instruction:
|
| 15 |
+
Write a Python function to reverse a string
|
| 16 |
+
|
| 17 |
+
### Input:
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
### Response:
|
| 21 |
+
example_title: Reverse String
|
| 22 |
+
- text: |-
|
| 23 |
+
### Instruction:
|
| 24 |
+
how are you?
|
| 25 |
+
|
| 26 |
+
### Input:
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
### Response:
|
| 30 |
+
example_title: Non-Code Request
|
| 31 |
+
- text: |-
|
| 32 |
+
### Instruction:
|
| 33 |
+
Implement quicksort algorithm in Python
|
| 34 |
+
|
| 35 |
+
### Input:
|
| 36 |
+
Use recursion and list comprehensions
|
| 37 |
+
|
| 38 |
+
### Response:
|
| 39 |
+
example_title: Quicksort Algorithm
|
| 40 |
+
base_model: Mercy-62/python-code-only-Qwen-lora
|
| 41 |
+
datasets:
|
| 42 |
+
- sahil2801/CodeAlpaca-20k
|
| 43 |
+
- google-research-datasets/mbpp
|
| 44 |
+
- openai/openai_humaneval
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
# 🐍 Python Code-Only Qwen
|
| 48 |
+
|
| 49 |
+
**A fine-tuned model that generates ONLY executable Python code, with no explanations or conversations.**
|
| 50 |
+
|
| 51 |
+
## 🚀 Quick Inference Example
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 55 |
+
|
| 56 |
+
# Load model
|
| 57 |
+
model = AutoModelForCausalLM.from_pretrained("Mercy-62/python-code-only-Qwen-lora")
|
| 58 |
+
tokenizer = AutoTokenizer.from_pretrained("Mercy-62/python-code-only-Qwen-lora")
|
| 59 |
+
|
| 60 |
+
# Use exact same prompt format from training
|
| 61 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 62 |
+
|
| 63 |
+
### Instruction:
|
| 64 |
+
{}
|
| 65 |
+
|
| 66 |
+
### Input:
|
| 67 |
+
{}
|
| 68 |
+
|
| 69 |
+
### Response:
|
| 70 |
+
{}"""
|
| 71 |
+
|
| 72 |
+
# Enable faster inference (if using Unsloth)
|
| 73 |
+
# FastLanguageModel.for_inference(model)
|
| 74 |
+
|
| 75 |
+
# Test 1: Simple code generation
|
| 76 |
+
inputs = tokenizer(
|
| 77 |
+
[
|
| 78 |
+
alpaca_prompt.format(
|
| 79 |
+
"Write a Python function to reverse a string", # instruction
|
| 80 |
+
"", # input (leave empty if no context)
|
| 81 |
+
"", # output - leave blank for generation
|
| 82 |
+
)
|
| 83 |
+
],
|
| 84 |
+
return_tensors="pt"
|
| 85 |
+
).to("cuda")
|
| 86 |
+
|
| 87 |
+
outputs = model.generate(**inputs, max_new_tokens=128, use_cache=True)
|
| 88 |
+
print("Test 1 - Reverse string function:")
|
| 89 |
+
print(tokenizer.batch_decode(outputs)[0])
|