web

lexicon

Grounded document Q&A that gives cited answers or refuses.

GitHub repo (opens in a new tab) ↗

~/problem

Document Q&A that sounds confident but is wrong is costly. A feasibility spike showed similarity scores could not separate a correct answer from a topically adjacent wrong one, so refusal is enforced by a separate verification step.

A FastAPI and Next.js system that answers questions only when the answer is backed by citations in the supplied documents. An independent groundedness verification call, not a similarity threshold, decides between answering and refusing. v1.0.0 is tagged.

~/highlights

  • Hybrid retrieval over PostgreSQL with pgvector; retrieval recall@k is measured for real (9/9) because it never calls an LLM.
  • Verification call hardened against prompt injection inside passages: 18 of 18 structural containment across an 18-document adversarial corpus.
  • Tamper-evident audit trail (ADR-0002) and instance-level authentication (ADR-0005).
  • Committed, CI-gated evaluation harness with a golden dataset.
  • Production-shaped compose stack with non-root images and a pre-warmed embedding model; three bugs found and fixed by running it.
  • No LLM API key exists in the project by design (ADR-0004): all quality numbers measure the harness against a deterministic stub, and the README says so.

~/architecture

Architecture of lexiconNext.js frontend connects to FastAPI backend. FastAPI backend connects to PostgreSQL + pgvector, Redis, MinIO, LLM client. PostgreSQL + pgvector has no outgoing connections. Redis has no outgoing connections. MinIO has no outgoing connections. LLM client has no outgoing connections.Next.js frontendFastAPI backendPostgreSQL + pgvectorRedisMinIOLLM client
Next.js frontend → FastAPI backend
Sign in, corpora, upload and question form.
FastAPI backend → PostgreSQL + pgvector, Redis, MinIO, LLM client
Ingestion, hybrid retrieval, generation, verification, audit trail.
PostgreSQL + pgvector
Chunks, embeddings, corpora, audit records.
Redis
Supporting store used by the backend.
MinIO
S3-compatible document storage.
LLM client
StubLLMClient by default; Anthropic client when a key is configured.

~/stack

  • Python 3.12
  • FastAPI
  • Next.js 16
  • PostgreSQL
  • pgvector
  • Redis
  • MinIO
  • Docker

~/status

v1.0.0 tagged, AGPL-3.0. Real LLM verification is permanently descoped, so answer quality has not been measured against a real model.

  • lexicon-android Android client for lexicon with offline caching and background sync.