Add model card README
Browse files
README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: google/gemma-3-270m-it
|
| 4 |
+
tags:
|
| 5 |
+
- gemma
|
| 6 |
+
- kiliki
|
| 7 |
+
- translation
|
| 8 |
+
- qlora
|
| 9 |
+
- language-model
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Gemma 3 270M - Kiliki Language Fine-tuned Model
|
| 13 |
+
|
| 14 |
+
This model is a fine-tuned version of [google/gemma-3-270m-it](https://huggingface.co/google/gemma-3-270m-it) using QLoRA (Quantized Low-Rank Adaptation) for English to Kiliki language translation.
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
|
| 18 |
+
- **Base Model**: google/gemma-3-270m-it
|
| 19 |
+
- **Fine-tuning Method**: QLoRA (4-bit quantization + LoRA adapters)
|
| 20 |
+
- **Training Dataset**: kiliki_dataset_10k.csv (7,528 unique English-Kiliki translation pairs)
|
| 21 |
+
- **Model Size**: Only adapter weights (~few MB) - requires base model for inference
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 27 |
+
from peft import PeftModel
|
| 28 |
+
import torch
|
| 29 |
+
|
| 30 |
+
# Load base model with quantization
|
| 31 |
+
bnb_config = BitsAndBytesConfig(
|
| 32 |
+
load_in_4bit=True,
|
| 33 |
+
bnb_4bit_quant_type="nf4",
|
| 34 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
+
"google/gemma-3-270m-it",
|
| 39 |
+
quantization_config=bnb_config,
|
| 40 |
+
device_map="auto",
|
| 41 |
+
)
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m-it")
|
| 43 |
+
|
| 44 |
+
# Load QLoRA adapter
|
| 45 |
+
model = PeftModel.from_pretrained(model, "droidnext/gemma_3_270m_kiliki_language")
|
| 46 |
+
|
| 47 |
+
# Generate translation
|
| 48 |
+
messages = [{"role": "user", "content": "Hello"}]
|
| 49 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 50 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 51 |
+
outputs = model.generate(**inputs, max_new_tokens=50)
|
| 52 |
+
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:]))
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
## Training Details
|
| 56 |
+
|
| 57 |
+
- **Training Dataset**: 7,528 English-Kiliki translation pairs
|
| 58 |
+
- **Training Split**: 80% train, 20% test
|
| 59 |
+
- **Method**: QLoRA (4-bit quantization with LoRA rank 64)
|