Skip to main content

A Quick Retrieval-Augmented Generation (RAG) system using transformers.

Project description

QuickRAG

QuickRAG is a Python library that implements a Retrieval-Augmented Generation (RAG) pipeline for question answering on PDF documents. It combines document processing, embedding generation, and language model inference to provide context-aware answers to user queries.

Features

  • PDF processing and text extraction
  • Text chunking and embedding generation
  • Efficient similarity search for relevant context retrieval
  • Integration with Hugging Face Transformers for language model inference
  • Support for quantization to optimize memory usage and inference speed

Installation

pip install quickrag

Usage

Here's a basic example of how to use QuickRAG:

from quickrag import QuickRAG

# Initialize QuickRAG
rag = QuickRAG("path/to/your/document.pdf", huggingface_token="YOUR_HUGGINGFACE_TOKEN")

# Process the PDF and create embeddings
rag.process_pdf()
rag.create_embeddings()

# Load the language model
rag.load_llm()

# Ask a question
query = "What are the macronutrients, and what roles do they play in the human body?"
answer = rag.ask(query)

print(f"Query: {query}")
print(f"Answer: {answer}")

Configuration

QuickRAG can be customized with the following parameters:

  • pdf_path: Path to the PDF document
  • embedding_model_name: Name of the sentence transformer model for embeddings (default: "all-mpnet-base-v2")
  • llm_model_name: Name of the language model for answer generation (default: "google/gemma-2b-it")
  • use_quantization: Whether to use quantization for the language model (default: True)
  • huggingface_token: Your Hugging Face API token

Requirements

  • Python 3.7+
  • PyTorch
  • Transformers
  • Sentence-Transformers
  • PyMuPDF
  • spaCy
  • NumPy
  • Pandas

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

  • Hugging Face for their Transformers library
  • Sentence-Transformers for the embedding models
  • PyMuPDF for PDF processing

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

quickrag-0.1.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

quickrag-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file quickrag-0.1.2.tar.gz.

File metadata

  • Download URL: quickrag-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.4

File hashes

Hashes for quickrag-0.1.2.tar.gz
Algorithm Hash digest
SHA256 119a1890c0c25be75e31750bfb41d8ce5a47769c6b69582e05aa16160cf8114c
MD5 901f7831406b3fe8276c4f4ef44e8c48
BLAKE2b-256 b34eaa1b8409c7f97894adb3cca186b4e5bae6b01c0ebf5a907584d7d5c74671

See more details on using hashes here.

File details

Details for the file quickrag-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: quickrag-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.4

File hashes

Hashes for quickrag-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3e08bd2e472f444185a0943f11ea5025142bb0f8036cc02707de14154a6d0f
MD5 53689a28056de6688d59ebd8e2788f22
BLAKE2b-256 9bb0e60cd496515e09fcd7b8cd3920b33a0604c3b4c15d0fc920b749a012b3e9

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