Skip to main content

Generate high-quality QA datasets to evaluate RAG systems

Project description

RAGScore Logo

PyPI version Python 3.9+ License

Generate high-quality QA datasets to evaluate your RAG systems


RAGScore automatically generates question-answer pairs from your documents, which you can then use to benchmark and evaluate your RAG (Retrieval-Augmented Generation) systems.

โœจ Features

  • ๐Ÿ“„ Multi-format support - PDF, TXT, Markdown, HTML
  • ๐ŸŒ Multi-language - English and Chinese out of the box
  • ๐Ÿค– Multi-provider - OpenAI, Anthropic, DashScope, Ollama, and more
  • ๐ŸŽฏ Difficulty levels - Easy, medium, and hard questions
  • ๐Ÿš€ Simple CLI - Easy command-line interface
  • ๐Ÿ”’ Privacy-first - No embeddings, no external API calls for document processing
  • โšก Lightweight - Only ~50MB install, no heavy ML dependencies

๐Ÿš€ Quick Start

Installation

# Basic installation (works with any provider)
pip install ragscore

# With specific provider support
pip install ragscore[openai]      # For OpenAI
pip install ragscore[anthropic]   # For Anthropic Claude
pip install ragscore[dashscope]   # For DashScope/Qwen

# All providers
pip install ragscore[all]

Note: On first run, RAGScore automatically downloads required NLTK data (~35MB). This only happens once.

Setup API Key

# Choose your LLM provider:
export OPENAI_API_KEY="sk-..."        # For OpenAI
export ANTHROPIC_API_KEY="sk-ant-..." # For Anthropic Claude
export DASHSCOPE_API_KEY="sk-..."     # For DashScope/Qwen
export GROQ_API_KEY="..."             # For Groq
# ... or any other provider

Generate QA Pairs

# Place documents in data/docs/, then:
ragscore generate --docs-dir YOUR-PDF-DIRECTORY

Output

Generated QA pairs are saved to output/generated_qas.jsonl:

{
  "id": "abc123",
  "question": "What is RAG?",
  "answer": "RAG (Retrieval-Augmented Generation) combines information retrieval with text generation...",
  "difficulty": "easy",
  "source_path": "docs/rag_intro.pdf"
}

๐Ÿ“– Usage

Command Line

# Generate QA pairs from documents
ragscore generate --docs-dir YOUR-PDF-DIRECTORY

# Use custom directory
ragscore generate -d /path/to/docs

Python API

from ragscore import run_pipeline, read_docs, generate_qa_for_chunk

# Run full pipeline
run_pipeline(docs_dir="./my_docs")

# Or use individual components
docs = read_docs(dir_path="./my_docs")
for doc in docs:
    qas = generate_qa_for_chunk(doc["text"], difficulty="medium", n=5)
    print(qas)

โš™๏ธ Configuration

Create a .env file or set environment variables:

# LLM Provider (auto-detected from available API keys)
DASHSCOPE_API_KEY="your-key"  # For DashScope/Qwen
OPENAI_API_KEY="your-key"     # For OpenAI

# Optional: Custom settings
RAGSCORE_CHUNK_SIZE=512
RAGSCORE_QUESTIONS_PER_CHUNK=5

๐Ÿ”Œ Supported LLM Providers

RAGScore works with any LLM provider - use your own API keys!

Provider Models Environment Variable
OpenAI gpt-4o, gpt-4o-mini, gpt-3.5-turbo OPENAI_API_KEY
Anthropic claude-3-opus, claude-3-sonnet, claude-3-haiku ANTHROPIC_API_KEY
Groq llama-3.1-70b, mixtral (ultra fast!) GROQ_API_KEY
Together AI llama-3, mistral, many open models TOGETHER_API_KEY
Grok (xAI) grok-beta XAI_API_KEY
Mistral mistral-large, mistral-medium MISTRAL_API_KEY
DeepSeek deepseek-chat, deepseek-coder DEEPSEEK_API_KEY
DashScope qwen-turbo, qwen-plus, qwen-max DASHSCOPE_API_KEY
Ollama llama2, mistral, codellama (local!) No key needed
Custom Any OpenAI-compatible endpoint LLM_BASE_URL

Using Ollama (Free, Local)

# Install Ollama: https://ollama.ai
ollama pull llama2
ollama serve

# RAGScore auto-detects Ollama
ragscore generate

Using Custom Endpoints

# Any OpenAI-compatible API (vLLM, LocalAI, etc.)
export LLM_BASE_URL="http://localhost:8000/v1"
export LLM_MODEL="my-model"
ragscore generate

๐Ÿ“ Project Structure

ragscore/
โ”œโ”€โ”€ data/docs/          # Place your documents here
โ”œโ”€โ”€ output/             # Generated QA pairs
โ”‚   โ””โ”€โ”€ generated_qas.jsonl
โ””โ”€โ”€ src/ragscore/       # Source code
    โ”œโ”€โ”€ cli.py          # Command-line interface
    โ”œโ”€โ”€ pipeline.py     # Main pipeline
    โ”œโ”€โ”€ data_processing.py  # Document reading & chunking
    โ”œโ”€โ”€ llm.py          # QA generation
    โ””โ”€โ”€ providers/      # Multi-provider LLM support

๐Ÿš€ RAGScore Pro (Coming Soon)

Need to evaluate your RAG system? RAGScore Pro offers:

  • ๐Ÿ” Hallucination Detection - Catch when your RAG makes things up
  • ๐Ÿ“ Citation Quality Scoring - Verify source attribution accuracy
  • ๐Ÿ“Š Multi-dimensional Scoring - Accuracy, relevance, completeness
  • ๐Ÿ“ˆ Executive Reports - Excel reports for stakeholders
  • โšก API Access - Integrate evaluation into your CI/CD

Join the waitlist โ†’

๐Ÿงช Development

# Clone repository
git clone https://github.com/HZYAI/RagScore.git
cd RagScore

# Install with dev dependencies
pip install -e ".[dev,all]"

# Run tests
pytest

# Run linting
ruff check src/
black --check src/

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

๐Ÿ“„ License

Apache 2.0 License - see LICENSE for details.

๐Ÿ”— Links


Made with โค๏ธ for the RAG 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

ragscore-0.3.1.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

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

ragscore-0.3.1-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file ragscore-0.3.1.tar.gz.

File metadata

  • Download URL: ragscore-0.3.1.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ragscore-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7548c62a078cfe5b9e2d2a2a7ac945738c965008e9cd0ac07baa1aebf634e41a
MD5 29592519c94c7c3a1176b18bf8177955
BLAKE2b-256 535935f5f2fc9e4c0c28ac276da075c5a1757cfa5d429b034f4416a98b243efb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragscore-0.3.1.tar.gz:

Publisher: ci.yml on HZYAI/RagScore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ragscore-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ragscore-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ragscore-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce2dc859b75de8dadab1f38b3167a280abdd3c823bd445f63915b8caf481f779
MD5 2c3523d74d197e919ab331870f237ec1
BLAKE2b-256 3a5412616a4bc64a78c10ad496cb941f7da087534c82560f2601826b87c4616f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragscore-0.3.1-py3-none-any.whl:

Publisher: ci.yml on HZYAI/RagScore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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