Skip to content

A simple, robust, RAG engine that focuses on speed and performance

License

Notifications You must be signed in to change notification settings

Predixus/DynaRAG

Repository files navigation

Group 6

GitHub Release Discord Widget

A fast, robust, and production-ready RAG backend - so you can focus on the chunks.

Caution

DynaRAG is in a Pre-release state. Full release and stability will arrive soon.

Table of Contents

What is DynaRAG?

DynaRAG is a RAG (Retrieval-Augmented Generation) backend that implements a simple naive approach.

In this way, it is no more complex than the simplest RAG examples that you may find on Haystack or Langchain.

Instead, DynaRAG focuses on providing a highly performant backend for adding, retrieving and filtering text chunks.

DynaRAG does this by pushing the inference and database-query latencies into the parts of the RAG pipeline that yield the lowest round trip time.

Core Features

  • Naive RAG with Go-managed feature extraction models (props to hugot for building awesome go bindings for Onnx)

Core Functionality

DynaRAG provides several key operations through its client interface:

  • Chunk: Add new text chunks with associated metadata and file paths
  • Similar: Find semantically similar chunks using vector similarity search
  • Query: Generate RAG responses by combining relevant chunks with LLM processing
  • PurgeChunks: Remove stored chunks (with optional dry-run)
  • GetStats: Retrieve usage statistics
  • ListChunks: List all stored chunks with their metadata

During initialisation (client.Initialise()), DynaRAG automatically runs database migrations to:

  1. Set up the required PostgreSQL extensions (pgvector)
  2. Create necessary tables for storing embeddings and metadata
  3. Configure indexes for efficient vector similarity search

These migrations ensure your database is properly configured for vector operations and chunk storage with DynaRAG. The migrations are managed using golang-migrate.

Note

The database must be accessible with the provided connection string and the user must have sufficient privileges to create extensions and tables.

Technical Benefits

DynaRAG is written entirely in Go, including feature extraction models interfaced with via the Onnx runtime. This provides several advantages over Python-based approaches:

  • Inherently faster performance, as we can leverage Golangs awesome concurrency model
  • Single binary compilation for easier deployment
  • Generally, better memory safety
  • No performance loss in HTTP layer communication with feature extraction service
  • Strongly typed from the offset
  • Easily slots in to applications that Golang was made for (i.e. servers), without a networking overhead

About Us

DynaRAG is built and maintained by Predixus, an Analytics and Data company based in Cambridge, UK.

Target Users

DynaRAG is ideal for developers or product owners looking to add RAG capabilities to their applications in a lightweight and performant manner. It excels when working with clear text chunks that directly represent potential answers to user questions.

Why DynaRAG?

DynaRAG was developed to address the need for a simple, self-hosted RAG solution for internal and client projects. DynaRAG was born out of our need for a fast, robust and simple RAG backend that didn't break the bank and allowed us to own the inference resources.

The key considerations to the project were:

  • Minimal project footprint
  • Cost-effective implementation
  • Focus on optimal chunking rather than complex retrieval
  • Ability to own inference capability and make the most use of compute resources available

Tip

Focus on the quality of your text chunks when using DynaRAG. If each chunk clearly represents an answer to likely questions, naive RAG becomes highly effective.

Prerequisites

DynaRAG depends on the Onnx runtime to run the embedding pipelines. Ensure that the runtime is present in the default directory (/usr/lib/onnxruntime.so). It can be downloaded from the Microsoft downloads page.

The Go bindings for Huggingface tokenisers is also required. Download it from this repo and place it in the default location /usr/lib/tokenizers.a.

Module Structure

The DynaRAG Go! module is split into several packages:

  • internal/llm - defines code to interface directly with the LLM provider (Groq, Ollama etc.)
  • internal/store - the interface to the PGVector store. The home of the sqlc auto-generated code and the migrations managed by go-migrate
  • internal/embed - the embedding process powered by Hugot
  • internal/rag - code that defines the final summarisation layer, along with system prompts
  • types - globally used types, some of which are used by sqlc during code generation
  • internal/utils - miscellaneous utilities
  • migrations - contains the Postgres migrations required to configure your postgres instance for DynaRAG query.sql defines raw pSQL queries that drive the interactions with the PGVector instance.

Feature Extraction / Embedding

Feature extraction (conversion of the text chunks into vectors) is performed through Hugot via the Onnx runtime.

On inference, the required models will be downloaded from Huggingface and stored in the ./models/ folder. This will only be done once to obtain the relevant .onnx binaries.

License

DynaRAG is licensed under the BSD 3-Clause License. See LICENSE for details.

About

A simple, robust, RAG engine that focuses on speed and performance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published