Skip to main content

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

Metadata

Release files for quickrag 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quickrag 0.2.1
File Size Uploaded Provenance Actions
quickrag-0.2.1.tar.gz 5.4 kB Without provenance Details for quickrag-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for quickrag 0.2.1
File Interpreter ABI Platform Actions
quickrag-0.2.1-py3-none-any.whl Python 3 none any Details for quickrag-0.2.1-py3-none-any.whl

Total release size: 11.3 kB

Release files / quickrag-0.2.1.tar.gz

Download URL quickrag-0.2.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b574acb0cf93970b31bc498ca7d4b35de323f2c5122180e91b9bcfd020b21cca
BLAKE2b-256 checksum
How to use checksums
821511e0342c0068d4f13e565e9670eaf969b13ee6dda674aadd5cd9d8903c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.4

Release files / quickrag-0.2.1-py3-none-any.whl

Download URL quickrag-0.2.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86e5b039b85cbd1ca4ab82b72b5b88e494d9ad4ad0d8912781db76b8f27173eb
BLAKE2b-256 checksum
How to use checksums
ff9ddd1ee5ef3413ef60690a3be1aeb933a0fc0cb363eea071082c9dad88600e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.4

Security for quickrag 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page