Skip to content

About

Production-oriented RAG backend featuring asynchronous document processing, semantic search, hybrid retrieval, and AI-powered question answering.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Talk2Docs

A production-oriented AI document intelligence and agentic conversational backend built with FastAPI, Celery, Docling, LangChain, ChromaDB, PostgreSQL, Redis, and multiple AI-driven retrieval and memory systems.

Python FastAPI PostgreSQL SQLAlchemy Redis Celery ChromaDB Cohere Nginx MIT License


🧠 What is Talk2Docs?

Talk2Docs is an asynchronous, user-isolated document intelligence platform that turns uploaded documents into searchable knowledge and provides grounded AI answers.

It started as a document-processing and RAG backend and evolved into a larger AI system containing:

  • Structure-aware document processing
  • Multi-index RAG
  • Hybrid vector + BM25 retrieval
  • Adaptive query transformation
  • AI reranking
  • Structured source-grounded answers
  • Three-tier semantic caching
  • Stateful conversations
  • Short-term conversational context
  • Current-session semantic memory
  • Cross-session semantic memory
  • Agentic tool selection
  • Web search
  • Document QA as an internal AI tool
  • General intent classification as an internal AI tool
  • Asynchronous background processing
  • User-isolated storage and retrieval

The system therefore contains two major AI paths:

                    TALK2DOCS
                        β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                   β”‚
              β–Ό                   β–Ό
        DOCUMENT QA          CONVO AI
              β”‚                   β”‚
              β–Ό                   β–Ό
       Advanced RAG          Agentic AI
              β”‚                   β”‚
              β–Ό                   β–Ό
       Grounded Answers     Tools + Memory

✨ Highlights

Document Intelligence System

  • Asynchronous document ingestion
  • Docling document parsing
  • Structure-aware HybridChunker
  • Raw / Summary / Explanation representations
  • Per-user ChromaDB storage
  • Persistent document lifecycle tracking
  • File type, MIME, size and signature validation

Advanced RAG

  • Vector retrieval
  • BM25 lexical retrieval
  • Hybrid retrieval
  • Reciprocal Rank Fusion
  • Multi-Query
  • HyDE
  • Step-Back prompting
  • Advanced query translation
  • Query decomposition
  • Multi-index retrieval
  • Cohere encoder reranking
  • Source-grounded structured responses

Three-Tier Caching

  • T1 exact Redis cache
  • T2 semantic Redis vector cache
  • T3 persistent ChromaDB semantic cache
  • Cohere reranking for T3
  • Source-version validation
  • Asynchronous cache population
  • Different cache behavior for AnswerAI and ConvoAI

Agentic Conversational AI

ConvoAI can dynamically use:

  • AnswerAI document search
  • Current-session semantic memory
  • Global semantic memory
  • Web search
  • General intent classification

The model decides which tools are required while the application controls the execution loop and tool plumbing.

Infrastructure

  • FastAPI
  • Async SQLAlchemy
  • PostgreSQL
  • Redis
  • Celery
  • Nginx
  • SlowAPI
  • JWT authentication
  • Structured logging
  • Centralized exception handling

πŸ—οΈ High-Level Architecture

Talk2Docs separates the HTTP lifecycle from expensive AI and document-processing workloads.

                              CLIENT
                                β”‚
                                β–Ό
                             NGINX
                                β”‚
                                β–Ό
                            FASTAPI
                                β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                 β”‚                 β”‚
              β–Ό                 β–Ό                 β–Ό
        Authentication      Validation       Rate Limiting
              β”‚                 β”‚                 β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                         Service Layer
                                β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚                             β”‚
                 β–Ό                             β–Ό
           Document Flow                 Question Flow
                 β”‚                             β”‚
                 β–Ό                             β–Ό
              Celery                    Cache / ConvoAI
                 β”‚                             β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚        β”‚        β”‚          β”‚                  β”‚
        β–Ό        β–Ό        β–Ό          β–Ό                  β–Ό
     Docling   BM25   Multi-Index  AnswerAI          ConvoAI
        β”‚        β”‚        β”‚          β”‚                  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚            β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”
                 β”‚                  β”‚             β”‚     β”‚     β”‚
                 β–Ό                  β”‚            LTM  Web   Classifier
             ChromaDB β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β–Ό
             PostgreSQL

The architecture follows a thin-route approach:

Route
  ↓
Service
  ↓
AI / Retrieval / Worker Logic
  ↓
APIResponse
  ↓
Centralized Response / Exception Handling

πŸ“„ Document Ingestion

The document pipeline is asynchronous.

User Upload
     β”‚
     β–Ό
FastAPI Route
     β”‚
     β–Ό
Authentication
     β”‚
     β–Ό
File Validation
     β”‚
     β”œβ”€β”€ Filename
     β”œβ”€β”€ Extension
     β”œβ”€β”€ MIME Type
     β”œβ”€β”€ Size
     β”œβ”€β”€ Content
     └── File Signature
     β”‚
     β–Ό
Validated File
     β”‚
     β–Ό
Persistent Storage
     β”‚
     β–Ό
PostgreSQL Document Record
     β”‚
     β–Ό
Celery Task
     β”‚
     β–Ό
Docling Parsing
     β”‚
     β–Ό
HybridChunker
     β”‚
     β–Ό
Raw Chunks
     β”‚
     β–Ό
Embedding Generation
     β”‚
     β–Ό
RAW VDB
     β”‚
     β–Ό
Document = READY
     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β–Ό                      β–Ό
Summary Worker       Explanation Worker
     β”‚                      β”‚
     β–Ό                      β–Ό
SUMMARY VDB          EXPLANATION VDB

The HTTP request does not wait for expensive parsing, chunking and embedding operations.

Instead, background workers process the document and maintain persistent lifecycle state in PostgreSQL.


πŸ” File Validation

Files are validated before entering the processing pipeline.

Validation includes:

  • Filename validation
  • Extension validation
  • MIME type validation
  • Maximum file size
  • File-content validation
  • Signature / magic-byte validation where applicable
  • Authentication
  • User ownership

The system does not rely solely on:

document.pdf

or:

application/pdf

when actual file-content validation is required.


βš™οΈ Celery Worker Architecture

Talk2Docs uses Celery to isolate expensive background operations from HTTP requests.

The system contains workers for operations such as:

  • Document ingestion
  • Parsing
  • Embedding
  • Summary generation
  • Explanation generation
  • BM25 construction
  • Cache population
  • Vector-cache population
  • Other AI/background operations

Conceptually:

FastAPI
   β”‚
   β–Ό
Celery Queue
   β”‚
   β”œβ”€β”€ Ingestion
   β”œβ”€β”€ Embeddings
   β”œβ”€β”€ BM25
   β”œβ”€β”€ Multi-Index
   β”œβ”€β”€ Cache
   └── AI Operations

Workers communicate using serializable payloads rather than passing ORM objects between processes.

This keeps worker execution independent from SQLAlchemy session state.


🧠 Multi-Index Document Architecture

Talk2Docs maintains multiple representations of the same document knowledge.

                         RAW CHUNKS
                             β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚            β”‚            β”‚
                β–Ό            β–Ό            β–Ό
             RAW VDB     SUMMARY VDB  EXPLANATION VDB
                β”‚            β”‚            β”‚
                β”‚            β”‚            β”‚
           Original       Summary       Explanation
            Content      Representation Representation

Each raw chunk maintains a shared chunk_id.

Conceptually:

Raw Chunk
   β”‚
   β”œβ”€β”€ chunk_id = document_id_0
   β”‚
   β”œβ”€β”€ Summary Representation
   β”‚
   └── Explanation Representation

This allows secondary representations to improve retrieval while still resolving results back to the original raw chunk.


πŸ”Ž Hybrid Retrieval

Talk2Docs combines semantic and lexical retrieval.

                    USER QUESTION
                         β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                 β”‚
                β–Ό                 β–Ό
         Vector Retrieval      BM25
                β”‚                 β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
                 Ensemble Retrieval
                         β”‚
                         β–Ό
                Reciprocal Rank Fusion
                         β”‚
                         β–Ό
                Candidate Documents
                         β”‚
                         β–Ό
                    Reranking

Vector Retrieval

Captures semantic similarity.

Useful when the question and document express the same idea using different wording.

BM25

Captures lexical relevance.

Useful for:

  • Exact terminology
  • Names
  • Identifiers
  • Uncommon phrases
  • Keyword-heavy questions

The two signals provide:

Semantic Understanding
        +
Lexical Precision

⚑ Global BM25 Architecture

BM25 requires corpus-level statistics.

Rebuilding a user-wide BM25 index from scratch for every query would be wasteful.

Talk2Docs therefore maintains a persistent user-scoped BM25 resource.

User
 β”‚
 β”œβ”€β”€ Raw VDB
 β”‚    β”œβ”€β”€ Document A
 β”‚    β”œβ”€β”€ Document B
 β”‚    └── Document C
 β”‚
 └── Global BM25
      β”œβ”€β”€ Document A chunks
      β”œβ”€β”€ Document B chunks
      └── Document C chunks

The BM25 resource is versioned and persisted.

Redis can be used for the active cached retriever while persistent pickle artifacts provide a durable fallback.

Conceptually:

New Document
     β”‚
     β–Ό
Update Corpus
     β”‚
     β–Ό
Build BM25
     β”‚
     β–Ό
Versioned Artifact
     β”‚
     β–Ό
Redis Cache

🧭 Adaptive Query Intelligence

For document questions, Talk2Docs does not blindly execute a single retrieval strategy.

The query can be transformed using techniques such as:

User Question
      β”‚
      β–Ό
Query / Intent Classification
      β”‚
      β”œβ”€β”€ NONE
      β”œβ”€β”€ MULTI_QUERY
      β”œβ”€β”€ HYDE
      β”œβ”€β”€ STEP_BACK
      β”œβ”€β”€ ADVANCED_TRANSLATION
      β”œβ”€β”€ QUERY_DECOMPOSITION
      └── MULTI_INDEXING
      β”‚
      β–Ό
Retrieval
      β”‚
      β–Ό
Reranking
      β”‚
      β–Ό
AnswerAI

Retrieval Techniques

Technique Purpose
Multi-Query Generates multiple query formulations to improve recall
HyDE Uses a hypothetical semantic representation for retrieval
Step-Back Retrieves using a broader conceptual question
Advanced Translation Converts the question into retrieval-oriented representations
Query Decomposition Splits complex questions into independently retrievable sub-questions
Multi-Index Searches Raw, Summary and Explanation representations

🎯 Common Retrieval Contract

Different retrieval techniques can have completely different internal implementations.

However, Talk2Docs deliberately normalizes their output to:

list[LangChainDocument]

Therefore:

Multi-Query
HyDE
Step-Back
Translation
Decomposition
Multi-Index
Hybrid Retrieval
        β”‚
        β–Ό
list[LangChainDocument]
        β”‚
        β–Ό
Reranking
        β”‚
        β–Ό
AnswerAI

This creates a stable boundary between retrieval and downstream answer generation.

The retrieval system can evolve without requiring AnswerAI to understand every retrieval implementation.


🎯 AI Reranking

Retrieval is optimized for recall.

Reranking improves precision.

Retriever
   β”‚
   β–Ό
Candidate Documents
   β”‚
   β–Ό
Cohere Encoder Reranker
   β”‚
   β”œβ”€β”€ Candidate 1 β†’ score
   β”œβ”€β”€ Candidate 2 β†’ score
   β”œβ”€β”€ Candidate 3 β†’ score
   └── ...
   β”‚
   β–Ό
Sorted Candidates
   β”‚
   β–Ό
Top-K

Talk2Docs validates reranker output before using it.

Validation includes:

  • Schema correctness
  • Candidate identity
  • Candidate uniqueness
  • Candidate completeness
  • Score validation
  • Ranking validation

πŸ€– AnswerAI

AnswerAI is the primary document-grounded answer generation system.

It receives retrieved document context and produces structured output.

User Question
      β”‚
      β–Ό
Cache
      β”‚
      β”œβ”€β”€ HIT ──────────────► Cached Answer
      β”‚
      β–Ό
Query Classification
      β”‚
      β–Ό
Retrieval Strategy
      β”‚
      β–Ό
Hybrid / Multi-Index Retrieval
      β”‚
      β–Ό
Cohere Reranking
      β”‚
      β–Ό
Top-K Context
      β”‚
      β–Ό
AnswerAI
      β”‚
      β–Ό
Structured Grounded Response

A simplified response structure contains:

class AnswerModel(BaseModel):
    answer: str
    topic: ShortTopicStr
    citations: list[LocationCitation]
    answer_summary: str
    confidence_score: float
    is_meaning_preserved: bool

The result is intended to be:

Human-readable
+
Machine-readable
+
Source-grounded
+
Citation-aware
+
Confidence-aware

⚑ Three-Tier Cache Architecture

Talk2Docs uses a three-tier cache architecture for document-answer workloads.

The architecture was originally developed as part of Talk2Docs and was later extracted into a reusable standalone project:

TriCacheLLM-MMA: https://github.com/mohib-ash/TriCacheLLM_MMA

Origin note: Talk2Docs currently uses the initial version of TriCacheLLM-MMA. The standalone project exists to generalize and evolve the caching architecture beyond Talk2Docs.

                    Incoming Question
                           β”‚
                           β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚ T1 Exact Redis  β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    MISS   β”‚   HIT
                           β”‚    └────────────► Response
                           β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚ T2 Semantic     β”‚
                  β”‚ Redis Vector    β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    MISS   β”‚   HIT
                           β”‚    └────────────► Response
                           β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚ T3 Persistent   β”‚
                  β”‚ Chroma + Cohere β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    MISS   β”‚   HIT
                           β”‚    └────────────► Response
                           β–Ό
                       AI Pipeline

Tier 1: Exact Cache

Redis stores exact request responses.

Purpose:

  • Duplicate request protection
  • Very fast repeated requests
  • Double-click/retry protection
  • Avoiding unnecessary AI execution for identical requests

Tier 2: Semantic Redis Cache

The question is embedded and searched using a Redis vector index.

Semantically similar questions can reuse a previous answer even when the wording is different.

Question A
"What is GOTEI 13?"

Question B
"Within Soul Society, what purpose does GOTEI 13 serve?"

          β”‚
          β–Ό

      Embeddings
          β”‚
          β–Ό
   Redis Vector Search
          β”‚
          β–Ό
    Similarity Match
          β”‚
          β–Ό
    Cached Response

This tier provides a faster semantic cache before falling back to the persistent cache.


Tier 3: Persistent Chroma Cache

The persistent cache VDB provides semantic caching beyond the Redis layer.

Candidates are:

  1. Retrieved from ChromaDB
  2. Validated against cache metadata and source versions
  3. Reranked with Cohere
  4. Checked against the configured similarity threshold
  5. Returned when the candidate satisfies the cache policy
Question
   β”‚
   β–Ό
Chroma Similarity Search
   β”‚
   β–Ό
Valid Candidates
   β”‚
   β–Ό
Cohere Reranking
   β”‚
   β–Ό
Threshold Validation
   β”‚
   β–Ό
Cached Response

This gives Talk2Docs a persistent semantic cache that survives beyond the short-lived Redis layers.


Why Three Tiers?

Each tier solves a different problem:

Tier Technology Main Purpose
T1 Redis Exact Identical request protection
T2 Redis Vector Fast semantic reuse
T3 Chroma + Cohere Persistent semantic reuse
Miss AI Pipeline Generate a new answer

The result is a progressive cache strategy:

Fastest
   β”‚
   β–Ό
T1 Exact
   β”‚
   β–Ό
T2 Semantic
   β”‚
   β–Ό
T3 Persistent Semantic
   β”‚
   β–Ό
Full AI Pipeline
   β”‚
   β–Ό
Slowest

TriCacheLLM-MMA

The three-tier caching architecture was first built and validated inside Talk2Docs.

After proving the design in the application, the caching system was extracted into a standalone reusable project:

TriCacheLLM-MMA

The standalone project turns the Talk2Docs-specific implementation into a reusable caching architecture that can be integrated into other LLM applications.

Talk2Docs therefore serves as the initial production-style integration and validation environment for the architecture, while TriCacheLLM-MMA is its reusable evolution.


πŸ”„ Cache Validation

Cached answers are not treated as universally valid.

AnswerAI cache entries can contain information such as:

question
response
document IDs
cache policy
citations
provenance
source versions

For document-grounded answers, source versions are checked before reusing cached data.

This prevents an answer generated from an older document version from being blindly reused after the underlying source has changed.


πŸ—£οΈ ConvoAI

ConvoAI is the stateful conversational AI system within Talk2Docs.

Unlike AnswerAI, ConvoAI is not simply:

Question β†’ Retrieval β†’ Answer

It is an agentic system capable of deciding when external information or stored context is required.

                    User Message
                         β”‚
                         β–Ό
                     ConvoAI
                         β”‚
                         β–Ό
                 Tool Selection
                         β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚              β”‚               β”‚
          β–Ό              β–Ό               β–Ό
       Memory          AnswerAI       Web Search
          β”‚              β”‚               β”‚
          β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€               β”‚
          β”‚              β”‚               β”‚
          β–Ό              β–Ό               β–Ό
 Current Session    Documents        Current Facts
      LTM
          β”‚
          β–Ό
   Global Session LTM

          +
          
    General Intent
      Classifier

The model decides which tool is appropriate based on the request and available context.


🧰 ConvoAI Tool System

ConvoAI currently has five major tool capabilities.

1. AnswerAI Tool

Used when the user asks about:

  • Uploaded documents
  • Project-specific knowledge
  • Custom document canon
  • Indexed content

ConvoAI can invoke AnswerAI internally rather than requiring an external HTTP request.

ConvoAI
   β”‚
   β–Ό
AnswerAI Tool
   β”‚
   β–Ό
Document Retrieval
   β”‚
   β–Ό
Grounded Result
   β”‚
   β–Ό
ConvoAI

2. Current-Session Semantic LTM

Used when relevant information exists earlier in the current conversation but is no longer present in the immediate context.

The current conversation maintains recent context separately.

Current Conversation
        β”‚
        β”œβ”€β”€ Latest 5 Q&A
        β”‚       β”‚
        β”‚       └── Recent Context
        β”‚
        └── Older Conversation Data
                β”‚
                β–Ό
          Current-Session LTM
                β”‚
                β–Ό
        Semantic Retrieval

This allows ConvoAI to retrieve older information from the same conversation without repeatedly placing the entire conversation into the prompt.


3. Global Semantic LTM

Global LTM allows ConvoAI to retrieve relevant information from previous conversation sessions.

Conversation A
      β”‚
      β”œβ”€β”€ Memory
      β”‚
      β–Ό
Conversation B
      β”‚
      β”œβ”€β”€ New Question
      β”‚
      β–Ό
Global LTM Search
      β”‚
      β–Ό
Relevant Information

This allows useful information to persist beyond a single conversation ID.


4. Web Search

ConvoAI can use web search when the request depends on current or external information.

Examples:

Latest API version
Current news
Recent events
Current documentation
Real-time facts

The model decides when web search is required rather than blindly searching every question.


5. General Intent Classifier

Ambiguous or unresolved conversational references can be sent to a general intent classifier.

Examples include:

"What about the other one?"

"No, I meant the thing we discussed earlier."

"Which one was that?"

The classifier helps resolve vague references before ConvoAI produces a final answer.


πŸ” ConvoAI Tool Execution

The model handles tool selection while the application controls the actual execution loop.

Conceptually:

User Message
     β”‚
     β–Ό
ConvoAI Model
     β”‚
     β–Ό
Tool Call?
     β”‚
 β”Œβ”€β”€β”€β”΄β”€β”€β”€β”€β”
 β”‚        β”‚
 NO      YES
 β”‚        β”‚
 β–Ό        β–Ό
Answer  Execute Tool
          β”‚
          β–Ό
      ToolMessage
          β”‚
          β–Ό
      ConvoAI Model
          β”‚
          β–Ό
      Tool Call?
          β”‚
         ...
          β”‚
          β–Ό
     Final Response

The application limits tool execution rounds to prevent uncontrolled tool loops.

The current implementation uses explicit orchestration rather than hiding execution inside a generic agent executor.

This keeps:

  • Tool dispatch
  • Error handling
  • Logging
  • Database access
  • Async execution
  • Internal service calls

under application control.


🧠 Conversational Context Model

Talk2Docs separates recent context from semantic long-term memory.

                 Conversation
                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚                       β”‚
          β–Ό                       β–Ό
    Recent Context          Semantic Memory
       Latest 5                  β”‚
       Q&A                       β”‚
          β”‚               β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
          β”‚               β”‚             β”‚
          β”‚               β–Ό             β–Ό
          β”‚         Current Session   Global
          β”‚              LTM            LTM
          β”‚               β”‚             β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
                       ConvoAI

This avoids unnecessarily sending an entire conversation history on every request while still allowing older information to be recovered semantically.


πŸ” ConvoAI Caching Policy

Conversational caching is intentionally different from document-answer caching.

ConvoAI

T1 Exact Cache
      β”‚
      β–Ό
Duplicate Protection

ConvoAI does not rely on semantic T2/T3 response caching for normal conversational requests.

The reason is contextual correctness.

Two semantically similar conversational questions can require different answers depending on:

  • Previous conversation
  • Current topic
  • Tool state
  • User intent
  • Retrieved memory
  • Position within the conversation

Therefore ConvoAI uses exact T1 caching primarily for duplicate-request protection.

AnswerAI

T1 Exact
   ↓
T2 Semantic Redis
   ↓
T3 Semantic Chroma
   ↓
AI Pipeline

AnswerAI benefits much more directly from semantic response reuse because document-grounded questions can be validated against their source versions.


πŸ†” Conversation IDs

Talk2Docs distinguishes between:

conversation_id

and:

request_id

Conversation ID

Identifies a conversational branch/session.

Request ID

Identifies an individual API operation and is used for request correlation and tracing.

This distinction allows users to maintain multiple ongoing conversations while individual requests remain independently traceable.


πŸ“Š End-to-End Question Architecture

The current system effectively contains two different question pipelines.

Document Question

                         USER
                          β”‚
                          β–Ό
                    Question Route
                          β”‚
                          β–Ό
                   T1 Exact Cache
                          β”‚
                    β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
                   HIT          MISS
                    β”‚             β”‚
                    β–Ό             β–Ό
                 Response    Cache Classification
                                  β”‚
                                  β–Ό
                           T2 Semantic Redis
                                  β”‚
                           β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                          HIT            MISS
                           β”‚               β”‚
                           β–Ό               β–Ό
                        Response      T3 Chroma
                                          β”‚
                                   β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                                  HIT            MISS
                                   β”‚               β”‚
                                   β–Ό               β–Ό
                                Response      Query Classification
                                                   β”‚
                                                   β–Ό
                                           Retrieval Strategy
                                                   β”‚
                                                   β–Ό
                                           Hybrid Retrieval
                                                   β”‚
                                                   β–Ό
                                               Reranking
                                                   β”‚
                                                   β–Ό
                                                AnswerAI
                                                   β”‚
                                                   β–Ό
                                           Structured Response
                                                   β”‚
                                                   β–Ό
                                            Cache Population

Conversational Question

                         USER
                          β”‚
                          β–Ό
                       ConvoAI
                          β”‚
                          β–Ό
                   T1 Exact Cache
                          β”‚
                    β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
                   HIT          MISS
                    β”‚             β”‚
                    β–Ό             β–Ό
                 Response    Recent Context
                                  β”‚
                                  β–Ό
                           Agentic Tool Selection
                                  β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚                    β”‚                   β”‚
             β–Ό                    β–Ό                   β–Ό
        Current LTM           AnswerAI            Web Search
             β”‚                    β”‚                   β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                         General Classifier
                           when required
                                  β”‚
                                  β–Ό
                           Tool Execution
                                  β”‚
                                  β–Ό
                           Final Response

πŸ“ˆ Performance

Talk2Docs has been benchmarked at the retrieval-pipeline level.

Current retrieval benchmarks were performed against a single indexed document and should not be interpreted as final large-scale production benchmarks.

Technique Retriever + Classifier Retrieval Strategy Reranker Total
Step-Back 739.50 ms 826.49 ms 1258.61 ms 2.825 s
HyDE 801.31 ms 1503.64 ms 807.36 ms 3.112 s
Advanced Translation 739.19 ms 471.04 ms 1129.38 ms 2.340 s
Query Decomposition 902.63 ms 721.46 ms 673.91 ms 2.298 s
Multi-Index 658.66 ms 2760.05 ms 645.60 ms 4.064 s

Cache Validation

The three cache tiers have also been tested independently:

T1 Exact Redis
      β”‚
      └── PASS

T2 Semantic Redis
      β”‚
      └── PASS

T3 Chroma + Cohere
      β”‚
      └── PASS

The T3 validation specifically confirmed:

Chroma similarity search
        ↓
Valid candidates
        ↓
Cohere reranking
        ↓
Cache hit

πŸ” Authentication & Security

Talk2Docs uses authenticated, user-scoped access throughout the system.

Security mechanisms include:

  • JWT authentication
  • OAuth2PasswordBearer
  • Redis-backed sessions
  • Session revocation
  • User ban support
  • User-scoped PostgreSQL queries
  • User-scoped vector databases
  • Rate limiting
  • File validation
  • File signature validation
  • Upload size limits
  • Centralized exception handling

Document access is scoped using authenticated user identity rather than trusting arbitrary user-provided identifiers.

Conceptually:

Authenticated User
       +
Request ID
       +
Resource ID
       ↓
Authorized Resource

🚦 Rate Limiting

Talk2Docs uses SlowAPI for API-level rate limiting.

Example:

@limiter.limit("3/minute")

Rate limiting protects sensitive endpoints against excessive requests.


πŸ“‘ Worker Status Polling

Uploads are asynchronous, so clients can monitor processing status.

Example endpoint:

GET /upload_worker/{task_id}/{request_id}

The endpoint combines transient Celery state with persistent PostgreSQL document state.

Example:

{
  "worker": {
    "status": "processing",
    "task_id": "...",
    "state": "STARTED"
  },
  "document": {
    "status": "PROCESSING",
    "failure_reason": null
  },
  "multi_index": {
    "doc_id": 42,
    "summary_status": "PROCESSING",
    "explanation_status": "PENDING"
  }
}

This prevents transient worker state from being confused with persistent document state.

I also have a conversiaon_id pooling endpoint which fron-end is expected to call before invoking convoAi:

@router.get("/convo-id")
async def create_convo_id(user_id: int = Depends(get_user_jwt_payload), db: AsyncSession = Depends(get_db)):
    convo_id: str = create_conversation_id(user_id)
    request_id = str(uuid.uuid4())
    
    return APIResponse(
        success=True,
        data={"convo_id": convo_id},
    )

🧱 APIResponse Architecture

Internal services use a common response representation:

success
+
data
+
error_code
+
error_message

Conceptually:

APIResponse(
    success=True,
    data=...,
    error_code=None,
    error_message=None
)

This provides a predictable boundary between:

  • Business-level failures
  • Validation failures
  • AI failures
  • Infrastructure failures
  • Unhandled application exceptions

πŸ›‘οΈ AI Failure & Validation

AI output is not blindly trusted.

Structured AI responses are validated through Pydantic models.

The general approach is:

AI Output
    β”‚
    β–Ό
Parse
    β”‚
    β–Ό
Validate
    β”‚
 β”Œβ”€β”€β”΄β”€β”€β”
 β”‚     β”‚
PASS  FAIL
 β”‚     β”‚
 β–Ό     β–Ό
Use   Recovery
        β”‚
        β–Ό
      Validate
        β”‚
      β”Œβ”€β”΄β”€β”
      β”‚   β”‚
    PASS FAIL
      β”‚   β”‚
      β–Ό   β–Ό
     Use Error

The same philosophy is applied to:

  • Answer generation
  • Query classification
  • Reranking
  • ConvoAI structured output
  • Tool results where validation is required

πŸ“ Project Structure

A simplified representation:

Talk2Docs/
β”‚
β”œβ”€β”€ Ai/
β”‚   β”œβ”€β”€ answer_ai.py
β”‚   β”œβ”€β”€ query_classifier.py
β”‚   β”œβ”€β”€ retry_logic.py
β”‚   β”œβ”€β”€ ai_utils.py
β”‚   β”œβ”€β”€ convo_ai/
β”‚   β”œβ”€β”€ reranker/
β”‚   └── query_construction/
β”‚       β”œβ”€β”€ HYDE/
β”‚       β”œβ”€β”€ multi_query/
β”‚       β”œβ”€β”€ multi_indexing/
β”‚       β”œβ”€β”€ query_decomp/
β”‚       β”œβ”€β”€ step_back/
β”‚       └── advanced_translation/
β”‚
β”œβ”€β”€ celery_worker/
β”‚   β”œβ”€β”€ celery_app.py
β”‚   └── Tasks/
β”‚       β”œβ”€β”€ Ai_worker/
β”‚       β”œβ”€β”€ embedding_worker.py
β”‚       β”œβ”€β”€ ingestion_worker.py
β”‚       └── chat_worker.py
β”‚
β”œβ”€β”€ routers/
β”‚   β”œβ”€β”€ Ai/
β”‚   β”œβ”€β”€ auth/
β”‚   └── users/
β”‚
β”œβ”€β”€ db_tables/
β”‚
β”œβ”€β”€ vector_db/
β”‚
β”œβ”€β”€ docling/
β”‚
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ Exceptions/
β”‚   └── rate_limiters/
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ logging/
β”‚   └── schemas/
β”‚
β”œβ”€β”€ alembic/
β”‚
β”œβ”€β”€ nginx/
β”‚
└── ...

πŸ› οΈ Technology Stack

Backend

  • Python 3.12+
  • FastAPI
  • Pydantic v2
  • SQLAlchemy 2.0 Async
  • Alembic

AI / RAG

  • LangChain
  • Sentence Transformers
  • ChromaDB
  • BM25
  • Hybrid Retrieval
  • Reciprocal Rank Fusion
  • Multi-Query
  • HyDE
  • Step-Back
  • Query Decomposition
  • Advanced Query Translation
  • Multi-Index Retrieval
  • Cohere Encoder Reranking
  • Structured Pydantic AI output

Conversational AI

  • LangChain tool calling
  • Agentic tool orchestration
  • Semantic current-session memory
  • Semantic cross-session memory
  • Web search
  • Document QA as an internal tool
  • General intent classification

Document Processing

  • Docling
  • HybridChunker
  • Content validation
  • Signature validation

Background Processing

  • Celery
  • Redis

Database & Storage

  • PostgreSQL
  • ChromaDB
  • Redis
  • Persistent BM25 artifacts

Authentication & Security

  • JWT
  • OAuth2PasswordBearer
  • Redis-backed sessions
  • Session revocation
  • SlowAPI
  • User-scoped retrieval

Infrastructure & Observability

  • Nginx
  • Structured logging
  • Centralized exception handling
  • Celery lifecycle tracking
  • Persistent document status tracking

πŸ§ͺ Engineering Principles

Separation of Concerns

Routes, services, workers, retrieval systems, AI systems and storage have distinct responsibilities.

HTTP
 ↓
Service
 ↓
AI / Retrieval / Database
 ↓
APIResponse

Retrieval Modularity

Retrieval strategies can evolve without forcing AnswerAI to understand their internal implementation.

Retrieval Strategy
       ↓
list[LangChainDocument]
       ↓
Reranker
       ↓
AnswerAI

User Isolation

Documents, vector databases, caches and semantic memories are scoped to authenticated users.

User A
 β”œβ”€β”€ Documents
 β”œβ”€β”€ VDBs
 β”œβ”€β”€ Cache
 └── Memory

User B
 β”œβ”€β”€ Documents
 β”œβ”€β”€ VDBs
 β”œβ”€β”€ Cache
 └── Memory

Asynchronous Processing

Expensive work is moved away from HTTP request execution whenever possible.

HTTP Request
     β”‚
     β–Ό
FastAPI
     β”‚
     β–Ό
Dispatch
     β”‚
     β–Ό
Celery / Background Task
     β”‚
     β–Ό
Expensive Work

Context-Aware AI

The system does not treat every question as the same type of problem.

A request may require:

Document Retrieval
      OR
Recent Conversation Context
      OR
Current-Session Memory
      OR
Global Memory
      OR
Web Search
      OR
General Intent Resolution

The goal is to retrieve the right information source, rather than simply retrieving more information.


πŸ“ˆ Current Progress

Core Backend

  • FastAPI
  • Async SQLAlchemy
  • PostgreSQL
  • Alembic
  • JWT authentication
  • OAuth2PasswordBearer
  • Redis-backed sessions
  • Session revocation
  • Celery integration
  • Rate limiting
  • Centralized exception handling
  • Structured logging
  • Nginx integration

Document Pipeline

  • File validation
  • File persistence
  • Document metadata
  • Asynchronous upload processing
  • Docling parsing
  • HybridChunker
  • Embedding generation
  • Raw ChromaDB indexing
  • Document state tracking
  • Celery retry handling
  • Worker status polling

Multi-Index RAG

  • Raw VDB
  • Summary VDB
  • Explanation VDB
  • Summary AI
  • Explanation AI
  • Shared chunk_id
  • Multi-index lifecycle tracking
  • Background construction
  • Summary retrieval
  • Explanation retrieval
  • Parallel secondary retrieval
  • Raw chunk resolution

Retrieval

  • Vector retrieval
  • BM25 retrieval
  • Hybrid retrieval
  • Ensemble retrieval
  • Reciprocal Rank Fusion
  • Multi-Query
  • HyDE
  • Step-Back
  • Advanced translation
  • Query decomposition
  • Multi-index retrieval
  • Common list[LangChainDocument] retrieval contract
  • AI reranking
  • Reranker validation
  • Candidate validation
  • Persistent user-scoped BM25

Caching

  • T1 exact Redis cache
  • T2 semantic Redis vector cache
  • T3 persistent Chroma semantic cache
  • Cohere cache reranking
  • Cache source-version validation
  • Cache provenance metadata
  • Asynchronous cache population
  • AnswerAI three-tier caching
  • ConvoAI T1-only duplicate protection

Conversational AI

  • Conversation IDs
  • Recent conversational context
  • Latest-five Q&A context
  • ConvoAI
  • Agentic tool selection
  • Manual tool execution loop
  • AnswerAI tool
  • Web search tool
  • Current-session semantic LTM
  • Global semantic LTM
  • General intent classifier tool
  • Structured ConvoAI responses
  • Tool execution logging

Answer Generation

  • Document-grounded answers
  • Structured Pydantic output
  • Source citations
  • Verbatim evidence
  • Confidence scoring
  • Meaning-preservation validation

πŸ—ΊοΈ Future Work

The core document intelligence, caching, and agentic conversation architecture is now implemented.

The next major feature is tabular document intelligence for CSV and XLSX files.

Unlike normal document QA, tabular questions should not rely on treating rows as ordinary text chunks. Instead, Talk2Docs will understand the table schema, retrieve the relevant structural information, and generate validated Pandas operations against the original file at question time.

CSV / XLSX Pipeline

The planned architecture is:

                         Upload
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Background Tabular      β”‚
              β”‚ Worker                  β”‚
              β”‚                         β”‚
              β”‚ Detect CSV / XLSX       β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Extract Schema +        β”‚
              β”‚ Metadata                β”‚
              β”‚                         β”‚
              β”‚ β€’ Column names          β”‚
              β”‚ β€’ Data types            β”‚
              β”‚ β€’ Table structure       β”‚
              β”‚ β€’ Useful metadata       β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                    Index Schema
                           β”‚
                           β–Ό
                  Schema VDB / Index
                           β”‚
                           β”‚
              Original File Remains
              the Source of Truth
                           β”‚
                           β–Ό
                     User Question
                           β”‚
                           β–Ό
                 Retrieve Relevant
                       Schema
                           β”‚
                           β–Ό
              Load Original File
                 at Runtime
                           β”‚
                           β–Ό
                    Pandas DataFrame
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ LLM 1                   β”‚
              β”‚                         β”‚
              β”‚ Question + Schema       β”‚
              β”‚          ↓              β”‚
              β”‚ Pydantic Output         β”‚
              β”‚          ↓              β”‚
              β”‚ Pandas Code             β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                      Validation
                           β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚             β”‚             β”‚
             β–Ό             β–Ό             β–Ό
        Column Check    AST Check    Forbidden
        vs Schema       / Allowed    Operations
                        Code Rules
             β”‚             β”‚             β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
                  Isolated Execution
                           β”‚
                           β–Ό
                Execute Pandas Code
                  Against DataFrame
                           β”‚
                           β–Ό
                Deterministic Result
                           β”‚
                           β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ LLM 2                   β”‚
              β”‚                         β”‚
              β”‚ Original Question       β”‚
              β”‚ + Relevant Schema       β”‚
              β”‚ + Executed Result       β”‚
              β”‚          ↓              β”‚
              β”‚ Final Natural Language  β”‚
              β”‚ Answer                  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design Principles

Original Files Remain the Source of Truth

CSV and XLSX files will be preserved after upload.

The VDB will store schema and metadata, not the authoritative table contents.

At question time, the original file will be loaded into a Pandas DataFrame and used for deterministic computation.

Original CSV/XLSX
       β”‚
       β–Ό
Runtime DataFrame
       β”‚
       β–Ό
Validated Pandas Operation
       β”‚
       β–Ό
Deterministic Result

This avoids relying on an LLM to perform arithmetic, filtering, aggregation, or other operations over retrieved text chunks.


Schema-First Retrieval

The system will first retrieve the relevant table schema.

For example:

Question:
"What was the average salary of employees in the Finance department?"

Retrieved Schema:

employees
β”œβ”€β”€ employee_id: integer
β”œβ”€β”€ name: string
β”œβ”€β”€ department: string
β”œβ”€β”€ salary: float
└── joining_date: datetime

The schema gives the model the structural information it needs to generate the Pandas operation.


LLM 1: Code Generation

The first model will receive:

Original Question
        +
Relevant Table Schema

and produce structured output through Pydantic.

Conceptually:

Question + Schema
       β”‚
       β–Ό
      LLM
       β”‚
       β–Ό
Pydantic Model
       β”‚
       β–Ό
Validated Pandas Code

The model will not directly execute its own output.


Code Validation

Generated Pandas code will pass through a validation layer before execution.

Validation will include:

  • Column names must exist in the retrieved schema
  • Only permitted operations/functions may be used
  • Python AST must satisfy the allowed structure
  • Forbidden operations must be rejected
  • Unexpected imports or filesystem/network access must be blocked
  • Generated code must operate only on the intended DataFrame

The goal is to treat model-generated code as untrusted input.

LLM Generated Code
        β”‚
        β–Ό
     Validate
        β”‚
   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
   β”‚         β”‚
Valid      Invalid
   β”‚         β”‚
   β–Ό         β–Ό
Execute     Reject

Isolated Execution

Only validated Pandas operations will be executed against the runtime DataFrame.

The execution layer will produce a deterministic result.

DataFrame
    +
Validated Pandas Code
    β”‚
    β–Ό
Execution
    β”‚
    β–Ό
Deterministic Result

The LLM does not calculate the result itself.

It asks Pandas to perform the computation and receives the actual result.


LLM 2: Answer Generation

The final model will receive:

Original Question
        +
Relevant Schema
        +
Executed Result

and convert the deterministic result into a natural-language answer.

Question
   +
Schema
   +
Actual Computed Result
        β”‚
        β–Ό
      LLM 2
        β”‚
        β–Ό
   Final Answer

This separates computation from explanation.

The first model determines what operation should be performed.

Pandas determines what the actual result is.

The second model determines how that result should be explained to the user.

Why This Architecture?

The important difference between ordinary document QA and tabular QA is that a table often requires computation rather than retrieval.

For example:

"What was the total revenue in Q3?"

should not be answered by hoping the LLM finds a matching sentence in a vector database.

Instead:

Question
   ↓
Schema Retrieval
   ↓
Pandas Code Generation
   ↓
Code Validation
   ↓
Actual DataFrame Execution
   ↓
Deterministic Result
   ↓
Natural Language Answer

This allows Talk2Docs to use RAG for understanding the structure of the data, while using deterministic execution for the actual computation.

Future Hardening

After the initial CSV/XLSX pipeline is implemented, the next focus will be:

  • Stronger generated-code validation
  • Execution sandboxing and resource limits
  • Better handling of multiple sheets in XLSX
  • Large-file handling
  • Schema/version validation
  • Better error recovery when generated code fails
  • Regression and integration testing
  • Performance testing
  • Production monitoring and observability

The overall goal is to make tabular QA another first-class workload inside Talk2Docs rather than treating spreadsheets as ordinary text documents.

Production Hardening

  • Larger multi-document benchmarks
  • Load testing
  • Expanded regression test suite
  • More provider failure/recovery testing
  • Expanded observability
  • CI/CD
  • Production deployment
  • Monitoring

Retrieval & AI

  • Larger-corpus retrieval benchmarking
  • Further model/provider benchmarking
  • Retrieval quality evaluation datasets
  • More advanced agentic workflows
  • Additional tool integrations

Memory

  • Further memory ranking improvements
  • Memory lifecycle optimization
  • More sophisticated context compression
  • Long-running conversation optimization

Data Support

  • Advanced CSV/XLSX question-answering pipeline
  • Tabular-data-specific retrieval
  • Additional document formats

❀️ Why Talk2Docs Exists

Talk2Docs started as a document-processing backend.

It gradually evolved into a system designed around a larger question:

How can an AI application decide what information it actually needs before answering?

The result is no longer simply:

Document
   ↓
Embeddings
   ↓
Vector Search
   ↓
LLM

Instead:

                       USER
                         β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚                       β”‚
             β–Ό                       β–Ό
        Document QA              ConvoAI
             β”‚                       β”‚
             β–Ό                       β–Ό
       Cache Layers             Tool Selection
             β”‚                       β”‚
             β–Ό              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      Query Intelligence    β”‚        β”‚         β”‚
             β”‚             LTM     Web      AnswerAI
             β–Ό              β”‚        β”‚         β”‚
       Hybrid Retrieval     β””β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚                       β”‚
             β–Ό                       β–Ό
         Reranking             Agentic Context
             β”‚                       β”‚
             β–Ό                       β–Ό
        Grounded Answer       Structured Response

Talk2Docs is therefore a combination of:

Document Processing
        +
Advanced RAG
        +
Hybrid Retrieval
        +
Multi-Index Retrieval
        +
Three-Tier Semantic Caching
        +
Conversational Memory
        +
Agentic Tool Use
        +
Structured AI Responses

πŸ“œ License

MIT License


Built with:

FastAPI Β· Celery Β· Docling Β· LangChain Β· ChromaDB Β· PostgreSQL Β· Redis Β· Pydantic Β· Sentence Transformers Β· Cohere

About

Production-oriented RAG backend featuring asynchronous document processing, semantic search, hybrid retrieval, and AI-powered question answering.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages