RAG knowledge assistant

Answers grounded in your docs, with receipts.

Ask a question and get an answer built only from retrieved sources: hybrid search, live relevance scoring, inline citations, and an honest refusal when the docs don’t cover it.

  • Runs in your browser
  • No sign-up
  • No API key
Type your own or pull a sample

Filed underismydataencryptedatrest

Replywritten only from the cards

All customer data is encrypted at rest with AES-256 and in transit with TLS 1.3.

    The Librarian owl in pen and ink, wearing round glasses, holding a stack of books and an open book

    Fig. 1 A sample run

    1. Filed
    2. Scored 12
    3. Pulled 3
    4. Written
    Cited 1
    security.mdcard 4

    All customer data is encrypted at rest with AES-256 and in transit with TLS 1.3. Database backups are encrypted with a separate key hierarchy.

    Not cited
    data.mdcard 5

    Export all of your data as JSON or CSV from Settings, then Data, then Export. Large exports are prepared in the background and emailed as a download link.

    Not cited
    residency.mdcard 8

    Data can be pinned to the US, EU, or APAC region. The region is chosen when a workspace is created and cannot be changed afterward.

    All twelve drawers searched. No card shares a single term with this question, so nothing leaves the cabinet.

    cosine, TF-IDFterm 0.06, phrase 0.08title 0.15termkeyword matchcite line 0.12

    Or pull a sample question

    How it works

    Three steps, run in your browser over a twelve-card sample catalogue. No server, no API key.

    1. File the question

      Stop words drop out. What is left is stemmed, so retries and retried file under one heading, and a few synonyms in the docs’ own words are added. The terms are weighted by TF-IDF into a query vector.

    2. Pull the cards

      Every card is scored: cosine similarity, plus 0.06 for each shared term, 0.08 for each shared phrase and 0.15 when a term names the card’s title. The top three leave their drawers.

    3. Cite or refuse

      The reply quotes the best sentence of each card and footnotes it. If no card reaches 0.12, nothing is written.

    What it does

    The house rules of the reading room.

    Librarian is retrieval-augmented generation reduced to its honest core: find the passages that answer the question, show how they were found, and quote them. Four rules keep it that way.

    Notice

    1. Every claim carries a footnote.

      Each sentence of a reply is quoted from a card, and its footnote lifts that card out of the tray with its score beside it.

    2. No card, no answer.

      When nothing clears the cite line, the reply is a refusal stamped Not in the stacks. It never guesses from what it half remembers.

    3. The arithmetic is on the card.

      Cosine, term, phrase and title parts are printed under every pulled card, so anyone can check why it was chosen.

    4. Bring your own text.

      Paste notes or an article in the console. It is cut into cards, filed in the cabinet and searched in your browser; nothing is sent anywhere.

    The architecture

    The route of a question.

    Five stations, one TypeScript module, no server. Followed here with a real question from the catalogue; every figure on this plate is computed by the same code the console runs.

    QuestionHow do webhooks handle retries?
    1. Analyzer

      analyze()

      Stop words and filler verbs drop out, the rest are stemmed with Porter’s rules, and a synonym map of 5 entries adds the docs’ own words (SSO also looks for single sign-on).

      howdowebhookshandleretries

    2. Index

      buildIndex()

      The twelve cards are filed under 142 distinct terms. Rare terms weigh more: a term on one card outranks one on four.

      termcardsidf
      webhook12.872
      retri12.872
    3. Scorer

      scoreAll()

      Cosine over TF-IDF vectors, plus 0.06 for every shared term, 0.08 for every shared two-word phrase and 0.15 when a term names the card’s title. The top 3 leave their drawers.

      webhooks.md0.341 cos + 0.120 match + 0.150 title= 0.611

      The other 11 cards: 0.000, no shared term.

    4. Cite line

      retrieve()

      If the best card is under 0.12, the run ends here with a refusal. Nothing below this line is ever guessed.

      “How do webhooks handle retries?”0.611 ≥ 0.12Write

      “What is the meaning of life?”0.000 < 0.12Not in the stacks

    5. Writer

      bestSentence()

      The reply is extractive: the sentence whose matched terms carry the most weight is quoted and footnoted. A term that only names the card’s title counts for a quarter, so the retry line wins over the signature line.

      Failed deliveries are retried with exponential backoff for up to 24 hours1.1 webhooks.md, card 7

    Plate II. The route of a question through Librarian. Source: lib/retrieval.ts, covered by a test for every sample question.

    Colophon

    Librarian was set, ruled and bound in the browser. No model is called and no server answers: the whole reading room is a static page and about four hundred lines of retrieval code.

    Framework
    Next.js 16, App Router, statically rendered
    Interface
    React 19, server-rendered, the reading room as a client island
    Language
    TypeScript, strict
    Styling
    Tailwind CSS 4 and hand-ruled CSS, no color
    Retrieval
    TF-IDF, Porter stemmer and hybrid scorer, written from scratch
    Tests
    Vitest: one test per sample question
    Type
    Fraunces, Libre Franklin, IBM Plex Mono
    Hosting
    Netlify

    Further reading

    The case study is on loan.

    The write-up of Librarian lives on rikenpatel.work, beside the rest of Riken Patel’s work in AI and mobile engineering.

    Call no. AI LAB 02Riken PatelLibrarian: a RAG assistant that cites or refuses

    The console

    The reading room is open.

    Ask the twelve cards anything, change the house rules and watch the scores move, or file your own text into the cabinet. It all runs in your browser.

    Launch console