Cosmic Engine

Cosmic Engine is a RAG experimentation platform for comparing 10+ retrieval, chunking, generation, and caching strategies.

Most RAG tools hide retrieval decisions.

Cosmic Engine exposes retrieval, ranking, caching, and generation behavior so you can improve quality with measurable evidence.

All those fine-tuning strategies you found lying around the internet, thanks to the Anthropic blogs, are put into a single place to experiment with.

Retrieval Modes

Cosmic Engine comes packed with retrieval modes that can be toggled per session:

  • Vector Search: Dense embedding retrieval from Milvus.
  • Hybrid Search: BM25 + vector retrieval with rank fusion.
  • RRF Search: Reciprocal Rank Fusion over lexical and dense ranked lists.
  • Query Expansion: Optional LLM-assisted expansion of vague or short queries before retrieval.
  • Query Response Caching: Normalized cache keys based on session, query, attachment set, and retrieval options. Repeated queries can return cached assistant responses quickly.
  • Dynamic Chunk Retrieval Sizing: Top-K automatically adapts to the number of selected attachments. This one's my favourite.
  • And many more.

Retrieval Diagnostics

Per-attachment retrieval timing and diagnostics record:

  • Vector search timing
  • BM25 timing
  • Ranking timing
  • Document hydration timing

This makes it easier to understand where your retrieval pipeline is spending time and how different strategies affect performance.

Business Value Drivers

  • Faster answer discovery from large, unstructured document sets.
  • Lower hallucination risk through retrieval-grounded responses and citation workflows.
  • Better quality tuning through measurable retrieval and generation metrics.
  • Reduced repeated inference costs when caching is enabled.

Production Hardening

For larger commercial rollouts, you would typically want to add:

  • Centralized or distributed queue backend
  • Rate limiting and abuse controls
  • Strong observability and alerting
  • Multi-tenant isolation strategy
  • SSO and audit controls

Tech Stack

Frontend

  • Next.js
  • React
  • TypeScript

Backend API

  • Express 5
  • TypeScript

Ingestion Microservice

  • FastAPI
  • Python
  • MarkItDown

LLMs and Embeddings

  • Google GenAI APIs
  • Bring Your Own API Key

Data

  • Milvus for vector storage
  • PostgreSQL + Prisma for transactional data

Open Source

Cosmic Engine is open source.

Check it out and experiment with the different retrieval strategies:

github.com/arpan-lol/cosmic-engine

Built With

Share this project:

Updates