Views
No views yet
pip install transformers accelerate torch1from transformers import AutoProcessor, Gemma3ForConditionalGeneration
2import torch
3
4model_id = "IQRA-AI/gemma-3-4b-Quran-1epochs"
5
6model = Gemma3ForConditionalGeneration.from_pretrained(
7 model_id, device_map="auto"
8).eval()
9
10processor = AutoProcessor.from_pretrained(model_id)
11
12messages = [
13 {
14 "role": "system",
15 "content": [{"type": "text", "text": ""}]
16 },
17 {
18 "role": "user",
19 "content": [
20 {"type": "text", "text": "Surah Al Fatihah turun dimana?"}
21 ]
22 }
23]
24
25inputs = processor.apply_chat_template(
26 messages, add_generation_prompt=True, tokenize=True,
27 return_dict=True, return_tensors="pt"
28).to(model.device, dtype=torch.bfloat16)
29
30input_len = inputs["input_ids"].shape[-1]
31
32with torch.inference_mode():
33 generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
34 generation = generation[0][input_len:]
35
36decoded = processor.decode(generation, skip_special_tokens=True)
37print(decoded)@misc{iqra-ai-gemma-3-4b-quran,
author = {IQRA-AI},
title = {Gemma 3 4B Quran 1 Epoch},
year = {2025},
publisher = {Hugging Face},
author = {Ariel Fikru Avicenna}
howpublished = {\url{https://huggingface.co/IQRA-AI/gemma-3-4b-Quran-1epochs}}
}