Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +147 -0
- added_tokens.json +3 -0
- chat_template.jinja +47 -0
- config.json +65 -0
- generation_config.json +13 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +33 -0
- tokenizer.json +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: google/gemma-3-1b-it
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
language: en
|
| 6 |
+
license: mit
|
| 7 |
+
tags:
|
| 8 |
+
- lora
|
| 9 |
+
- sft
|
| 10 |
+
- transformers
|
| 11 |
+
- trl
|
| 12 |
+
- unsloth
|
| 13 |
+
- fine-tuned
|
| 14 |
+
datasets:
|
| 15 |
+
- Vezora/Tested-22k-Python-Alpaca
|
| 16 |
+
---
|
| 17 |
+
# Gemma3-Python-22k-1B
|
| 18 |
+
|
| 19 |
+
A fine-tuned Gemma 3 1B model, fine tuned on the Vezora/Tested-22k-Python-Alpaca dataset.
|
| 20 |
+
|
| 21 |
+
## Model Details
|
| 22 |
+
|
| 23 |
+
This model is a fine-tuned version of google/gemma-3-1b-it using the Unsloth framework with LoRA (Low-Rank Adaptation) for efficient training.
|
| 24 |
+
|
| 25 |
+
- **Developed by:** theprint
|
| 26 |
+
- **Model type:** Causal Language Model (Fine-tuned with LoRA)
|
| 27 |
+
- **Language:** en
|
| 28 |
+
- **License:** mit
|
| 29 |
+
- **Base model:** google/gemma-3-1b-it
|
| 30 |
+
- **Fine-tuning method:** LoRA with rank 128
|
| 31 |
+
|
| 32 |
+
## Intended Use
|
| 33 |
+
|
| 34 |
+
Light coding support (Python only), project feedback and brainstorming.
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## GGUF Quantized Versions
|
| 38 |
+
|
| 39 |
+
Quantized GGUF versions are available in the [theprint/Gemma3-Python-22k-1B-GGUF](https://huggingface.co/theprint/Gemma3-Python-22k-1B-GGUF) repo.
|
| 40 |
+
|
| 41 |
+
- `Gemma3-Python-22k-1B-f16.gguf` (2489.6 MB) - 16-bit float (original precision, largest file)
|
| 42 |
+
- `Gemma3-Python-22k-1B-q3_k_m.gguf` (850.9 MB) - 3-bit quantization (medium quality)
|
| 43 |
+
- `Gemma3-Python-22k-1B-q4_k_m.gguf` (966.7 MB) - 4-bit quantization (medium, recommended for most use cases)
|
| 44 |
+
- `Gemma3-Python-22k-1B-q5_k_m.gguf` (1027.9 MB) - 5-bit quantization (medium, good quality)
|
| 45 |
+
- `Gemma3-Python-22k-1B-q6_k.gguf` (1270.9 MB) - 6-bit quantization (high quality)
|
| 46 |
+
- `Gemma3-Python-22k-1B-q8_0.gguf` (1325.8 MB) - 8-bit quantization (very high quality)
|
| 47 |
+
|
| 48 |
+
## Training Details
|
| 49 |
+
|
| 50 |
+
### Training Data
|
| 51 |
+
|
| 52 |
+
The data set used is [Vezora/Tested-22k-Python-Alpaca](https://huggingface.co/datasets/Vezora/Tested-22k-Python-Alpaca).
|
| 53 |
+
|
| 54 |
+
- **Dataset:** Vezora/Tested-22k-Python-Alpaca
|
| 55 |
+
- **Format:** alpaca
|
| 56 |
+
|
| 57 |
+
### Training Procedure
|
| 58 |
+
|
| 59 |
+
- **Training epochs:** 2
|
| 60 |
+
- **LoRA rank:** 128
|
| 61 |
+
- **Learning rate:** 3e-05
|
| 62 |
+
- **Batch size:** 4
|
| 63 |
+
- **Framework:** Unsloth + transformers + PEFT
|
| 64 |
+
- **Hardware:** NVIDIA RTX 5090
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from unsloth import FastLanguageModel
|
| 70 |
+
import torch
|
| 71 |
+
|
| 72 |
+
# Load model and tokenizer
|
| 73 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 74 |
+
model_name="theprint/Gemma3-Python-22k-1B",
|
| 75 |
+
max_seq_length=4096,
|
| 76 |
+
dtype=None,
|
| 77 |
+
load_in_4bit=True,
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# Enable inference mode
|
| 81 |
+
FastLanguageModel.for_inference(model)
|
| 82 |
+
|
| 83 |
+
# Example usage
|
| 84 |
+
inputs = tokenizer(["Your prompt here"], return_tensors="pt")
|
| 85 |
+
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
|
| 86 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 87 |
+
print(response)
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Alternative Usage (Standard Transformers)
|
| 91 |
+
|
| 92 |
+
```python
|
| 93 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 94 |
+
import torch
|
| 95 |
+
|
| 96 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 97 |
+
"theprint/Gemma3-Python-22k-1B",
|
| 98 |
+
torch_dtype=torch.float16,
|
| 99 |
+
device_map="auto"
|
| 100 |
+
)
|
| 101 |
+
tokenizer = AutoTokenizer.from_pretrained("theprint/Gemma3-Python-22k-1B")
|
| 102 |
+
|
| 103 |
+
# Example usage
|
| 104 |
+
messages = [
|
| 105 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 106 |
+
{"role": "user", "content": "Your question here"}
|
| 107 |
+
]
|
| 108 |
+
|
| 109 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
|
| 110 |
+
outputs = model.generate(inputs, max_new_tokens=256, temperature=0.7, do_sample=True)
|
| 111 |
+
response = tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)
|
| 112 |
+
print(response)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### Using with llama.cpp
|
| 116 |
+
|
| 117 |
+
```bash
|
| 118 |
+
# Download a quantized version (q4_k_m recommended for most use cases)
|
| 119 |
+
wget https://huggingface.co/theprint/Gemma3-Python-22k-1B/resolve/main/gguf/Gemma3-Python-22k-1B-q4_k_m.gguf
|
| 120 |
+
|
| 121 |
+
# Run with llama.cpp
|
| 122 |
+
./llama.cpp/main -m Gemma3-Python-22k-1B-q4_k_m.gguf -p "Your prompt here" -n 256
|
| 123 |
+
```
|
| 124 |
+
## Limitations
|
| 125 |
+
|
| 126 |
+
May provide incorrect information.
|
| 127 |
+
|
| 128 |
+
## Citation
|
| 129 |
+
|
| 130 |
+
If you use this model, please cite:
|
| 131 |
+
|
| 132 |
+
```bibtex
|
| 133 |
+
@misc{gemma3_python_22k_1b,
|
| 134 |
+
title={Gemma3-Python-22k-1B: Fine-tuned google/gemma-3-1b-it},
|
| 135 |
+
author={theprint},
|
| 136 |
+
year={2025},
|
| 137 |
+
publisher={Hugging Face},
|
| 138 |
+
url={https://huggingface.co/theprint/Gemma3-Python-22k-1B}
|
| 139 |
+
}
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
## Acknowledgments
|
| 143 |
+
|
| 144 |
+
- Base model: [google/gemma-3-1b-it](https://huggingface.co/google/gemma-3-1b-it)
|
| 145 |
+
- Training dataset: [Vezora/Tested-22k-Python-Alpaca](https://huggingface.co/datasets/Vezora/Tested-22k-Python-Alpaca)
|
| 146 |
+
- Fine-tuning framework: [Unsloth](https://github.com/unslothai/unsloth)
|
| 147 |
+
- Quantization: [llama.cpp](https://github.com/ggerganov/llama.cpp)
|
added_tokens.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<image_soft_token>": 262144
|
| 3 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{ bos_token }}
|
| 2 |
+
{%- if messages[0]['role'] == 'system' -%}
|
| 3 |
+
{%- if messages[0]['content'] is string -%}
|
| 4 |
+
{%- set first_user_prefix = messages[0]['content'] + '
|
| 5 |
+
|
| 6 |
+
' -%}
|
| 7 |
+
{%- else -%}
|
| 8 |
+
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
|
| 9 |
+
|
| 10 |
+
' -%}
|
| 11 |
+
{%- endif -%}
|
| 12 |
+
{%- set loop_messages = messages[1:] -%}
|
| 13 |
+
{%- else -%}
|
| 14 |
+
{%- set first_user_prefix = "" -%}
|
| 15 |
+
{%- set loop_messages = messages -%}
|
| 16 |
+
{%- endif -%}
|
| 17 |
+
{%- for message in loop_messages -%}
|
| 18 |
+
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
|
| 19 |
+
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
|
| 20 |
+
{%- endif -%}
|
| 21 |
+
{%- if (message['role'] == 'assistant') -%}
|
| 22 |
+
{%- set role = "model" -%}
|
| 23 |
+
{%- else -%}
|
| 24 |
+
{%- set role = message['role'] -%}
|
| 25 |
+
{%- endif -%}
|
| 26 |
+
{{ '<start_of_turn>' + role + '
|
| 27 |
+
' + (first_user_prefix if loop.first else "") }}
|
| 28 |
+
{%- if message['content'] is string -%}
|
| 29 |
+
{{ message['content'] | trim }}
|
| 30 |
+
{%- elif message['content'] is iterable -%}
|
| 31 |
+
{%- for item in message['content'] -%}
|
| 32 |
+
{%- if item['type'] == 'image' -%}
|
| 33 |
+
{{ '<start_of_image>' }}
|
| 34 |
+
{%- elif item['type'] == 'text' -%}
|
| 35 |
+
{{ item['text'] | trim }}
|
| 36 |
+
{%- endif -%}
|
| 37 |
+
{%- endfor -%}
|
| 38 |
+
{%- else -%}
|
| 39 |
+
{{ raise_exception("Invalid content type") }}
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{{ '<end_of_turn>
|
| 42 |
+
' }}
|
| 43 |
+
{%- endfor -%}
|
| 44 |
+
{%- if add_generation_prompt -%}
|
| 45 |
+
{{'<start_of_turn>model
|
| 46 |
+
'}}
|
| 47 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_sliding_window_pattern": 6,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"Gemma3ForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attn_logit_softcapping": null,
|
| 9 |
+
"bos_token_id": 2,
|
| 10 |
+
"cache_implementation": "hybrid",
|
| 11 |
+
"eos_token_id": [
|
| 12 |
+
1,
|
| 13 |
+
106
|
| 14 |
+
],
|
| 15 |
+
"final_logit_softcapping": null,
|
| 16 |
+
"head_dim": 256,
|
| 17 |
+
"hidden_activation": "gelu_pytorch_tanh",
|
| 18 |
+
"hidden_size": 1152,
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 6912,
|
| 21 |
+
"layer_types": [
|
| 22 |
+
"sliding_attention",
|
| 23 |
+
"sliding_attention",
|
| 24 |
+
"sliding_attention",
|
| 25 |
+
"sliding_attention",
|
| 26 |
+
"sliding_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"sliding_attention",
|
| 29 |
+
"sliding_attention",
|
| 30 |
+
"sliding_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"sliding_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"sliding_attention",
|
| 35 |
+
"sliding_attention",
|
| 36 |
+
"sliding_attention",
|
| 37 |
+
"sliding_attention",
|
| 38 |
+
"sliding_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"sliding_attention",
|
| 41 |
+
"sliding_attention",
|
| 42 |
+
"sliding_attention",
|
| 43 |
+
"sliding_attention",
|
| 44 |
+
"sliding_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"sliding_attention",
|
| 47 |
+
"sliding_attention"
|
| 48 |
+
],
|
| 49 |
+
"max_position_embeddings": 32768,
|
| 50 |
+
"model_type": "gemma3_text",
|
| 51 |
+
"num_attention_heads": 4,
|
| 52 |
+
"num_hidden_layers": 26,
|
| 53 |
+
"num_key_value_heads": 1,
|
| 54 |
+
"pad_token_id": 0,
|
| 55 |
+
"query_pre_attn_scalar": 256,
|
| 56 |
+
"rms_norm_eps": 1e-06,
|
| 57 |
+
"rope_local_base_freq": 10000,
|
| 58 |
+
"rope_scaling": null,
|
| 59 |
+
"rope_theta": 1000000,
|
| 60 |
+
"sliding_window": 512,
|
| 61 |
+
"torch_dtype": "float16",
|
| 62 |
+
"transformers_version": "4.53.2",
|
| 63 |
+
"use_cache": true,
|
| 64 |
+
"vocab_size": 262144
|
| 65 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 2,
|
| 3 |
+
"cache_implementation": "hybrid",
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": [
|
| 6 |
+
1,
|
| 7 |
+
106
|
| 8 |
+
],
|
| 9 |
+
"pad_token_id": 0,
|
| 10 |
+
"top_k": 64,
|
| 11 |
+
"top_p": 0.95,
|
| 12 |
+
"transformers_version": "4.53.2"
|
| 13 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5bb1a41f9250efc5c087b320cf01554f0e53191fb8739a8ec161ec0ca4321a1e
|
| 3 |
+
size 1999887347
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"boi_token": "<start_of_image>",
|
| 3 |
+
"bos_token": {
|
| 4 |
+
"content": "<bos>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false
|
| 9 |
+
},
|
| 10 |
+
"eoi_token": "<end_of_image>",
|
| 11 |
+
"eos_token": {
|
| 12 |
+
"content": "<eos>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false
|
| 17 |
+
},
|
| 18 |
+
"image_token": "<image_soft_token>",
|
| 19 |
+
"pad_token": {
|
| 20 |
+
"content": "<pad>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false
|
| 25 |
+
},
|
| 26 |
+
"unk_token": {
|
| 27 |
+
"content": "<unk>",
|
| 28 |
+
"lstrip": false,
|
| 29 |
+
"normalized": false,
|
| 30 |
+
"rstrip": false,
|
| 31 |
+
"single_word": false
|
| 32 |
+
}
|
| 33 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
|
| 3 |
+
size 33384568
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
|
| 3 |
+
size 4689074
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|