Views
No views yet
| Task | Qalb (Ours) | Alif-1.0-Instruct | LLaMA-3.1-8B-Instruct |
|---|---|---|---|
| Overall Score | 90.34 | 87.1 | 45.7 |
| Translation | 94.41 | 89.3 | 58.9 |
| Classification | 96.38 | 93.9 | 61.4 |
| Sentiment Analysis | 95.79 | 94.3 | 54.3 |
| Ethics | 90.83 | 85.7 | 27.3 |
| Reasoning | 88.59 | 83.5 | 45.6 |
| QA (Question Answering) | 80.40 | 73.8 | 30.5 |
| Generation | 85.97 | 90.2 | 42.8 |
1from unsloth import FastLanguageModel
2import torch
3
4model, tokenizer = FastLanguageModel.from_pretrained(
5 model_name = "enstazao/Qalb-1.0-8B-Instruct",
6 max_seq_length = 2048,
7 dtype = None,
8 load_in_4bit = True, # <--- Currently set to use 4-bit quantization
9)
10FastLanguageModel.for_inference(model)
11
12
13urdu_system_prompt = "آپ ایک مددگار اور بے ضرر مصنوعی ذہانت کے اسسٹنٹ ہیں۔ آپ اردو میں سوالات کے درست جوابات دیتے ہیں۔"
14
15questions = [
16 "پاکستان کا قومی کھیل کیا ہے؟",
17 "لاہور شہر کیوں مشہور ہے؟ مختصر وضاحت کریں۔",
18 "سوال: لیاقت علی خان کون تھے؟",
19 "کراچی کو روشنیوں کا شہر کیوں کہا جاتا ہے؟",
20 "انگریزی میں ترجمہ کریں: 'محنت کامیابی کی کنجی ہے۔'"
21]
22
23print("🚀 Starting Batch Generation...\n")
24
25
26for user_input in questions:
27 print(f"🔹 Question: {user_input}")
28
29 # Manually Format Prompt (Llama-3 Style)
30 prompt = f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
31
32{urdu_system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>
33
34{user_input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
35"""
36
37 inputs = tokenizer([prompt], return_tensors = "pt").to("cuda")
38
39 outputs = model.generate(
40 **inputs,
41 max_new_tokens = 256,
42 temperature = 0.1,
43 top_p = 0.9,
44 repetition_penalty = 1.1,
45 do_sample = True,
46 eos_token_id = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
47 )
48
49 response = tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
50
51 print(f"✅ Answer: {response}")
52 print("-" * 50)1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2import torch
3
4
5model_name = "enstazao/Qalb-1.0-8B-Instruct"
6urdu_system_prompt = "آپ ایک مددگار اور بے ضرر مصنوعی ذہانت کے اسسٹنٹ ہیں۔ آپ اردو میں سوالات کے درست جوابات دیتے ہیں۔"
7
8
9bnb_config = BitsAndBytesConfig(
10 load_in_4bit=True,
11 bnb_4bit_quant_type="nf4",
12 bnb_4bit_compute_dtype=torch.bfloat16,
13 bnb_4bit_use_double_quant=True,
14)
15
16
17
18print("⏳ Loading model in 4-bit...")
19tokenizer = AutoTokenizer.from_pretrained(model_name)
20model = AutoModelForCausalLM.from_pretrained(
21 model_name,
22 quantization_config=bnb_config, # <--- Apply 4-bit here
23 device_map="auto" # <--- Required for quantization
24)
25
26terminators = [
27 tokenizer.eos_token_id,
28 tokenizer.convert_tokens_to_ids("<|eot_id|>")
29]
30
31
32questions = [
33 "پاکستان کا قومی کھیل کیا ہے؟",
34 "لاہور شہر کیوں مشہور ہے؟ مختصر وضاحت کریں۔",
35 "سوال: لیاقت علی خان کون تھے؟",
36 "سوال: اسلام آباد شہر کے بارے میں بتائیں۔",
37 "انگریزی میں ترجمہ کریں: 'محنت کامیابی کی کنجی ہے۔'"
38]
39
40print("Model Loaded. Starting Generation...\n")
41
42# 5. Loop through questions
43for user_input in questions:
44 print(f"🔹 Question: {user_input}")
45
46 prompt = f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
47
48{urdu_system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>
49
50{user_input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
51"""
52
53 input_ids = tokenizer([prompt], return_tensors="pt").to("cuda")
54
55 outputs = model.generate(
56 **input_ids,
57 max_new_tokens = 256,
58 temperature = 0.1,
59 top_p = 0.9,
60 repetition_penalty = 1.1,
61 do_sample = True,
62 eos_token_id = terminators
63 )
64
65 response = tokenizer.decode(outputs[0][input_ids['input_ids'].shape[1]:], skip_special_tokens=True)
66
67 print(f"✅ Answer: {response}")
68 print("-" * 50)@article{qalb2025,
title={Qalb: Largest State-of-the-Art Urdu Large Language Model for 230M Speakers with Systematic Continued Pre-training},
author={Hassan, Muhammad Taimoor and Ahmed, Jawad and Awais, Muhammad},
journal={arXiv preprint arXiv:2601.08141},
year={2026},
eprint={2601.08141},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={[https://arxiv.org/abs/2601.08141](https://arxiv.org/abs/2601.08141)},
doi={10.48550/arXiv.2601.08141}
}