Question Answering
Transformers
Safetensors
Arabic
lfm2
text-generation
arabic
rag
fine-tuned
Lora
liquid
extractive-qa
Instructions to use azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("question-answering", model="azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA") model = AutoModelForCausalLM.from_pretrained("azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -8,7 +8,7 @@ tags:
|
|
| 8 |
- rag
|
| 9 |
- question-answering
|
| 10 |
- fine-tuned
|
| 11 |
-
-
|
| 12 |
- liquid
|
| 13 |
- extractive-qa
|
| 14 |
datasets:
|
|
@@ -21,19 +21,19 @@ library_name: transformers
|
|
| 21 |
pipeline_tag: question-answering
|
| 22 |
---
|
| 23 |
|
| 24 |
-
# LFM2-1.2B-RAG Arabic (
|
| 25 |
|
| 26 |
-
Fine-tuned version of [LiquidAI/LFM2-1.2B-RAG](https://huggingface.co/LiquidAI/LFM2-1.2B-RAG) for Arabic reading comprehension and question answering tasks using **
|
| 27 |
|
| 28 |
## ๐ Model Description
|
| 29 |
|
| 30 |
-
This model specializes in extractive question answering for Arabic text
|
| 31 |
|
| 32 |
**Key Features:**
|
| 33 |
-
- Optimized for Arabic extractive QA
|
| 34 |
-
- Context-based question answering
|
| 35 |
-
-
|
| 36 |
-
-
|
| 37 |
|
| 38 |
## ๐ฏ Intended Use
|
| 39 |
|
|
@@ -42,21 +42,19 @@ This model specializes in extractive question answering for Arabic text with ada
|
|
| 42 |
- RAG (Retrieval-Augmented Generation) applications for Arabic content
|
| 43 |
- Information extraction from Arabic documents
|
| 44 |
- Educational tools for Arabic reading comprehension
|
| 45 |
-
- Chatbots requiring grounded Arabic responses
|
| 46 |
|
| 47 |
### Downstream Use
|
| 48 |
Can be further fine-tuned for:
|
| 49 |
- Domain-specific QA (medical, legal, financial)
|
| 50 |
- Multi-turn conversational QA
|
| 51 |
-
-
|
| 52 |
-
- Document analysis pipelines
|
| 53 |
|
| 54 |
### Out-of-Scope Use
|
| 55 |
**Not recommended for:**
|
| 56 |
- Open-domain question answering without context
|
| 57 |
-
- Creative writing or
|
| 58 |
-
-
|
| 59 |
-
- Code generation
|
| 60 |
|
| 61 |
## ๐ How to Use
|
| 62 |
|
|
@@ -67,7 +65,7 @@ import torch
|
|
| 67 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 68 |
|
| 69 |
# Load model and tokenizer
|
| 70 |
-
model_id = "azeddinShr/LFM2-1.2B-RAG-ARABIC-
|
| 71 |
model = AutoModelForCausalLM.from_pretrained(
|
| 72 |
model_id,
|
| 73 |
device_map="auto",
|
|
@@ -100,8 +98,8 @@ with torch.no_grad():
|
|
| 100 |
|
| 101 |
answer = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
|
| 102 |
print(answer) # Output: 500 ู
ููุงุฑ ุฏููุงุฑ
|
| 103 |
-
```
|
| 104 |
|
|
|
|
| 105 |
|
| 106 |
## ๐ Training Details
|
| 107 |
|
|
@@ -115,7 +113,7 @@ print(answer) # Output: 500 ู
ููุงุฑ ุฏููุงุฑ
|
|
| 115 |
|
| 116 |
### Training Procedure
|
| 117 |
|
| 118 |
-
**Fine-tuning method:**
|
| 119 |
|
| 120 |
**Hyperparameters:**
|
| 121 |
- **Base model:** LiquidAI/LFM2-1.2B-RAG
|
|
@@ -126,18 +124,9 @@ print(answer) # Output: 500 ู
ููุงุฑ ุฏููุงุฑ
|
|
| 126 |
- **LR scheduler:** Cosine
|
| 127 |
- **Warmup steps:** 50
|
| 128 |
- **Weight decay:** 0.01
|
| 129 |
-
|
| 130 |
-
**AdaLoRA Configuration:**
|
| 131 |
-
- **Initial rank (r):** 16
|
| 132 |
-
- **Target average rank:** 8
|
| 133 |
-
- **Initial adapter rank:** 12
|
| 134 |
- **LoRA alpha:** 32
|
| 135 |
- **LoRA dropout:** 0.05
|
| 136 |
-
- **Pruning start step (tinit):** 10% of total steps
|
| 137 |
-
- **Pruning end step (tfinal):** 70% of total steps
|
| 138 |
-
- **Pruning frequency (deltaT):** 10 steps
|
| 139 |
-
- **Importance smoothing (beta1, beta2):** 0.85
|
| 140 |
-
- **Orthogonality regularization:** 0.5
|
| 141 |
- **Target modules:** w1, w2, w3, q_proj, k_proj, v_proj, out_proj, in_proj
|
| 142 |
|
| 143 |
**Training infrastructure:**
|
|
@@ -145,38 +134,24 @@ print(answer) # Output: 500 ู
ููุงุฑ ุฏููุงุฑ
|
|
| 145 |
- Gradient checkpointing: Enabled
|
| 146 |
- Framework: Hugging Face Transformers + PEFT + TRL
|
| 147 |
|
| 148 |
-
## ๐ Ethical Considerations
|
| 149 |
-
|
| 150 |
-
- This model should not be used to generate misleading information or propaganda
|
| 151 |
-
- Outputs should be fact-checked for critical applications
|
| 152 |
-
- The model reflects statistical patterns in training data and may not represent complete or unbiased knowledge
|
| 153 |
-
- Users are responsible for ensuring appropriate use in their applications
|
| 154 |
-
|
| 155 |
-
## ๐ฌ Technical Details
|
| 156 |
|
| 157 |
-
##
|
| 158 |
-
|
| 159 |
-
AdaLoRA (Adaptive Low-Rank Adaptation) extends LoRA by dynamically allocating parameter budgets across different weight matrices based on their importance during training. This results in:
|
| 160 |
-
- More efficient parameter usage
|
| 161 |
-
- Better performance with fewer trainable parameters
|
| 162 |
-
- Automatic pruning of less important adaptations
|
| 163 |
|
| 164 |
-
|
| 165 |
-
-
|
| 166 |
-
-
|
| 167 |
-
- More stable training dynamics
|
| 168 |
|
| 169 |
## ๐ Citation
|
| 170 |
|
| 171 |
If you use this model in your research or application, please cite:
|
| 172 |
|
| 173 |
```bibtex
|
| 174 |
-
@misc{lfm2-arabic-
|
| 175 |
-
author = {Azeddin
|
| 176 |
-
title = {LFM2-1.2B-RAG Arabic (
|
| 177 |
year = {2025},
|
| 178 |
publisher = {Hugging Face},
|
| 179 |
-
howpublished = {\url{https://huggingface.co/azeddinShr/lfm2-1.2b-arabic-qa-
|
| 180 |
}
|
| 181 |
```
|
| 182 |
|
|
@@ -185,16 +160,11 @@ If you use this model in your research or application, please cite:
|
|
| 185 |
- **Base Model:** [LiquidAI](https://www.liquid.ai/) for LFM2-1.2B-RAG
|
| 186 |
- **Dataset:** [ARCD](https://huggingface.co/datasets/hsseinmz/arcd) - Arabic Reading Comprehension Dataset
|
| 187 |
- **Framework:** Hugging Face Transformers, PEFT, TRL
|
| 188 |
-
- **Method:** AdaLoRA by Zhang et al.
|
| 189 |
|
| 190 |
## ๐ License
|
| 191 |
|
| 192 |
-
|
| 193 |
|
| 194 |
## ๐ง Contact
|
| 195 |
|
| 196 |
For questions, issues, or collaboration opportunities, please open an issue in the model repository or contact via Hugging Face.
|
| 197 |
-
|
| 198 |
-
---
|
| 199 |
-
|
| 200 |
-
**Note:** This is a research model. Always validate outputs for your specific use case and domain.
|
|
|
|
| 8 |
- rag
|
| 9 |
- question-answering
|
| 10 |
- fine-tuned
|
| 11 |
+
- lora
|
| 12 |
- liquid
|
| 13 |
- extractive-qa
|
| 14 |
datasets:
|
|
|
|
| 21 |
pipeline_tag: question-answering
|
| 22 |
---
|
| 23 |
|
| 24 |
+
# LFM2-1.2B-RAG Arabic (LoRA Fine-tuned)
|
| 25 |
|
| 26 |
+
Fine-tuned version of [LiquidAI/LFM2-1.2B-RAG](https://huggingface.co/LiquidAI/LFM2-1.2B-RAG) for Arabic reading comprehension and question answering tasks using **LoRA (Low-Rank Adaptation)** technique.
|
| 27 |
|
| 28 |
## ๐ Model Description
|
| 29 |
|
| 30 |
+
This model specializes in extractive question answering for Arabic text. It has been fine-tuned using LoRA on the Arabic Reading Comprehension Dataset (ARCD) to improve its ability to answer questions based on provided context in Modern Standard Arabic.
|
| 31 |
|
| 32 |
**Key Features:**
|
| 33 |
+
- Optimized for Arabic extractive QA
|
| 34 |
+
- Context-based question answering
|
| 35 |
+
- Maintains faithfulness to source documents
|
| 36 |
+
- Efficient fine-tuning via LoRA (rank=16)
|
| 37 |
|
| 38 |
## ๐ฏ Intended Use
|
| 39 |
|
|
|
|
| 42 |
- RAG (Retrieval-Augmented Generation) applications for Arabic content
|
| 43 |
- Information extraction from Arabic documents
|
| 44 |
- Educational tools for Arabic reading comprehension
|
|
|
|
| 45 |
|
| 46 |
### Downstream Use
|
| 47 |
Can be further fine-tuned for:
|
| 48 |
- Domain-specific QA (medical, legal, financial)
|
| 49 |
- Multi-turn conversational QA
|
| 50 |
+
- Document summarization with Q&A
|
|
|
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
**Not recommended for:**
|
| 54 |
- Open-domain question answering without context
|
| 55 |
+
- Creative writing or content generation
|
| 56 |
+
- Translation tasks
|
| 57 |
+
- Code generation
|
| 58 |
|
| 59 |
## ๐ How to Use
|
| 60 |
|
|
|
|
| 65 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 66 |
|
| 67 |
# Load model and tokenizer
|
| 68 |
+
model_id = "azeddinShr/LFM2-1.2B-RAG-ARABIC-LoRA"
|
| 69 |
model = AutoModelForCausalLM.from_pretrained(
|
| 70 |
model_id,
|
| 71 |
device_map="auto",
|
|
|
|
| 98 |
|
| 99 |
answer = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
|
| 100 |
print(answer) # Output: 500 ู
ููุงุฑ ุฏููุงุฑ
|
|
|
|
| 101 |
|
| 102 |
+
```
|
| 103 |
|
| 104 |
## ๐ Training Details
|
| 105 |
|
|
|
|
| 113 |
|
| 114 |
### Training Procedure
|
| 115 |
|
| 116 |
+
**Fine-tuning method:** LoRA (Low-Rank Adaptation)
|
| 117 |
|
| 118 |
**Hyperparameters:**
|
| 119 |
- **Base model:** LiquidAI/LFM2-1.2B-RAG
|
|
|
|
| 124 |
- **LR scheduler:** Cosine
|
| 125 |
- **Warmup steps:** 50
|
| 126 |
- **Weight decay:** 0.01
|
| 127 |
+
- **LoRA rank (r):** 16
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
- **LoRA alpha:** 32
|
| 129 |
- **LoRA dropout:** 0.05
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
- **Target modules:** w1, w2, w3, q_proj, k_proj, v_proj, out_proj, in_proj
|
| 131 |
|
| 132 |
**Training infrastructure:**
|
|
|
|
| 134 |
- Gradient checkpointing: Enabled
|
| 135 |
- Framework: Hugging Face Transformers + PEFT + TRL
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
+
## ๐ Ethical Considerations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
- This model should not be used for generating misleading or false information
|
| 141 |
+
- Users should verify factual claims, especially for sensitive topics
|
| 142 |
+
- The model's responses reflect patterns in training data and may not represent complete or unbiased information
|
|
|
|
| 143 |
|
| 144 |
## ๐ Citation
|
| 145 |
|
| 146 |
If you use this model in your research or application, please cite:
|
| 147 |
|
| 148 |
```bibtex
|
| 149 |
+
@misc{lfm2-rag-arabic-lora,
|
| 150 |
+
author = {Azeddin sahir},
|
| 151 |
+
title = {LFM2-1.2B-RAG Arabic (LoRA Fine-tuned)},
|
| 152 |
year = {2025},
|
| 153 |
publisher = {Hugging Face},
|
| 154 |
+
howpublished = {\url{https://huggingface.co/azeddinShr/lfm2-1.2b-arabic-qa-lora}}
|
| 155 |
}
|
| 156 |
```
|
| 157 |
|
|
|
|
| 160 |
- **Base Model:** [LiquidAI](https://www.liquid.ai/) for LFM2-1.2B-RAG
|
| 161 |
- **Dataset:** [ARCD](https://huggingface.co/datasets/hsseinmz/arcd) - Arabic Reading Comprehension Dataset
|
| 162 |
- **Framework:** Hugging Face Transformers, PEFT, TRL
|
|
|
|
| 163 |
|
| 164 |
## ๐ License
|
| 165 |
|
| 166 |
+
Same as based model
|
| 167 |
|
| 168 |
## ๐ง Contact
|
| 169 |
|
| 170 |
For questions, issues, or collaboration opportunities, please open an issue in the model repository or contact via Hugging Face.
|
|
|
|
|
|
|
|
|
|
|
|