Arabic Retrieval-Augmented Generation Library
Project description
๐ง Muffakir RAG
Advanced Arabic RAG (Retrieval-Augmented Generation) Library
Muffakir RAG is a sophisticated Python library for building Arabic-focused Retrieval-Augmented Generation (RAG) systems. It provides intelligent solutions for document processing, semantic search, and answer generation.
โจ Key Features
- ๐ Arabic Language Focus: Optimized specifically for Arabic texts
- ๐ค Multi-Provider Support: Together AI, OpenAI, Groq
- ๐ Advanced Document Processing: PDF, DOCX, TXT with OCR support
- ๐ Smart Retrieval: Multiple retrieval methods with reranking
- โก Easy-to-Use API: Simple and intuitive interface
- ๐ก๏ธ Hallucination Check: Answer validation system
- ๐ Query Transformation: Automatic query optimization
- ๐ Reranker: Automatic Reranker
๐ Installation
pip install muffakir-rag
For development:
git clone https://github.com/yourusername/muffakir-rag.git
cd muffakir-rag
pip install -e .
๐ Quick Start
from Muffakir import MuffakirRAG
# Configuration
config = {
"data_dir": "path/to/your/documents",
"llm_provider": "together",
"api_key": "your_api_key_here",
"embedding_model": "mohamed2811/Muffakir_Embedding",
"k": 5,
"query_transformer": True,
"hallucination_check": True,
"reranking": True
}
# Initialize system
rag = MuffakirRAG(config)
# Ask questions
response = rag.ask("What is the definition of artificial intelligence?")
print(response["answer"])
๐ง Detailed Configuration
Core Parameters
| Parameter | Description | Default |
|---|---|---|
data_dir |
Documents directory | Required |
api_key |
API key | Required |
llm_provider |
LLM provider | "together" |
embedding_model |
Embedding model | "mohamed2811/Muffakir_Embedding" |
Advanced Parameters
config = {
# Basics
"data_dir": "documents/",
"api_key": "your_key",
"llm_provider": "together",
# LLM Settings
"llm_model": "meta-llama/Llama-3.3-70B-Instruct-Turbo-Free",
"llm_temperature": 0.0,
"llm_max_tokens": 1000,
# Text Processing
"chunk_size": 600,
"chunk_overlap": 200,
"chunking_method": "recursive",
# Retrieval
"retrieval_method": "max_marginal_relevance",
"k": 5,
"fetch_k": 15,
# Features
"query_transformer": True,
"hallucination_check": True,
"reranking": True,
"reranking_method": "semantic_similarity"
}
๐ฏ Advanced Examples
Document Search
# Find similar documents
similar_docs = rag.get_similar_documents(
query="Artificial Intelligence",
k=3,
method="similarity_search"
)
for doc in similar_docs:
print(f"Source: {doc.metadata.get('source', 'N/A')}")
print(f"Content: {doc.page_content[:200]}...")
Adding New Documents
# Add new documents
new_documents = ["path/to/new/doc1.pdf", "path/to/new/doc2.docx"]
success = rag.add_documents(new_documents)
if success:
print("Documents added successfully!")
Custom Parameters
response = rag.ask(
"Your question here",
k=10, # Retrieve 10 documents instead of 5
retrieval_method="hybrid", # Use hybrid search
temperature=0.3 # Increase answer creativity
)
๐๏ธ Project Structure
muffakir-rag/
โโโ Muffakir/ # Core component
โโโ TextProcessor/ # Text processing
โโโ LLMProvider/ # LLM providers
โโโ Embedding/ # Text embedding
โโโ Generation/ # Answer generation
โโโ VectorDB/ # Vector database
โโโ Reranker/ # Reranking
โโโ RAGPipeline/ # Pipeline management
โโโ PromptManager/ # Template management
โโโ QueryTransformer/ # Query transformation
๐ Supported Providers
- Together AI:
together - OpenAI:
openai - Groq:
groq - Open Router:
open_router
๐ Supported File Types
- ๐ PDF: With OCR support for scanned texts
- ๐ DOCX: Microsoft Word documents
- ๐ TXT: Plain text files
- ๐ผ๏ธ Images: With Azure Computer Vision OCR
๐ Performance Metrics
- โก Speed: Fast processing of large documents
- ๐ฏ Accuracy: Optimized results for Arabic texts
- ๐พ Memory: Efficient resource usage
- ๐ Scalability: Supports thousands of documents
๐ค Contributing
I welcome contributions! Please follow these steps:
- Fork the project
- Create a feature branch
- Implement improvements
- Add tests
- Submit Pull Request
Built with โค๏ธ for the Arabic community
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Muffakir-0.1.1.tar.gz.
File metadata
- Download URL: Muffakir-0.1.1.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5d7e425b78bad36657a87391f0b7bafb736198ef39778a528b8cd65d27cbfc3
|
|
| MD5 |
8a409787d2608a29780948049f16a6e4
|
|
| BLAKE2b-256 |
0653cd5ade532ce0d916748052e140adc0dd7ef0f57f627107df135cef2e93e1
|
File details
Details for the file Muffakir-0.1.1-py3-none-any.whl.
File metadata
- Download URL: Muffakir-0.1.1-py3-none-any.whl
- Upload date:
- Size: 28.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45cf2fad5c627ea7d3f11de6c734ca240969b3b145c93c064b8d97fad0cc0774
|
|
| MD5 |
00be2368e2d19c54d3334895f42132dc
|
|
| BLAKE2b-256 |
af67bafdad38b9e62c67ab3071a9345fa0e3591e6b4da127cd2dfc731e806158
|