Hadi - Islamic Assistant (LoRA Adapter for Qwen3-8B)

This repository contains a LoRA adapter fine-tuned on Qwen3-8B to build an Islamic AI assistant named Hadi. The model is designed to be used in RAG (Retrieval-Augmented Generation) systems for providing accurate, context-aware Islamic guidance based on retrieved knowledge.


🧠 Model Overview

  • Base Model: Qwen3-8B
  • Fine-tuning Method: LoRA (Low-Rank Adaptation)
  • LoRA Rank (r): 64
  • Task: Islamic Question Answering / Assistant behavior tuning
  • Assistant Name: Hadi
  • Framework: Hugging Face Transformers + PEFT

πŸ“š Training Dataset

The model was fine-tuned using the following dataset:

πŸ‘‰ Dataset Repository:
Azizkhan22/hadi-islamic-assistant-instruction-dataset

The dataset contains curated Islamic question-answer pairs designed to improve:

  • Quran and Hadith-based responses
  • Ethical and daily life guidance in Islamic context
  • Safe, respectful, and non-extremist responses

βš™οΈ Intended Use

This adapter is designed for use in RAG pipelines, where external knowledge is retrieved and passed to the model.

Typical Workflow:

  1. Retrieve relevant Islamic knowledge from a vector database (FAISS, pgvector, Pinecone, etc.)
  2. Pass retrieved context + user query to the model
  3. Generate grounded responses using Hadi

🧩 How to Load the Adapter

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_name = "Qwen/Qwen3-8B"

model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    device_map="auto",
    torch_dtype="auto"
)

model = PeftModel.from_pretrained(
    model,
    "YOUR_HF_USERNAME/hadi-qwen3-8b-lora"
)

tokenizer = AutoTokenizer.from_pretrained(base_model_name)

πŸ’¬ Example System Prompt (Recommended for Inference)

You are Hadi, an Islamic assistant.
You provide answers based on authentic Islamic teachings and retrieved context when available.
If context is provided, prioritize it. If not, answer cautiously and avoid speculation.
Always remain respectful and avoid extreme or unsupported claims.

🧠 RAG Integration Notes

This model is designed to work well with retrieval systems. Common embedding models used in similar setups include:

  • bge-large
  • e5-large

You can store and retrieve knowledge using:

  • FAISS
  • PostgreSQL + pgvector
  • Pinecone / Weaviate

Always inject retrieved context into the prompt before generation.


⚠️ Limitations

  • This model is not a replacement for qualified Islamic scholarship
  • Always verify answers with authentic scholarly sources
  • May hallucinate if used without proper RAG grounding

πŸ“Œ Citation

If you use this model, please cite:

Hadi: LoRA-adapted Islamic assistant based on Qwen3-8B using PEFT


❀️ Acknowledgements

  • Qwen Team for the base model
  • Hugging Face Transformers & PEFT
  • Open-source Islamic knowledge resources used in dataset construction
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support