Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,105 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- smollm
|
| 5 |
+
- python
|
| 6 |
+
- code-generation
|
| 7 |
+
- instruct
|
| 8 |
+
- qlora
|
| 9 |
+
- fine-tuned
|
| 10 |
+
- code
|
| 11 |
+
- nf4
|
| 12 |
+
datasets:
|
| 13 |
+
- flytech/python-codes-25k
|
| 14 |
+
model-index:
|
| 15 |
+
- name: HF-SmolLM-1.7B-0.5B-4bit-coder
|
| 16 |
+
results: []
|
| 17 |
+
language:
|
| 18 |
+
- en
|
| 19 |
+
pipeline_tag: text-generation
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
# HF-SmolLM-1.7B-0.5B-4bit-coder
|
| 23 |
+
|
| 24 |
+
## Model Summary
|
| 25 |
+
**HF-SmolLM-1.7B-0.5B-4bit-coder** is a fine-tuned variant of [SmolLM-1.7B](https://huggingface.co/HuggingFaceTB/SmolLM-1.7B), optimized for **instruction-following in Python code generation tasks**.
|
| 26 |
+
It was trained on a **1,500-sample subset** of the [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k) dataset using **parameter-efficient fine-tuning (QLoRA 4-bit)**.
|
| 27 |
+
|
| 28 |
+
The model is suitable for:
|
| 29 |
+
- Generating Python code snippets from natural language instructions
|
| 30 |
+
- Completing short code functions
|
| 31 |
+
- Educational prototyping of fine-tuned LMs
|
| 32 |
+
|
| 33 |
+
⚠️ This is **not a production-ready coding assistant**. Generated outputs must be manually reviewed before execution.
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Intended Uses & Limitations
|
| 38 |
+
|
| 39 |
+
### ✅ Intended
|
| 40 |
+
- Research on parameter-efficient fine-tuning
|
| 41 |
+
- Educational demos of instruction-tuning workflows
|
| 42 |
+
- Prototype code generation experiments
|
| 43 |
+
|
| 44 |
+
### ❌ Not Intended
|
| 45 |
+
- Deployment in production coding assistants
|
| 46 |
+
- Safety-critical applications
|
| 47 |
+
- Long-context multi-file programming tasks
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Training Details
|
| 52 |
+
|
| 53 |
+
### Base Model
|
| 54 |
+
- **Name:** [HuggingFaceTB/SmolLM-1.7B](https://huggingface.co/HuggingFaceTB/SmolLM-1.7B)
|
| 55 |
+
- **Architecture:** Decoder-only causal LM
|
| 56 |
+
- **Total Parameters:** 1.72B
|
| 57 |
+
- **Fine-tuned Trainable Parameters:** ~9M (0.53%)
|
| 58 |
+
|
| 59 |
+
### Dataset
|
| 60 |
+
- **Source:** [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k)
|
| 61 |
+
- **Subset Used:** 1,500 randomly sampled examples
|
| 62 |
+
- **Content:** Instruction + optional input → Python code output
|
| 63 |
+
- **Formatting:** Converted into `chat` format with `user` / `assistant` roles
|
| 64 |
+
|
| 65 |
+
### Training Procedure
|
| 66 |
+
- **Framework:** Hugging Face Transformers + TRL (SFTTrainer)
|
| 67 |
+
- **Quantization:** 4-bit QLoRA (nf4) with bfloat16 compute when available
|
| 68 |
+
- **Effective Batch Size:** 6 (with accumulation)
|
| 69 |
+
- **Optimizer:** AdamW
|
| 70 |
+
- **Scheduler:** Cosine decay with warmup ratio 0.05
|
| 71 |
+
- **Epochs:** 3
|
| 72 |
+
- **Learning Rate:** 2e-4
|
| 73 |
+
- **Max Seq Length:** 64 tokens (training)
|
| 74 |
+
- **Mixed Precision:** FP16
|
| 75 |
+
- **Gradient Checkpointing:** Enabled
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## Evaluation
|
| 80 |
+
No formal benchmark evaluation has been conducted yet.
|
| 81 |
+
Empirically, the model:
|
| 82 |
+
- Produces syntactically valid Python code for simple tasks
|
| 83 |
+
- Adheres to given instructions with reasonable accuracy
|
| 84 |
+
- Struggles with multi-step reasoning and long code outputs
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## Example Usage
|
| 89 |
+
|
| 90 |
+
```python
|
| 91 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 92 |
+
|
| 93 |
+
repo = "sweatSmile/HF-SmolLM-1.7B-0.5B-4bit-coder"
|
| 94 |
+
tokenizer = AutoTokenizer.from_pretrained(repo)
|
| 95 |
+
model = AutoModelForCausalLM.from_pretrained(repo, device_map="auto")
|
| 96 |
+
|
| 97 |
+
prompt = "Write a Python function that checks if a number is prime."
|
| 98 |
+
inputs = tokenizer.apply_chat_template(
|
| 99 |
+
[{"role": "user", "content": prompt}],
|
| 100 |
+
return_tensors="pt",
|
| 101 |
+
add_generation_prompt=True
|
| 102 |
+
).to(model.device)
|
| 103 |
+
|
| 104 |
+
outputs = model.generate(inputs, max_new_tokens=150)
|
| 105 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|