Skip to main content

🧱 ragbt

"dbt for RAG" — declarative, incremental, tested embedding pipelines

PyPI Python License


The Problem

Building RAG pipelines today means writing bespoke scripts that:

  • Re-embed everything on every run — slow and expensive
  • Have no tests — you only find out your retrieval is broken in production
  • Are impossible to diff or review in PRs

ragbt brings the dbt workflow — declarative configs, incremental builds, tests, and lineage — to embedding pipelines.


✨ Features

Feature What it means
🔄 Incremental runs Content-hash based; only changed docs get re-embedded
🧪 Retrieval tests Assert that queries return the right docs before shipping
📊 Lineage & manifest Lineage from source → chunks → vectors
🎯 Multi-target Isolated dev / prod environments
🔌 Pluggable Swappable chunkers, embedders, and vector stores
⚡ Fast HNSW index on pgvector for sub-second search

🚀 Quick Start

1. Install

pip install ragbt

Requires Python 3.10+ and a Postgres database with the pgvector extension.

2. Set environment variables

export RAGBT_DATABASE_URL="postgresql+asyncpg://user:pass@host:5432/db"
export VOYAGE_API_KEY="your-api-key"
# or OPENAI_API_KEY="your-key"

3. Scaffold a project

ragbt init my_rag_project
cd my_rag_project

4. Add your docs

Drop Markdown or text files into data/product_docs/.

5. Run incrementally

ragbt run

Only changed documents are re-chunked and re-embedded. Subsequent runs are near-instant.

6. Test retrieval quality

ragbt test

Fails CI if your expected docs don't surface for key queries.

7. Generate lineage

ragbt docs generate
ragbt ls

📁 Project Structure

my_rag_project/
├── ragbt_project.yml          # Project metadata
├── sources.yml                # Where raw content lives
├── models/
│   └── product_docs.yml       # Chunking + embedding strategy
├── tests/
│   └── retrieval_tests.yml    # Quality assertions
├── data/
│   └── product_docs/          # Your raw docs
└── manifest.json              # Generated lineage graph

🛠️ Configuration

sources.yml — define content sources

sources:
  - name: product_docs
    type: directory
    path: ./data/product_docs
    file_types: [md, txt]

models/product_docs.yml — declare chunking & embedding

models:
  - name: product_docs_chunks
    source: product_docs
    description: "Customer-facing product documentation"

    chunking:
      strategy: recursive
      chunk_size: 512
      chunk_overlap: 50

    embedding:
      provider: voyage
      model: voyage-3
      dimensions: 1024
      batch_size: 100

    materialization: incremental
    index:
      backend: pgvector
      table: product_docs_vectors
      distance: cosine

tests/retrieval_tests.yml — gate your pipeline

tests:
  - name: refund_policy_findable
    model: product_docs_chunks
    query: "what is your refund policy"
    expect:
      top_k: 5
      must_contain_doc: "refund-policy.md"
      min_score: 0.75

  - name: no_orphaned_chunks
    model: product_docs_chunks
    type: integrity

🖥️ CLI Reference

Command Description
ragbt init [name] Scaffold a new project
ragbt run Incremental run (default)
ragbt run --full-refresh Force re-process everything
ragbt run --target prod Run against the prod index
ragbt test Run retrieval assertions
ragbt docs generate Build manifest.json + lineage graph
ragbt ls List models and last-run status

✅ Supported in v0.1

Component Supported
Sources directory (local files)
Chunkers recursive, markdown
Embedders voyage, openai
Vector Stores pgvector (Postgres + pgvector)
Distance Metrics cosine, euclidean, dot
Tests retrieval, integrity, freshness

🗺️ Roadmap

Feature Status Target
semantic chunker Planned v0.2
cohere embedder Planned v0.2
pinecone / weaviate vector stores Planned v0.2
ragbt plan — dry-run preview Planned v0.2
ragbt diff — changed files report Planned v0.2
DAG with ref() between models Planned v0.3
Retrieval metrics (MRR, HitRate) Planned v0.3
Automatic RAGBT PR checks Planned v0.3
GitHub Actions CI ✓ Available v0.1
RAGBT Cloud dashboard Future v1.0

🏗️ Architecture

sources.yml ──▶ config loader (Pydantic)
                      │
                      ▼
              ┌───────────────┐
              │  state store   │  (Postgres: doc hashes, run history)
              └───────┬───────┘
                      │ diff: what changed?
                      ▼
              ┌───────────────┐
              │  chunker       │  recursive | markdown
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │  embedder      │  voyage | openai
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │  vector store  │  pgvector
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │  test runner   │  golden query → expected chunk assertions
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │  manifest/docs │  lineage graph, freshness, run history
              └───────────────┘

Core Concepts vs dbt

dbt concept ragbt equivalent
sources.yml sources.yml — where raw content lives
models/*.sql models/*.yml — declared chunking + embedding strategy
Incremental models Content-hash based incremental runs
dbt test ragbt test — retrieval assertions
dbt docs generate ragbt docs generate — lineage graph
target: dev / target: prod --target flag — separate indexes
manifest.json manifest.json — lineage metadata + run state
Jinja macros Python plugin functions for custom chunkers/embedders

🧪 Development

git clone https://github.com/shivamim/ragbt.git
cd ragbt
pip install -e ".[dev]"
pytest

🐳 Docker

docker-compose up -d postgres
ragbt init demo && cd demo
ragbt run
ragbt test

📜 License

Apache License 2.0 — see LICENSE.


Built with ❤️ by Shivam Shukla

Metadata

Release files for ragbt 0.1.0

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

Source distribution (sdist)

Source distribution for ragbt 0.1.0
File Size Uploaded Provenance Actions
ragbt-0.1.0.tar.gz 25.6 kB Without provenance Details for ragbt-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 56.1 kB

Release files / ragbt-0.1.0.tar.gz

Download URL ragbt-0.1.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c669209d89be341c232feaf0ca364b334cbfb4249a0f7999405d6e9398c0e09f
BLAKE2b-256 checksum
How to use checksums
e7395ebadd4fa604fc46b3879cb7c259f3a84f875c3a07e859d053d2b3d74a4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / ragbt-0.1.0-py3-none-any.whl

Download URL ragbt-0.1.0-py3-none-any.whl
Size 30.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd20b8d9e3574b5305c790e2802f063f675239b80e7278cff17cd386676053b5
BLAKE2b-256 checksum
How to use checksums
149f9b424e734cd50b45d992f2f39b9f543081a6f04febdeec1666846f50dfd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for ragbt 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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