~/localhost

Project

AI Knowledge Copilot

PrototypeApplied AI · RAG

Overview

The FastAPI backend and Streamlit UI running locally with the default local models (all-MiniLM-L6-v2 embeddings, flan-t5-base answers). The uploaded PDF is a fictional sample handbook.

A reusable retrieval-augmented generation (RAG) platform: upload any PDFs, ask questions, get cited answers.

Knowledge Copilot is a document question-answering platform. It works with any set of PDFs, from handbooks and research papers to internal docs, not one fixed corpus. Each answer cites the source file, page and passage it came from, with a relevance score.

Working end to end with a local model. Hosted LLM providers are planned.

Problem

Teams have knowledge locked inside PDFs. Keyword search misses meaning, and a plain LLM invents answers. RAG retrieves the relevant passages first and answers only from them.

Role

Sole engineer

Stack

API
PythonFastAPISQLAlchemy 2SQLite
Retrieval
ChromaDBsentence-transformersall-MiniLM-L6-v2
Generation
transformersgoogle/flan-t5-base (local)
UI & ops
StreamlitpypdfDocker ComposepytestGitHub Actions

Architecture

Two services, a layered backend and a pluggable LLM provider.

  1. Streamlit UI

    Upload PDFs, ask questions and inspect citations. Talks to the API over HTTP.

  2. Ingestion

    Per-page PDF extraction, then character chunks (800 chars, 150 overlap), then embeddings, then ChromaDB with document/page metadata.

  3. Retrieval

    Embed the question and take the top-4 chunks by cosine similarity.

  4. Generation

    A prompt that says to answer only from the retrieved context, using a local flan-t5 model behind an LLMProvider interface.

  5. Storage

    ChromaDB for vectors, SQLite for document metadata and chat history.

Engineering

Engineering decisions

  • LLM behind a provider interface

    The local model works today, and hosted models can be added without touching the pipeline.

  • Page-level citations

    Answers are only trustworthy if a reader can jump to the exact source passage.

  • Lazy model loading

    Tests and CI don't pay the cost of loading embedding and generation models.

Challenges & solutions

  • Grounding answers in the documents

    The prompt restricts the model to the retrieved context, and each answer ships with its supporting chunks and scores.

  • Keeping it general-purpose

    Nothing is specific to one corpus. Documents can be added or deleted through the API, and retrieval spans everything uploaded.

Results & roadmap

Results & outcomes

No answer-quality metrics have been measured yet.

  • REST endpoints

    6

    Source: Health, document upload/list/delete, ask, chat history

  • Automated tests

    11

    Source: Chunking, PDF service, repository and API health

Roadmap

  1. PDF ingestion + cited Q&ADone
  2. Hosted LLM providers · OpenAI / Anthropic behind the existing interfacePlanned
  3. Hybrid search + re-rankingPlanned
  4. Async ingestion workerPlanned
  5. Auth, multi-tenancy, PostgresPlanned
  6. DOCX / TXT / HTMLPlanned

Links