RAG demo: grounded Q&A over documents — German & English

Full pipeline, entirely server-side on Cloudflare Workers AI: chunking → multilingual embeddings → cosine retrieval → cross-encoder reranking → an answer grounded strictly in the retrieved fragments, with citations. No API keys and no model calls in the browser. Ask in German or English — the corpus language doesn't have to match the question language (cross-lingual retrieval).

text → chunks (480 chars, 90 overlap) → bge-m3 (1024-dim vectors) → cosine top-8bge-reranker top-3 → mistral-small-3.1 → answer + citations

1. Document corpus

index not built

The index lives client-side: for a few dozen fragments, brute-force cosine costs microseconds, while a vector database would add a network round trip per query. At 10⁵+ fragments this is where Vectorize / pgvector / Milvus goes in — only the retrieve() function changes.

2. Question

The answer appears here — grounded only in the ingested documents.

Retrieved fragments in context

Empty so far.

How it executed