Downloads · 30 days
7
2% of all-time downloads
safora/PersianSciQA-Qwen2.5-14B
PersianSciQA-Qwen2.5-14B is a text generation model from safora. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A QLoRA fine-tuned adapter of Qwen/Qwen2.5-14B-Instruct for extractive question answering over Persian scientific texts. The model is trained on the safora/PersianSciQA-Extractive dataset using Supervised Fine-Tuning…
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
367
Public
Parameters
14.8B
30.4 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors30.1 GB · 98%
From the Hugging Face model README
A QLoRA fine-tuned adapter of Qwen/Qwen2.5-14B-Instruct for extractive question answering over Persian scientific texts. The model is trained on the safora/PersianSciQA-Extractive dataset using Supervised Fine-Tuning (SFT) with the TRL library.
This model is a LoRA adapter designed to answer questions about Persian scientific documents in an extractive manner. Given a scientific context (e.g., a research abstract) and a question in Persian, the model extracts the relevant answer directly from the provided context. When the context does not contain sufficient information to answer the question, the model is trained to respond with CANNOT_ANSWER.
The model is intended for extractive question answering over Persian scientific texts. It can be used to build scientific information retrieval systems, academic research assistants, or Persian-language QA pipelines for the engineering and scientific domains.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
# Quantization config (same as training)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-14B-Instruct",
quantization_config=bnb_config,
device_map="auto",
)
# Load the LoRA adapter
model = PeftModel.from_pretrained(base_model, "safora/PersianSciQA-Qwen2.5-14B")
tokenizer = AutoTokenizer.from_pretrained("safora/PersianSciQA-Qwen2.5-14B")
# Build the prompt
context = "متن علمی فارسی شما اینجا قرار میگیرد..."
question = "سوال شما اینجا قرار میگیرد..."
prompt = (
'شما یک دستیار متخصص در زمینه اسناد علمی هستید. وظیفه شما این است که به سوال پرسیده شده، '
'**فقط و فقط** بر اساس متن زمینه (Context) ارائه شده پاسخ دهید. پاسخ شما باید دقیق و خلاصه باشد.\n\n'
'**دستورالعمل مهم:** اگر اطلاعات لازم برای پاسخ دادن به سوال در متن زمینه وجود ندارد، '
'باید **دقیقا** عبارت "CANNOT_ANSWER" را به عنوان پاسخ بنویسید و هیچ توضیح اضافهای ندهید.\n\n'
f'**زمینه (Context):**\n---\n{context}\n---\n\n'
f'**سوال (Question):**\n{question}\n\n'
'**پاسخ (Answer):**'
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
)
answer = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(answer)
The model was fine-tuned on the safora/PersianSciQA-Extractive dataset. The PersianSciQA dataset is a large-scale resource of question–answer snippet pairs derived from Persian scientific engineering abstracts sourced from IranDoc's Ganj repository. Each sample contains a scientific context, a question, and an extractive answer.
The model was fine-tuned using QLoRA (Quantized Low-Rank Adaptation) with the TRL SFTTrainer.
| Parameter | Value |
|---|---|
| Quantization | 4-bit (NF4) |
| Compute dtype | bfloat16 |
| Double quantization | No |
| Parameter | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Parameter | Value |
|---|---|
| Epochs | 1 |
| Per-device train batch size | 1 |
| Gradient accumulation steps | 8 |
| Effective batch size | 8 |
| Learning rate | 2e-5 |
| LR scheduler | Cosine |
| Warmup ratio | 0.03 |
| Optimizer | paged_adamw_32bit |
| Max gradient norm | 1.0 |
| Precision | bf16 |
| Max sequence length | 1024 |
The model was evaluated on the validation split during training (evaluation at each epoch). A held-out test split is available in the dataset for final evaluation.
CANNOT_ANSWER when the context is insufficient, or may extract incomplete answers.If you use this model, please cite the PersianSciQA dataset paper:
@inproceedings{jolfaei2025persiansciqa,
title={PersianSciQA: A New Dataset for Bridging the Language Gap in Scientific Question Answering},
author={Jolfaei, Safoura Aghadavoud and Mohebi, Azadeh and Hemmat, Zahra},
booktitle={Proceedings of Recent Advances in Natural Language Processing (RANLP)},
pages={32--37},
year={2025},
address={Varna, Bulgaria}
}