Generate high-quality QA datasets to evaluate RAG systems
Project description
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
๐งช 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
Release history Release notifications | RSS feed
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 ragscore-0.2.2.tar.gz.
File metadata
- Download URL: ragscore-0.2.2.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fec531420b70b65e7fb155c8d896683175fa5256f580c5ba50df987d5cbbae3
|
|
| MD5 |
da07290bcb07760aa5f27975cfcf5dac
|
|
| BLAKE2b-256 |
83f26473b9e4073679a304bc2128bd968bd10d844071e2799f933228b29c025f
|
Provenance
The following attestation bundles were made for ragscore-0.2.2.tar.gz:
Publisher:
ci.yml on HZYAI/RagScore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragscore-0.2.2.tar.gz -
Subject digest:
4fec531420b70b65e7fb155c8d896683175fa5256f580c5ba50df987d5cbbae3 - Sigstore transparency entry: 780291208
- Sigstore integration time:
-
Permalink:
HZYAI/RagScore@b2653b5bb00b26fa106decc30b75641b5d3d72fa -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/HZYAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b2653b5bb00b26fa106decc30b75641b5d3d72fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file ragscore-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ragscore-0.2.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0463f73858a7eabf66a327006419d6810d9cac55bc41d7f7b4896aa25d796340
|
|
| MD5 |
0df5830d327ba81389cfd3cfedd162ab
|
|
| BLAKE2b-256 |
4a62b44233529b5db721af9baf41eece416e1d6ceb4892443a0a4b787a7ebabb
|
Provenance
The following attestation bundles were made for ragscore-0.2.2-py3-none-any.whl:
Publisher:
ci.yml on HZYAI/RagScore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragscore-0.2.2-py3-none-any.whl -
Subject digest:
0463f73858a7eabf66a327006419d6810d9cac55bc41d7f7b4896aa25d796340 - Sigstore transparency entry: 780291220
- Sigstore integration time:
-
Permalink:
HZYAI/RagScore@b2653b5bb00b26fa106decc30b75641b5d3d72fa -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/HZYAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b2653b5bb00b26fa106decc30b75641b5d3d72fa -
Trigger Event:
push
-
Statement type: