Home / Case studies / 01 of 03

LLM systems · Live on kiosks

A multilingual avatar platform that answers from an organisation's own documents

An organisation sets up a persona and uploads its documents, and gets a real-time talking avatar on the web and on touch-screen kiosks. Every answer comes from those documents, with a citation.

My role
Architect and sole engineer
Built at
Think Digital
Client type
A national meat processor, on kiosks at its sites
Status
In production for one client

The problem

A large employer wanted its staff to ask questions about their workplace and get a straight answer, by voice and in the language they speak, at a kiosk on site or in a browser. A general chatbot fails that job in two ways: it invents answers that sound right, and it cannot say where an answer came from.

So the requirements were plain. Answer from the organisation's own documents and cite them. Hand a question to the right persona when it belongs elsewhere. Keep personal data out of what is stored. Let administrators change personas and knowledge without an engineer.

Who uses it

  • Staff and visitors, who talk to the avatar at a kiosk or in a browser
  • Organisation administrators, who set up personas, upload knowledge and manage users
  • The platform team, who run it, watch its cost and latency, and roll a release back when one goes wrong

What I built

I architected and built the platform end to end, as its only engineer. Every one of its 846 commits is mine.

  • A FastAPI backend with 64 routes for organisations, personas, knowledge bases, users and the audit trail, on PostgreSQL with 19 migrations
  • A separate streaming brain service on Amazon ECS that runs retrieval and calls the model. It speaks the OpenAI chat format, so the avatar vendor can call it directly in full mode
  • A Next.js admin app for personas, knowledge and users
  • The kiosk app, with 46 routes and its own speech path, where a visitor's phone can act as the microphone
  • The delivery path: GitHub Actions CI, OIDC deploys with no stored keys, a rollback runbook and 12 release tags
  • A kiosk client for Atlas AI, so the same kiosk can run on Think Digital's shared platform. It is on a branch, in testing
Avatar platform architecture Documents are extracted, chunked, embedded with Titan v2 and stored in PostgreSQL with pgvector and full-text indexes. Each spoken turn is rewritten for follow-ups, searched by vector and full text, fused by reciprocal rank, answered by Claude with citations and checked tool calls, then streamed to the avatar and stored after PII redaction. INGEST Upload PDF, Word or text Text extraction, Textract OCR for scans, site tag 01 Chunk 800 tokens, 100 overlap 02 Embed Titan v2, 1,024 dims PostgreSQL pgvector HNSW, cosine · tsvector, GIN index EACH TURN Visitor speaks, at a kiosk or on the web Transcribe in lite mode, the vendor in full mode 03 Query rewrite A short follow-up joins the previous question Hybrid search 04 Vector search Top 8, floor 0.20 Full-text search Ranked by ts_rank_cd Reciprocal rank fusion Constant 60, joins the two ranked lists Claude Sonnet 4.6 on Bedrock Citations document blocks, prompt caching 05 Tool calls, checked by the API Specialist handoff, end session, allowlist 06 Stream to avatar Server-sent events, then voice 07 Redact, then store Transcript, citations Fails closed
Fig. 01 · Ingest, then each turn. Lime marks the retrieval core, amber the redaction that fails closed.

Architecture

How a spoken question becomes a cited answer

Two paths share one store. Documents go in once, through extraction, chunking and embedding. Each spoken turn then runs a hybrid search over the same store before Claude answers.

  1. Ingest. An administrator uploads PDF, Word or text. The backend extracts the text, runs Textract OCR on scanned pages, and tags each document with its client site.
  2. Chunk and embed. The chunker cuts 800-token windows with a 100-token overlap, up to 400 chunks for each document. Amazon Titan Text Embeddings v2 turns each chunk into a 1,024-dimension vector. pgvector stores them under an HNSW cosine index, and a tsvector column with a GIN index serves full-text search.
  3. Speech in. A visitor speaks to the avatar. In full mode the vendor handles speech and calls the brain in the OpenAI chat format. In lite mode the kiosk runs Amazon Transcribe in and ElevenLabs out, and the vendor only renders video.
  4. Hybrid search. A short follow-up such as "say that in Hindi" first joins the previous question. The brain takes the top 8 chunks by cosine similarity above a 0.20 floor, and runs a Postgres full-text search ranked by ts_rank_cd. Reciprocal rank fusion, with a constant of 60, joins the two lists.
  5. Cited answer. The chunks reach Claude Sonnet 4.6 on Amazon Bedrock as Citations document blocks, with prompt caching. One setting switches the provider to the Anthropic API.
  6. Tools. The model can hand the visitor to a specialist persona with a redacted summary, or end the session. The backend checks every call against that persona's tool allowlist and a rate limit.
  7. Stream and store. The brain streams server-sent events to the avatar. The backend redacts personal data, then stores the transcript, citations and extracted facts.

Key decisions and trade-offs

  • Fuse by rank, not by scoreVector search finds a loosely worded question. Full-text search finds the exact name or code that an embedding blurs. Their scores sit on different scales, so reciprocal rank fusion joins the two lists by rank and needs no tuned weight between them.
  • A similarity floor set by measurementA floor borrowed from another embedding model would be wrong for this one. I measured where real matches and off-topic questions score with Titan v2, and set the floor at 0.20, between the two.
  • The documents are the authority, with one exceptionA document-authority rule tells the model to answer from the organisation's documents rather than its own knowledge, so it never invents policy. Safety is the carve-out: it never withholds a safety answer. Six prompt-rule tests hold this in place.
  • Authorisation lives in the API, never in the promptThe model can ask to hand off or end a session, but the backend decides. Each persona has a tool allowlist and a rate limit, because a model will eventually be talked into trying something it was never granted.
  • Found nothing is not the same as could not runRetrieval falls back from an in-memory cache, to pgvector, to loading every chunk, to no documents. Only a real failure reaches the load-all step, never an empty result. One failed embedding costs one chunk, not the whole document.
  • Bring the speech in house to halve the vendor rateIn full mode the vendor runs speech recognition, the model and the voice. Lite mode renders video only, at half the per-minute rate, but it meant building our own speech path: the visitor's phone as the microphone, streaming speech to text, and our own voice. The kiosk runs on lite.
  • A newer model has to win on the numbersI tested a newer Claude model against the current one on the same checks. Quality matched, but the first word came later, so the upgrade waited. On a voice avatar, a slow first word feels like a broken one.
  • Measure before tuningProduction latency logs showed that the slowest turns came from a database reconnect, not from the model. That pointed the fix at the connection pool rather than at the prompt.

Evaluation and quality

Quality is checked by tests and gates, not by a demo that went well.

  • 1,052 automated tests across four services: 483 in the backend, 174 in the brain, 249 in the kiosk app and 146 in the admin app
  • An acceptance gate of 30 invented facts. The facts exist only in a test knowledge base, so no model can know them from training. The avatar has to answer all 30 from the documents, and it passes 30 of 30 on the keyword search path
  • Six prompt-rule tests for document authority, including the safety carve-out
  • A regression test that replays a real outage, so the same failure cannot come back quietly
  • 102 authorisation tests: each of the 34 admin routes is tested for three cases, plus six kiosk cases
  • A/B tests before a model upgrade, on the same checks, for both quality and time to first word

Safety, privacy and failure handling

  • Four roles: super administrator, organisation administrator, organisation user and visitor
  • An audit log written in the same transaction as each change, so a change cannot land without its record
  • Versioned persona prompts, so every prompt change has a history
  • Personal data redaction with Microsoft Presidio across 10 entity types, which fails closed
  • Kill switches for the knowledge layer, conversation memory and redaction
  • A 128-bit pair code between the kiosk and a visitor's phone, which closed an unauthenticated relay
  • Monitoring: token, cache-token and first-token logs, two AWS Budgets with alerts at 50, 80 and 100%, seven alarms, a five-minute canary and a dashboard
  • Rollback: OIDC deploys from GitHub Actions and a nine-section rollback runbook

Results

846
commits, every one of them mine
1,052
automated tests across four services
30 of 30
invented facts answered from the documents
102
authorisation tests on the admin API
1 min
about one billed vendor minute saved on each kiosk session, by fixing a stop call that failed
10
types of personal data redacted before storage

Stack

  • Claude Sonnet 4.6
  • Amazon Bedrock
  • Anthropic API
  • Titan Text Embeddings v2
  • PostgreSQL
  • pgvector
  • HNSW
  • Python
  • FastAPI
  • Next.js
  • TypeScript
  • Amazon ECS
  • Textract
  • Transcribe
  • ElevenLabs
  • LiveAvatar
  • Microsoft Presidio
  • AWS Budgets
  • GitHub Actions

More case studies