Text Generation
Transformers
Safetensors
English
qwen2.5-coder
code-generation
code-modernization
python
fine-tuned
merged-model
conversational
Instructions to use Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter
- SGLang
How to use Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter with Docker Model Runner:
docker model run hf.co/Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,447 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model Card for
|
| 7 |
-
|
| 8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
- **
|
| 21 |
-
- **
|
| 22 |
-
- **
|
| 23 |
-
- **
|
| 24 |
-
- **
|
| 25 |
-
- **
|
| 26 |
-
- **
|
| 27 |
|
| 28 |
-
### Model Sources
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
## Bias, Risks, and Limitations
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
### Recommendations
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
|
| 95 |
-
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
### Testing Data, Factors & Metrics
|
| 108 |
|
| 109 |
#### Testing Data
|
| 110 |
|
| 111 |
-
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
#### Factors
|
| 116 |
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
#### Metrics
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
### Results
|
| 128 |
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
#### Summary
|
| 132 |
|
|
|
|
| 133 |
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
-
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
### Model Architecture and Objective
|
| 156 |
|
| 157 |
-
|
| 158 |
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
#### Hardware
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
#### Software
|
| 168 |
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
|
|
|
|
| 172 |
|
| 173 |
-
|
|
|
|
| 174 |
|
| 175 |
-
**
|
|
|
|
| 176 |
|
| 177 |
-
|
|
|
|
| 178 |
|
| 179 |
-
**
|
|
|
|
| 180 |
|
| 181 |
-
|
|
|
|
| 182 |
|
| 183 |
-
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
## Model Card Authors
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- qwen2.5-coder
|
| 5 |
+
- code-generation
|
| 6 |
+
- code-modernization
|
| 7 |
+
- python
|
| 8 |
+
- qlora
|
| 9 |
+
- lora
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Model Card for Qwen2.5-Coder-1.5B Python 3.14 QLoRA Adapter
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
## Model Details
|
| 15 |
|
| 16 |
### Model Description
|
| 17 |
|
| 18 |
+
This model is a LoRA adapter fine-tuned on top of `Qwen/Qwen2.5-Coder-1.5B-Instruct` for Python code modernization, with a focus on updating Python code toward Python 3.14-compatible syntax and practices.
|
| 19 |
|
| 20 |
+
The adapter was trained using QLoRA with 4-bit NF4 quantization of the frozen base model and LoRA-based parameter-efficient fine-tuning.
|
| 21 |
|
| 22 |
+
- **Base model:** `Qwen/Qwen2.5-Coder-1.5B-Instruct`
|
| 23 |
+
- **Model type:** LoRA / QLoRA adapter
|
| 24 |
+
- **Task:** Python code modernization
|
| 25 |
+
- **Primary target:** Python 3.14 modernization
|
| 26 |
+
- **Quantization:** 4-bit NF4
|
| 27 |
+
- **Nested quantization:** Enabled
|
| 28 |
+
- **Compute dtype:** FP16
|
| 29 |
|
| 30 |
+
### Model Sources
|
| 31 |
|
| 32 |
+
- **Base model:** `Qwen/Qwen2.5-Coder-1.5B-Instruct`
|
| 33 |
+
- **Adapter repository:** `Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter`
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Uses
|
| 36 |
|
|
|
|
|
|
|
| 37 |
### Direct Use
|
| 38 |
|
| 39 |
+
This adapter is intended to be used with the base Qwen2.5-Coder-1.5B-Instruct model to modernize Python source code toward Python 3.14.
|
| 40 |
|
| 41 |
+
Potential applications include:
|
| 42 |
|
| 43 |
+
- Modernizing legacy Python syntax
|
| 44 |
+
- Updating Python code to newer language features
|
| 45 |
+
- Refactoring older Python implementations
|
| 46 |
+
- Assisting developers with Python version migration
|
| 47 |
+
- Generating modernized Python code from older implementations
|
| 48 |
|
| 49 |
+
### Downstream Use
|
| 50 |
|
| 51 |
+
The adapter can be integrated into developer tools, code migration pipelines, educational tools, and automated code modernization workflows.
|
| 52 |
+
|
| 53 |
+
It can also be merged with the base model to create a standalone fine-tuned model.
|
| 54 |
|
| 55 |
### Out-of-Scope Use
|
| 56 |
|
| 57 |
+
This model is not intended to:
|
| 58 |
+
|
| 59 |
+
- Guarantee that generated code is fully compatible with every Python 3.14 environment
|
| 60 |
+
- Replace automated testing or human code review
|
| 61 |
+
- Perform security-critical code migration without validation
|
| 62 |
+
- Generate production-ready software without testing
|
| 63 |
+
- Serve as a general-purpose replacement for the original Qwen2.5-Coder model
|
| 64 |
|
| 65 |
+
Generated code should always be validated, tested, and reviewed before production use.
|
| 66 |
|
| 67 |
## Bias, Risks, and Limitations
|
| 68 |
|
| 69 |
+
The model inherits limitations from the underlying Qwen2.5-Coder model and from the fine-tuning dataset.
|
| 70 |
+
|
| 71 |
+
The model may:
|
| 72 |
|
| 73 |
+
- Produce syntactically incorrect code in some situations
|
| 74 |
+
- Introduce behavioral changes during modernization
|
| 75 |
+
- Apply an inappropriate modernization depending on the context
|
| 76 |
+
- Fail to preserve edge-case behavior
|
| 77 |
+
- Generate code that appears valid but requires additional testing
|
| 78 |
+
- Reflect biases or limitations present in the base model and training data
|
| 79 |
|
| 80 |
### Recommendations
|
| 81 |
|
| 82 |
+
Generated code should be:
|
| 83 |
|
| 84 |
+
1. Reviewed by a developer.
|
| 85 |
+
2. Parsed or compiled using the target Python version.
|
| 86 |
+
3. Tested against the original implementation's expected behavior.
|
| 87 |
+
4. Validated with appropriate unit and integration tests.
|
| 88 |
|
| 89 |
## How to Get Started with the Model
|
| 90 |
|
| 91 |
+
The adapter can be loaded together with the base model using PEFT and BitsAndBytes.
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
import torch
|
| 95 |
+
|
| 96 |
+
from transformers import (
|
| 97 |
+
AutoModelForCausalLM,
|
| 98 |
+
AutoTokenizer,
|
| 99 |
+
BitsAndBytesConfig,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
from peft import PeftModel
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
BASE_MODEL = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
|
| 106 |
+
ADAPTER_MODEL = "Krishnasri2027/qwen25-coder-1.5b-python3147-nf4-adapter"
|
| 107 |
+
|
| 108 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 109 |
+
ADAPTER_MODEL,
|
| 110 |
+
trust_remote_code=True,
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
bnb_config = BitsAndBytesConfig(
|
| 114 |
+
load_in_4bit=True,
|
| 115 |
+
bnb_4bit_quant_type="nf4",
|
| 116 |
+
bnb_4bit_use_double_quant=True,
|
| 117 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 121 |
+
BASE_MODEL,
|
| 122 |
+
quantization_config=bnb_config,
|
| 123 |
+
torch_dtype=torch.float16,
|
| 124 |
+
device_map="auto",
|
| 125 |
+
trust_remote_code=True,
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
model = PeftModel.from_pretrained(
|
| 129 |
+
base_model,
|
| 130 |
+
ADAPTER_MODEL,
|
| 131 |
+
is_trainable=False,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
model.eval()
|
| 135 |
+
|
| 136 |
+
messages = [
|
| 137 |
+
{
|
| 138 |
+
"role": "user",
|
| 139 |
+
"content": "Modernize the following Python code for Python 3.14:\n\n<your Python code here>",
|
| 140 |
+
}
|
| 141 |
+
]
|
| 142 |
+
|
| 143 |
+
inputs = tokenizer.apply_chat_template(
|
| 144 |
+
messages,
|
| 145 |
+
tokenize=True,
|
| 146 |
+
add_generation_prompt=True,
|
| 147 |
+
return_tensors="pt",
|
| 148 |
+
).to(model.device)
|
| 149 |
+
|
| 150 |
+
with torch.no_grad():
|
| 151 |
+
outputs = model.generate(
|
| 152 |
+
inputs,
|
| 153 |
+
max_new_tokens=512,
|
| 154 |
+
temperature=0.2,
|
| 155 |
+
do_sample=False,
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
response = tokenizer.decode(
|
| 159 |
+
outputs[0][inputs.shape[-1]:],
|
| 160 |
+
skip_special_tokens=True,
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
print(response)
|
| 164 |
+
```
|
| 165 |
|
| 166 |
## Training Details
|
| 167 |
|
| 168 |
### Training Data
|
| 169 |
|
| 170 |
+
The model was fine-tuned using a chat-formatted training dataset designed for Python code modernization.
|
| 171 |
|
| 172 |
+
The training examples were tokenized using the Qwen2.5-Coder tokenizer and its chat template.
|
| 173 |
|
| 174 |
+
The configured sequence length was **256 tokens**.
|
| 175 |
|
| 176 |
+
Token-length analysis of the training examples produced:
|
| 177 |
|
| 178 |
+
| Statistic | Tokens |
|
| 179 |
+
|---|---:|
|
| 180 |
+
| Minimum | 115 |
|
| 181 |
+
| Maximum | 197 |
|
| 182 |
+
| Mean | 150.792 |
|
| 183 |
+
| Median | 147 |
|
| 184 |
+
| 95th percentile | 187 |
|
| 185 |
+
| 99th percentile | 197 |
|
| 186 |
+
| Configured sequence length | 256 |
|
| 187 |
|
| 188 |
+
The maximum observed sequence length of 197 tokens was below the configured 256-token sequence length, providing approximately 59 tokens of headroom.
|
| 189 |
|
| 190 |
+
### Training Procedure
|
| 191 |
|
| 192 |
+
The model was trained using **QLoRA**, keeping the quantized base model frozen while training a small set of LoRA adapter parameters.
|
| 193 |
|
| 194 |
+
The base model was quantized to 4-bit NF4 using BitsAndBytes with nested/double quantization.
|
| 195 |
|
| 196 |
+
LoRA adapters were applied to:
|
| 197 |
|
| 198 |
+
- `q_proj`
|
| 199 |
+
- `k_proj`
|
| 200 |
+
- `v_proj`
|
| 201 |
+
- `o_proj`
|
| 202 |
+
- `gate_proj`
|
| 203 |
+
- `up_proj`
|
| 204 |
+
- `down_proj`
|
| 205 |
|
| 206 |
+
#### Training Hyperparameters
|
| 207 |
|
| 208 |
+
| Parameter | Value |
|
| 209 |
+
|---|---:|
|
| 210 |
+
| Base model | Qwen/Qwen2.5-Coder-1.5B-Instruct |
|
| 211 |
+
| Fine-tuning method | QLoRA |
|
| 212 |
+
| Quantization | 4-bit NF4 |
|
| 213 |
+
| Nested quantization | Enabled |
|
| 214 |
+
| Compute dtype | FP16 |
|
| 215 |
+
| LoRA rank (`r`) | 16 |
|
| 216 |
+
| LoRA alpha | 32 |
|
| 217 |
+
| LoRA dropout | 0.05 |
|
| 218 |
+
| Batch size | 1 |
|
| 219 |
+
| Gradient accumulation steps | 8 |
|
| 220 |
+
| Effective batch size | 8 |
|
| 221 |
+
| Number of epochs | 4 |
|
| 222 |
+
| Learning rate | 1e-4 |
|
| 223 |
+
| LR scheduler | Cosine |
|
| 224 |
+
| Weight decay | 0.01 |
|
| 225 |
+
| Warmup steps | 30 |
|
| 226 |
+
| Evaluation frequency | Every 50 steps |
|
| 227 |
+
| Checkpoint save frequency | Every 50 steps |
|
| 228 |
+
| Logging frequency | Every 10 steps |
|
| 229 |
+
| Maximum sequence length | 256 |
|
| 230 |
+
| Gradient checkpointing | Enabled |
|
| 231 |
+
| FIM rate | 0.0 |
|
| 232 |
+
| FIM SPM rate | 0.0 |
|
| 233 |
+
| Random seed | 42 |
|
| 234 |
+
| FP16 | Enabled |
|
| 235 |
+
| BF16 | Disabled |
|
| 236 |
+
|
| 237 |
+
### Speeds, Sizes, Times
|
| 238 |
+
|
| 239 |
+
The completed training run reported:
|
| 240 |
+
|
| 241 |
+
| Metric | Value |
|
| 242 |
+
|---|---:|
|
| 243 |
+
| Global steps | 500 |
|
| 244 |
+
| Epochs | 4 |
|
| 245 |
+
| Training runtime | 3342.5477 seconds |
|
| 246 |
+
| Training runtime | ~55 minutes 43 seconds |
|
| 247 |
+
| Training samples / second | 1.197 |
|
| 248 |
+
| Training steps / second | 0.150 |
|
| 249 |
+
| Total FLOPs | 4,835,834,903,592,960 |
|
| 250 |
+
| Total tokens processed | 607,168 |
|
| 251 |
+
| Final logged training loss | 0.037346 |
|
| 252 |
+
| Aggregate Trainer training loss | 0.2003363176 |
|
| 253 |
+
|
| 254 |
+
The `training_loss` value reported by `Trainer` (`0.2003363176`) represents the aggregate training loss reported for the complete run, whereas the training loss shown at step 500 (`0.037346`) is the most recent logged training loss.
|
| 255 |
|
| 256 |
+
## Evaluation
|
| 257 |
|
| 258 |
### Testing Data, Factors & Metrics
|
| 259 |
|
| 260 |
#### Testing Data
|
| 261 |
|
| 262 |
+
The evaluation dataset was held separately from the training data and was used to calculate validation loss during training.
|
| 263 |
|
| 264 |
+
Validation was performed every 50 training steps.
|
| 265 |
|
| 266 |
#### Factors
|
| 267 |
|
| 268 |
+
The primary evaluation objective was to determine whether the model could learn the expected Python modernization patterns while reducing validation loss throughout training.
|
| 269 |
|
| 270 |
+
The evaluation results below are the validation losses recorded during the training run.
|
| 271 |
|
| 272 |
#### Metrics
|
| 273 |
|
| 274 |
+
The primary reported metrics are:
|
| 275 |
|
| 276 |
+
- Training loss
|
| 277 |
+
- Validation loss
|
| 278 |
+
- Entropy
|
| 279 |
+
- Mean token accuracy
|
| 280 |
+
- Number of processed tokens
|
| 281 |
|
| 282 |
### Results
|
| 283 |
|
|
|
|
|
|
|
| 284 |
#### Summary
|
| 285 |
|
| 286 |
+
The model showed a substantial reduction in both training and validation loss during fine-tuning.
|
| 287 |
|
| 288 |
+
Validation loss decreased from **0.252825 at step 50** to **0.037586 at step 500**.
|
| 289 |
|
| 290 |
+
This represents an approximately **85.1% reduction in validation loss** over the recorded training run.
|
| 291 |
|
| 292 |
+
The final reported mean token accuracy was **98.6229%** at step 500.
|
| 293 |
|
| 294 |
+
The validation loss continued to decrease throughout the later checkpoints, reaching its lowest recorded value of **0.037586 at step 500**.
|
| 295 |
|
| 296 |
+
| Step | Training Loss | Validation Loss | Entropy | Mean Token Accuracy | Num Tokens |
|
| 297 |
+
|---:|---:|---:|---:|---:|---:|
|
| 298 |
+
| 50 | 0.329822 | 0.252825 | 0.280223 | 0.939414 | 60,652 |
|
| 299 |
+
| 100 | 0.070807 | 0.064497 | 0.067091 | 0.981024 | 121,228 |
|
| 300 |
+
| 150 | 0.043590 | 0.048881 | 0.047465 | 0.984845 | 182,259 |
|
| 301 |
+
| 200 | 0.040075 | 0.042402 | 0.043094 | 0.985729 | 242,627 |
|
| 302 |
+
| 250 | 0.038932 | 0.040337 | 0.044742 | 0.985716 | 303,584 |
|
| 303 |
+
| 300 | 0.037993 | 0.038709 | 0.041848 | 0.985923 | 364,412 |
|
| 304 |
+
| 350 | 0.037793 | 0.038682 | 0.041355 | 0.986143 | 424,864 |
|
| 305 |
+
| 400 | 0.038162 | 0.038088 | 0.039560 | 0.986307 | 485,911 |
|
| 306 |
+
| 450 | 0.040015 | 0.037656 | 0.041152 | 0.986229 | 546,449 |
|
| 307 |
+
| 500 | 0.037346 | **0.037586** | 0.040890 | **0.986229** | 607,168 |
|
| 308 |
+
|
| 309 |
+
The final training output was:
|
| 310 |
+
|
| 311 |
+
```text
|
| 312 |
+
TrainOutput(
|
| 313 |
+
global_step=500,
|
| 314 |
+
training_loss=0.20033631759881973,
|
| 315 |
+
epoch=4.0
|
| 316 |
+
)
|
| 317 |
+
```
|
| 318 |
+
|
| 319 |
+
with the following reported training metrics:
|
| 320 |
|
| 321 |
+
```text
|
| 322 |
+
train_runtime: 3342.5477
|
| 323 |
+
train_samples_per_second: 1.197
|
| 324 |
+
train_steps_per_second: 0.15
|
| 325 |
+
total_flos: 4835834903592960.0
|
| 326 |
+
train_loss: 0.20033631759881973
|
| 327 |
+
epoch: 4.0
|
| 328 |
+
```
|
| 329 |
|
| 330 |
+
These results indicate that the model successfully optimized the training objective and achieved high token-level accuracy on the evaluation data.
|
| 331 |
|
| 332 |
+
However, token-level accuracy and validation loss should not be interpreted as a guarantee that every generated modernization preserves the original program's behavior. Functional testing remains necessary.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
+
## Model Examination
|
| 335 |
+
|
| 336 |
+
The model should be examined primarily through qualitative code-generation and modernization tests.
|
| 337 |
+
|
| 338 |
+
Recommended examination procedures include:
|
| 339 |
+
|
| 340 |
+
- Comparing legacy and modernized Python implementations.
|
| 341 |
+
- Checking generated code with the Python 3.14 interpreter.
|
| 342 |
+
- Running unit tests before and after modernization.
|
| 343 |
+
- Checking whether program behavior is preserved.
|
| 344 |
+
- Testing edge cases and uncommon Python constructs.
|
| 345 |
+
- Evaluating whether deprecated or legacy syntax is correctly modernized.
|
| 346 |
+
|
| 347 |
+
No additional qualitative examination results are reported in this model card unless separately documented.
|
| 348 |
+
|
| 349 |
+
## Environmental Impact
|
| 350 |
+
|
| 351 |
+
The training run required approximately **55 minutes and 43 seconds** of compute time.
|
| 352 |
+
|
| 353 |
+
No verified carbon-emissions measurement was recorded for this training run, so a specific carbon footprint is not reported.
|
| 354 |
+
|
| 355 |
+
## Technical Specifications
|
| 356 |
|
| 357 |
### Model Architecture and Objective
|
| 358 |
|
| 359 |
+
The underlying architecture is based on Qwen2.5-Coder-1.5B-Instruct.
|
| 360 |
|
| 361 |
+
The fine-tuning objective uses supervised instruction tuning with LoRA adapters.
|
| 362 |
|
| 363 |
+
QLoRA was used to reduce the memory requirements of fine-tuning by quantizing the frozen base model to 4-bit NF4 while keeping the trainable LoRA parameters separate.
|
| 364 |
+
|
| 365 |
+
The LoRA configuration was:
|
| 366 |
+
|
| 367 |
+
```text
|
| 368 |
+
r = 16
|
| 369 |
+
alpha = 32
|
| 370 |
+
dropout = 0.05
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
Target modules:
|
| 374 |
+
|
| 375 |
+
```text
|
| 376 |
+
q_proj
|
| 377 |
+
k_proj
|
| 378 |
+
v_proj
|
| 379 |
+
o_proj
|
| 380 |
+
gate_proj
|
| 381 |
+
up_proj
|
| 382 |
+
down_proj
|
| 383 |
+
```
|
| 384 |
+
|
| 385 |
+
The adapter contains only the learned parameter-efficient fine-tuning weights and does not contain a standalone copy of the base model.
|
| 386 |
+
|
| 387 |
+
### Compute Infrastructure
|
| 388 |
|
| 389 |
#### Hardware
|
| 390 |
|
| 391 |
+
Training was performed using an NVIDIA Tesla T4 GPU environment.
|
| 392 |
|
| 393 |
#### Software
|
| 394 |
|
| 395 |
+
| Component | Version |
|
| 396 |
+
|---|---|
|
| 397 |
+
| Python | 3.13 |
|
| 398 |
+
| PyTorch | 2.11.0+cu128 |
|
| 399 |
+
| CUDA | 12.8 |
|
| 400 |
+
| Transformers | 5.16.1 |
|
| 401 |
+
| TRL | 1.12.0 |
|
| 402 |
+
| PEFT | 0.20.0 |
|
| 403 |
+
| Accelerate | 1.14.0 |
|
| 404 |
+
| BitsAndBytes | 0.50.2 |
|
| 405 |
+
|
| 406 |
+
## Citation
|
| 407 |
+
|
| 408 |
+
If you use this adapter, please also cite the underlying Qwen2.5-Coder model according to the citation information provided by its authors.
|
| 409 |
+
|
| 410 |
+
## Glossary
|
| 411 |
|
| 412 |
+
**LoRA**
|
| 413 |
+
Low-Rank Adaptation, a parameter-efficient fine-tuning method that trains small low-rank matrices instead of updating the entire model.
|
| 414 |
|
| 415 |
+
**QLoRA**
|
| 416 |
+
Quantized LoRA fine-tuning, where the frozen base model is loaded in low-bit precision while LoRA parameters are trained.
|
| 417 |
|
| 418 |
+
**NF4**
|
| 419 |
+
NormalFloat 4-bit, a 4-bit quantization data type designed for normally distributed neural-network weights.
|
| 420 |
|
| 421 |
+
**Nested Quantization / Double Quantization**
|
| 422 |
+
A technique that further quantizes the quantization constants to reduce memory usage.
|
| 423 |
|
| 424 |
+
**FP16**
|
| 425 |
+
16-bit floating-point representation used for computation during training and inference.
|
| 426 |
|
| 427 |
+
**Mean Token Accuracy**
|
| 428 |
+
The proportion of target tokens correctly predicted by the model during evaluation.
|
| 429 |
|
| 430 |
+
**Validation Loss**
|
| 431 |
+
The loss calculated on the held-out evaluation dataset.
|
| 432 |
|
| 433 |
+
## More Information
|
| 434 |
|
| 435 |
+
This adapter is specifically intended for Python code modernization toward Python 3.14.
|
| 436 |
|
| 437 |
+
For deployment scenarios with limited GPU memory, the adapter can be loaded with the base model using 4-bit NF4 quantization.
|
| 438 |
|
| 439 |
+
For standalone deployment, the LoRA adapter can also be merged into the base model and subsequently quantized using an appropriate deployment format.
|
| 440 |
|
| 441 |
+
## Model Card Authors
|
| 442 |
|
| 443 |
+
Krishnasri2027
|
| 444 |
|
| 445 |
## Model Card Contact
|
| 446 |
|
| 447 |
+
For questions, issues, or suggestions regarding this model, please use the discussion and issue facilities available on the model repository.
|