File size: 4,161 Bytes
20cdbdf
3276d37
 
ebee714
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20cdbdf
 
ebee714
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20cdbdf
ebee714
20cdbdf
ebee714
20cdbdf
ebee714
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
language:
- en
license: llama3.1
license_name: llama3.1
license_link: https://huggingface.co/meta-llama/Llama-3.1-8B/blob/main/LICENSE
base_model: meta-llama/Llama-3.1-8B
tags:
- llama
- llama-3.1
- unsloth
- lora
- code-generation
- python
- gguf
datasets:
- flytech/python-codes-25k
pipeline_tag: text-generation
library_name: transformers
---

# Python-wizard-Llama-3.1-8b

A Python code-generation assistant fine-tuned from **Meta-Llama-3.1-8B** using LoRA, trained with [Unsloth](https://github.com/unslothai/unsloth), and exported to GGUF for local inference (Ollama / llama.cpp).

Built with Llama.

## Model Details

- **Base model:** [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B)
- **Fine-tuning method:** LoRA (Low-Rank Adaptation), via Unsloth
- **Quantized base:** `unsloth/Meta-Llama-3.1-8B-bnb-4bit` (4-bit) used during training
- **Task:** Instruction-following Python code generation
- **Export format:** GGUF, quantized `Q4_K_M` (~4.92 GB)
- **Language:** English

## Training Data

Fine-tuned on [`flytech/python-codes-25k`](https://huggingface.co/datasets/flytech/python-codes-25k), a dataset of instruction/input/output triples for Python code generation tasks.

Prompt format used during training:

```
Below is an instruction that describes a task, paired with an optional introductory context. Write a response that appropriately completes the request with clean Python code.

### Instruction:
{instruction}

### Context:
{input}

### Response:
{output}
```

## Training Configuration

| Parameter | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 16 |
| LoRA dropout | 0 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Bias | none |
| Max sequence length | 2048 |
| Quantization (training) | 4-bit |
| Gradient checkpointing | Unsloth (optimized) |
| Random seed | 3407 |

> Note: this checkpoint was trained for a limited number of steps (checkpoint-60). Treat outputs as a proof-of-concept rather than a fully converged model — see Limitations below.

## Usage

### With Ollama

```bash
ollama run hf.co/ShyamSaran-18/Python-wizard-Llama-3.1-8b
```

### With llama.cpp

```bash
llama-cli -hf ShyamSaran-18/Python-wizard-Llama-3.1-8b --jinja
```

### With transformers + PEFT (LoRA adapter, if published separately)

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B")
model = PeftModel.from_pretrained(base, "ShyamSaran-18/Python-wizard-Llama-3.1-8b")
```

## Intended Use

Generating Python code snippets and completions from natural-language instructions. Intended for experimentation, learning, and portfolio demonstration of LoRA fine-tuning and local LLM deployment workflows.

## Limitations

- Trained on a single open dataset with a limited number of training steps; not benchmarked against held-out evaluation data.
- Inherits the general limitations and biases of the base Llama 3.1 model.
- Generated code should be reviewed before use — no guarantees of correctness, security, or production-readiness.
- Not evaluated for languages other than Python or for tasks outside code generation.

## License

This model is a fine-tuned derivative of Meta's Llama 3.1 and is distributed under the **Llama 3.1 Community License**.

- License text: https://huggingface.co/meta-llama/Llama-3.1-8B/blob/main/LICENSE
- Acceptable Use Policy: https://llama.meta.com/llama3_1/use-policy

By using this model you agree to the terms of the Llama 3.1 Community License Agreement. Use of this model must also comply with Meta's Acceptable Use Policy.

**Notice:** Llama 3.1 is licensed under the Llama 3.1 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.

## Acknowledgements

- [Meta AI](https://ai.meta.com/llama/) for the base Llama 3.1 model
- [Unsloth](https://github.com/unslothai/unsloth) for efficient fine-tuning and GGUF export tooling
- [flytech/python-codes-25k](https://huggingface.co/datasets/flytech/python-codes-25k) dataset authors