Downloads · 30 days
12
6% of all-time downloads
emre/gemma-2-9b-Turkish-Lora-Continue-Pre-Trained
gemma-2-9b-Turkish-Lora-Continue-Pre-Trained is a text generation model from emre. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as gemma.
- Commercially only available to BBVA Group, Free to use for academic and research purposes
Downloads · 30 days
12
6% of all-time downloads
All-time downloads
218
Public
Repo size
56.5 MB
Likes
5
Public
Click a slice to open those files.
.json34.4 MB · 61%
From the Hugging Face model README
This model is a continued pre-trained version of the google/gemma-2-9b base model, trained on the Turkish Wikipedia dataset (Alaeddin/wikipedia-turkish). The fine-tuning was performed using Low-Rank Adaptation (LoRA) to efficiently adapt the model to the Turkish language. This model aims to improve the base model's understanding and generation capabilities for Turkish text.
This model can be used for generating Turkish text for various natural language processing tasks, such as:
It is intended for researchers, developers, and enthusiasts interested in exploring and utilizing large language models for the Turkish language.
This model can serve as a strong base for further fine-tuning on specific downstream tasks in Turkish, such as:
This model should not be used for generating harmful, unethical, or biased content. As a language model trained on a large corpus of text, it may inadvertently generate such content. Users should exercise caution and responsibility when deploying this model.
The model was trained on the Turkish Wikipedia dataset, which may contain biases present in the original data. The model's performance may vary depending on the specific task and domain. Users should be aware of these limitations and conduct thorough evaluations for their specific use cases.
Users should carefully evaluate the model's output and consider potential biases before deploying it in real-world applications. Further fine-tuning on task-specific and diverse Turkish datasets can help mitigate some of these limitations.
The model was trained on the Alaeddin/wikipedia-turkish dataset:
The model was trained using the Hugging Face Trainer API on a Google Colab Pro+ instance with an A100 GPU (40GB). Key settings include:
BitsAndBytesConfig).r): 8lora_alpha): 32q_proj, v_projper_device_train_batch_size=2, gradient_accumulation_steps=4)1,000 paragraphs from the Turkish Wikipedia dataset, reserved as a validation set.
| Model | Validation Loss | Perplexity |
|---|---|---|
| Pre-trained Core (Gemma-2-9b) | 2.5168 | 12.39 |
| Continued Pre-trained (LoRA) | 2.1027 | 8.19 |
The LoRA-adapted model significantly outperforms the base model on Turkish text.
Carbon emissions were estimated using the Machine Learning Impact calculator:
Note: Exact emissions depend on the compute region's energy mix.
You can easily load and use this model using the transformers and peft libraries in Python:
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
model_name = "google/gemma-2-9b"
peft_model_id = "emre/gemma-2-9b-Turkish-Lora-Continue-Pre-Trained"
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Load the base model with 4-bit quantization for efficiency
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16
)
base_model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.float16,
attn_implementation="eager"
)
# Load the LoRA adapter
model = PeftModel.from_pretrained(base_model, peft_model_id)
model.eval()
if torch.cuda.is_available():
model = model.to("cuda")
prompt = "Türkiye'nin başkenti neresidir?"
input_ids = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**input_ids, max_new_tokens=50, num_return_sequences=1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
@misc{tasar2023gemma2turkish,
author = {Davut Emre Tasar},
title = {Gemma-2-9b Turkish LoRA Continue Pre-Trained Model},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/emre/gemma-2-9b-Turkish-Lora-Continue-Pre-Trained}}
}