Mosaic

Documentation

Quick Start

Install

git clone https://github.com/jahidbappi/mosaic-rag
cd mosaic-rag
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Basic usage

from mosaic import MosaicPipeline
from mosaic.eval.datasets import load_sample_corpus
from mosaic.types import Query

pipeline = MosaicPipeline()
pipeline.index(load_sample_corpus())

result = pipeline.retrieve(Query(text="How does hybrid retrieval work?", top_k=5))
answer = pipeline.answer(Query(text="How does hybrid retrieval work?", top_k=5))
print(answer.text)
print(answer.citations)

Run benchmarks

mosaic-benchmark --output benchmarks/results
cat benchmarks/results/leaderboard.json

Components

  • Embeddings: mock-text, mock-multimodal, sentence-transformers, CLIP
  • Retrieval: dense, BM25, hybrid
  • Rerankers: score-fusion, cross-encoder
  • Chunking: fixed-size, semantic