explaingit

victorsteinbock/llama-cag-n8n-reworked

Analysis updated 2026-05-18

0PythonAudience · developerComplexity · 4/5LicenseSetup · hard

TLDR

A self-hosted Docker stack that lets a local AI model read a document once and answer unlimited later questions from a saved cache, without rereading it.

Mindmap

mindmap
  root((repo))
    What it does
      Reads document once
      Caches model state
      Answers from cache
    Tech stack
      llama.cpp
      Docker
      n8n
      FastAPI
    Use cases
      Support chatbot
      Coding agent spec lookup
      Private reference desk
    Audience
      Developers
      Teams with private docs
    License
      MIT permissive

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a support chatbot that answers strictly from a real product manual using a local model.

USE CASE 2

Let a coding agent like Claude Code query a large spec document without spending its context window.

USE CASE 3

Set up a private team reference desk for contracts or compliance documents that can't leave your network.

USE CASE 4

Ask repeated questions about a dense document without reprocessing it every time.

What is it built with?

Pythonllama.cppDockern8nFastAPIPostgreSQL

How does it compare?

victorsteinbock/llama-cag-n8n-reworked0xallam/my-recipe0xhassaan/nn-from-scratch
Stars00
LanguagePythonPythonPython
Last pushed2022-11-22
MaintenanceDormant
Setup difficultyhardmoderatemoderate
Complexity4/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires Docker plus a one-time warm-up read of each document (minutes on CPU), scanned PDFs need an extra text-extraction pass.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

llama-cag-n8n-reworked lets you ask questions about a document using a fully local AI model, without that model having to reread the whole document every time you ask something new. The idea it's built around is called Cache-Augmented Generation, or CAG. Normally, an AI model either has to process your entire document again for every question, which is slow, or it only sees small retrieved snippets from the document through a technique called RAG, which can miss connections between different parts of the text. This project takes a different path. You hand it a document once, and the model reads the whole thing a single time on your own computer. As it reads, it saves its internal understanding of the text, called the KV cache, to disk. From then on, every question you ask is answered by restoring that saved understanding rather than reading the document again, so answers come back in seconds instead of minutes, at no ongoing cost, and without any of the document leaving your machine. Everything runs inside Docker containers, so there's nothing to compile by hand on your own computer. Under the hood, llama.cpp's llama-server handles running the AI model and keeping the cache, a small FastAPI service coordinates the pieces, n8n handles automation and workflow logic, and PostgreSQL stores metadata. It's designed to work on Windows, macOS, or Linux. The README describes several situations where this approach works especially well: a support chatbot that needs to answer strictly from a real product manual instead of guessing, a way to let AI coding assistants like Claude Code ask questions about a large specification document without that document eating up their limited context window every session, and a private reference desk for a team's contracts, runbooks, or compliance documents that can't leave the building. It's also honest about where it doesn't fit. It's not meant for searching across thousands of documents at once, for documents too large to fit in the model's memory, for multi-user login systems, or for documents you'll only ever ask about once. The document needs to be readable as text, so scanned or image-based PDFs need an extra preparation step first. The local server also runs unauthenticated, relying on being reachable only from your own machine rather than the open internet. The project is released under the MIT license. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Help me set up this Docker stack to run Cache-Augmented Generation on my own document.
Prompt 2
Explain how the KV cache in this project lets me avoid re-reading a document for every question.
Prompt 3
Show me how to connect this project's ask_document tool to Claude Code over MCP.
Prompt 4
Walk me through the tradeoffs between this CAG approach and a typical RAG setup.

Frequently asked questions

What is llama-cag-n8n-reworked?

A self-hosted Docker stack that lets a local AI model read a document once and answer unlimited later questions from a saved cache, without rereading it.

What language is llama-cag-n8n-reworked written in?

Mainly Python. The stack also includes Python, llama.cpp, Docker.

What license does llama-cag-n8n-reworked use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is llama-cag-n8n-reworked to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is llama-cag-n8n-reworked for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.