Views
No views yet
unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit model, fine-tuned on a cleaned Persian conversational dataset.unsloth/gemma-3n-E4B-it model and then apply the adapters from this repository. The Unsloth library is required for this process.1# Install Unsloth for Google Colab
2!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
3!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes1from unsloth import FastLanguageModel
2import torch
3from transformers import TextStreamer
4
5# Your LoRA adapter repository
6lora_model_name = "mshojaei77/gemma-3n-E4B-persin-lora-adaptors"
7
8# Load the base model and tokenizer
9model, tokenizer = FastLanguageModel.from_pretrained(
10 model_name = lora_model_name, # Use your LoRA repo name
11 max_seq_length = 4096,
12 dtype = None,
13 load_in_4bit = True,
14)
15
16# Set up a text streamer for continuous output
17streamer = TextStreamer(tokenizer, skip_prompt=True)
18
19# Prepare your prompt
20messages = [{
21 "role": "user",
22 "content": "Node.js چیه و چه کاربردی داره؟",
23}]
24
25# Format and tokenize the input
26inputs = tokenizer.apply_chat_template(
27 messages,
28 add_generation_prompt=True,
29 return_tensors="pt",
30).to("cuda")
31
32# Run generation
33_ = model.generate(
34 **inputs,
35 max_new_tokens=256,
36 streamer=streamer,
37 use_cache=True,
38 # Recommended Gemma-3 settings
39 temperature=0.7,
40 top_p=0.95,
41 top_k=64,
42)mshojaei77/persian-gk-cleaned dataset, which is a curated version of the original mshojaei77/persian-gk dataset. The cleaning process involved:user/assistant alternating roles.r: 8alpha: 16@misc{gemma3n,
author = {The Gemma 3N team, Google},
title = {Gemma 3N},
year = {2024},
howpublished = {\url{https://ai.google.dev/gemma}},
}@misc{unsloth,
author = {Daniel Han and Phil Wang},
title = {Unsloth: Llama, Mistral & Gemma 5x faster training},
year = {2024},
howpublished = {\url{https://github.com/unslothai/unsloth}},
}