File size: 2,264 Bytes
228cdd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4681709
228cdd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- tr
license: apache-2.0
library_name: transformers
tags:
- llama-3
- turkish
- tiny-llama
- scratch-build
datasets:
- TFLai/Turkish-Alpaca
metrics:
- loss
model_type: llama
---

# Llama-TR-Mini (134M Parameters)

Llama-TR-Mini is an experimental, ultra-lightweight Turkish language model with **134 million parameters**, trained from scratch using the Llama 3 architecture. 

This project was developed to explore the limits of small-scale language modeling and to understand the end-to-end pre-training/fine-tuning pipeline on consumer-grade hardware (Apple Silicon).

## Model Specifications
- **Architecture:** Llama 3
- **Parameters:** 134,105,856
- **Hidden Size:** 768
- **Intermediate Size:** 2048
- **Number of Layers:** 12
- **Attention Heads:** 12
- **Vocabulary Size:** 32,000 (Custom Turkish Tokenizer)
- **Training Epochs:** 30
- **Device:** MacBook Pro (MPS - Metal Performance Shaders)

## Training Data
The model was trained on the [Turkish-Alpaca](https://huggingface.co/datasets/TFLai/Turkish-Alpaca) dataset, which contains approximately 52K instruction-following pairs translated into Turkish.

## Intended Use & Limitations
**Important Note:** Due to its extremely small size (134M parameters), this model is prone to significant hallucinations and may produce nonsensical or repetitive outputs. 

- **Purpose:** Educational purposes, understanding LLM mechanics.
- **Not Suited For:** Production environments, factual information retrieval, or complex reasoning tasks.
- **Format:** Optimized for the Llama 3 Instruct template (`<|start_header_id|>user<|end_header_id|>`).

## How to Use
You can load this model using the `transformers` library:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "k12tr/mini-tr-134M"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

prompt = "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nTürkiye'nin başkenti neresidir?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=50, temperature=0.1, repetition_penalty=1.5)

print(tokenizer.decode(output[0], skip_special_tokens=True))