--- library_name: transformers license: apache-2.0 datasets: - MohammedNasser/Arabic_Reasoning_Instruct_QA language: - ar base_model: - silma-ai/SILMA-9B-Instruct-v1.0 pipeline_tag: question-answering --- # 🌟 MohammedNaaser/silma_9b_instruct_ft 🌟 [![HF Model Card](https://img.shields.io/badge/Hugging%20Face-Model%20Card-yellow.svg)](https://huggingface.co/MohammedNaaser/silma_9b_instruct_ft) [![Python](https://img.shields.io/badge/Python-3.8%2B-blue.svg)](https://www.python.org/) [![PEFT](https://img.shields.io/badge/PEFT-LoRA-brightgreen.svg)](https://github.com/huggingface/peft) [![RAG](https://img.shields.io/badge/RAG-Retrieval--Augmented%20Generation-orange.svg)](https://huggingface.co/docs/transformers/model_doc/rag) 🚀 **Fine-Tuned Arabic Language Model for Enhanced Reasoning and Instructive Tasks** 🚀 ### 🧠 **Model Overview** Welcome to **`silma_9b_instruct_ft`**, an advanced fine-tuned version of the [SILMA-9B-Instruct](https://huggingface.co/silma-ai/SILMA-9B-Instruct-v1.0), crafted to boost **reasoning capabilities** and **improve response quality** in Arabic-language tasks. This model is tailored for causal language modeling (CAUSAL_LM) and has been optimized using parameter-efficient fine-tuning (PEFT) with LoraConfig. ### 🔧 **Key Features** - **Reasoning Enhancement** 🧩: Fine-tuned specifically for handling complex reasoning tasks in Arabic. - **Efficient & Quantized** 🖥️: Utilizes 4-bit quantization via [BitsAndBytes](https://huggingface.co/docs/transformers/main_classes/quantization), making it resource-friendly with improved memory management. - **PEFT for Efficient Fine-Tuning** 📊: Employs the LoRA (Low-Rank Adaptation) technique for lightweight and effective fine-tuning. - **Customizable Attention** 🎯: Incorporates custom attention modules (`q_proj`, `k_proj`, `v_proj`, etc.) to tailor focus during task processing. --- ## 🎯 **Usage** Here's how to load and start using the model for inference or further fine-tuning: ```python from transformers import AutoTokenizer, AutoModelForCausalLM # Load the tokenizer and model tokenizer = AutoTokenizer.from_pretrained("MohammedNaaser/silma_9b_instruct_ft") model = AutoModelForCausalLM.from_pretrained("MohammedNaaser/silma_9b_instruct_ft") # Example inference input_text = """ في إحدى الألعاب، يربح اللاعب 3 نقاط إذا فاز، ويخسر نقطتين إذا خسر ،ولا يحصل على أي نقاط إذا تعادل. إذا لعب 20 مباراة وانتهى برصيد 15 نقطة، فما أقل عدد من المباريات التي يمكن أن يكون قد فاز بها؟ """" inputs = tokenizer(input_text, return_tensors="pt") outputs = model.generate(**inputs) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` ### 🚀 **Deployment with Hugging Face Spaces and Gradio** Want to deploy your own interactive chat or Q&A system using this model? Check out [Gradio](https://gradio.app) for creating simple UIs! [Create Your Space Here!](https://huggingface.co/spaces/new) --- ## ⚙️ **Training Setup** ### 📝 **Fine-Tuning Parameters** - **Base Model**: [`silma-ai/SILMA-9B-Instruct-v1.0`](https://huggingface.co/silma-ai/SILMA-9B-Instruct-v1.0) - **Trainer**: `SFTTrainer` from [TRL](https://huggingface.co/docs/trl/main/en/sft_trainer) - **Quantization Config**: `BitsAndBytesConfig` (4-bit with `nf4` type) - **LoRA Parameters**: - `lora_alpha`: 16 - `lora_dropout`: 0.1 - `lora_r`: 4 - Target modules: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` ## 🛠️ **File Overview** After saving the fine-tuned model, the following files are generated: - `adapter_config.json`: Configuration file for LoRA adapters. - `adapter_model.safetensor`: Serialized fine-tuned model weights. - `tokenizer.json`, `tokenizer_config.json`: Tokenizer configuration files. - `special_tokens_map.json`: Mapping for special tokens like `[BOS]` and `[EOS]`. - `tokenizer.model`: The model used for tokenization. ## 🔑 **License & Citation** This model is released under the **Apache License**. If you use it in your work, please consider citing the original SILMA model and the fine-tuning method as follows: ``` @misc{MohammedNasser_silma9b_ft, author = {Mohammed Nasser}, title = {Fine-Tuning Arabic Instructive Models with PEFT and LoRA}, year = {2024}, url = {https://huggingface.co/MohammedNaaser/silma_9b_instruct_ft}, } ``` ## 🧑‍💻 **Contributing** Contributions are welcome! If you find any issues or would like to improve this model further, feel free to [open an issue](https://github.com/MohammedNaaser/silma_9b_instruct_ft/issues) or submit a pull request. Let's push the boundaries of Arabic NLP together!