Skip to content

RAG on DuckDB Implementation Based on Prototype #868

Description

@mulla028

Description

Recently, we have implemented a prototype of RAG on DuckDB, and it proves that implementation is doable for the ChatCraft it's time to start working on it!

The implementation will take several steps, lets call them stages. Since we already have the set up of DuckDB using duckdb-wasm, the file loader, and format to text extractors, we are skipping some of the steps(stages). Therefore here are the steps we need to take in order successfully implement it:

Proposed Implementation Stages

  1. Stage 1: Create Two New Tables in IndexedDB
    • Embeddings Table, with foreign key to a file
    • Chunks Table, with foreign key to a file
  2. Stage 2: Implement Chunking Logic
  3. Stage 3: Implement Embeddings Generation
    • Allow using a cloud-based model or local (transformers.js or tensorflow.js)
  4. Stage 4: Vector Search
    • Use DuckDB's extension Called VSS
    • Load Embeddings, Chunks, etc. into DuckDB
    • Apply HNSW Indexing to Increase Speed of the Search ( HNSW Indexing Provided by VSS extension)
  5. Stage 5: LLM Integration
    • Modify Prompt Construction to Include Retrieved Context
    • Implement Source Attribution in Responses
    • Adjust Token Management to Account For Context
  6. Stage 6: Query Processing
    • Implement Embedding Generation for User Queries
    • Use the Same Embedding Model as Documents for Consistency(text-embedding-3-small)

@humphd, @tarasglek please take a look at the proposed implementation stages, and approve them. Let me know if I am missing something :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dbIssues related to database

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions