Skip to main content

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:

  1. Fork the project
  2. Create a feature branch
  3. Implement improvements
  4. Add tests
  5. 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

Muffakir-0.1.1.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Muffakir-0.1.1-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

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

Hashes for Muffakir-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c5d7e425b78bad36657a87391f0b7bafb736198ef39778a528b8cd65d27cbfc3
MD5 8a409787d2608a29780948049f16a6e4
BLAKE2b-256 0653cd5ade532ce0d916748052e140adc0dd7ef0f57f627107df135cef2e93e1

See more details on using hashes here.

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

Hashes for Muffakir-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45cf2fad5c627ea7d3f11de6c734ca240969b3b145c93c064b8d97fad0cc0774
MD5 00be2368e2d19c54d3334895f42132dc
BLAKE2b-256 af67bafdad38b9e62c67ab3071a9345fa0e3591e6b4da127cd2dfc731e806158

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page