Lattice makes retrieval-augmented generation visible. Add documents by pasting text or uploading .txt / .md / .csv / .json files, choose a chunking strategy (fixed word windows, sentence-aware or paragraph-aware) with adjustable size and overlap, and watch the index rebuild instantly. Every step happens in the browser with code you can read in one sitting.
The embeddings are a real stand-in written from scratch: TF-IDF weighted, signed feature-hashed bag-of-words vectors (optional bigrams, 256 to 2048 dimensions) compared with cosine similarity. It is lexical rather than neural, which is exactly why it is easy to inspect. The chat embeds your question the same way, retrieves the top-k chunks above a similarity threshold, and writes an answer with numbered citations.
If nothing relevant is found it refuses instead of guessing.
The inspector explains the result: a per-document chunk map with overlap stripes, a list of every chunk with its retrieval score, a 2-D PCA vector map showing your question and the chunks it pulled in, and a detail view with top TF-IDF terms, a vector heat strip and nearest neighbours. The generation step sits behind one function in js/ai.js, with a documented OpenAI-compatible example and notes for swapping in neural embeddings.
Highlights
- Add documents by paste or upload; chunk by words, sentences or paragraphs with live size and overlap sliders
- Real TF-IDF + signed feature-hashing embeddings and cosine search, written from scratch (no libraries)
- Chat answers with numbered citations that open the source chunk; refuses when nothing relevant is retrieved
- Chunk inspector: chunk map with overlap stripes, per-chunk scores, vector heat strip, top terms, neighbours
- 2-D PCA vector map showing your query and retrieved chunks
- Top-k, minimum similarity, dimensions, bigrams and stop-word controls
- Export the index (chunks + vectors) as JSON and the conversation as Markdown
- Generator behind one function with an OpenAI-compatible example; no keys in code
mammoth templates


