- What a "local" language model is and why it matters for sensitive data.
- What RAG is — the technique that makes the AI answer from your documents instead of making things up.
- How to ask Claude Code to build the app step by step.
- How to run it, save it, and open it again another day.
Key concepts (in two minutes)
Before typing anything, let's understand what we're building. It's just three ideas.
Local language model
A "language model" is the brain that understands and writes text (the same kind of thing behind a well-known chatbot). Local means that brain is downloaded and runs on your own machine.
Why AI "makes things up" and how to avoid it
A model on its own answers from what it "remembers" from its training. Sometimes it gets it right, and sometimes it invents things with complete confidence (this is called hallucination). For legal topics, that's unacceptable.
RAG: giving the AI the right documents
The solution is called RAG (Retrieval-Augmented Generation). It works in two stages:
- Search: when you ask something, the system searches your documents for the passages most related to your question.
- Answer: it passes those passages to the model and tells it: "answer using ONLY this, and cite where you got it from."
Step by step
Step 1: install Ollama and download a model
Ollama is a free application. Download it from ollama.com and install it like any other program. When it's done, open the terminal and check that it responds:
ollama --version
Now download a model. We'll use a small, capable version that fits comfortably on an 8 GB laptop:
ollama pull qwen3:4b
We also need an "embeddings" model — the one that knows how to find similar passages:
ollama pull nomic-embed-text
Step 2: create the project folder
mkdir chatbot-legal cd chatbot-legal
Step 3: ask Claude Code to build the app
You're not going to write the program by hand. You'll describe what you want and Claude Code will build it. Start Claude Code inside the folder with claude and paste this request:
Step 4: add your documents
Copy into the documentos/ folder the PDFs you want to query: a collective agreement, the Workers' Statute, an internal regulation... You can drag them there with the file explorer.
Run it on your computer
With the documents in place, start the application (the README will tell you the exact command):
npm install npm run dev
In the terminal you'll see a local address, similar to http://localhost:3000. Open it in your browser, type a question about your documents, and press Enter.
If something goes wrong
- "command not found: ollama" — Ollama isn't installed or you need to reopen the terminal.
- Connection error — make sure Ollama is running (icon in the menu bar). Check with ollama list.
- Responds very slowly — normal on the first question. If your machine is modest, try ollama pull qwen3:4b and ask Claude Code to use it.
- Doesn't cite well or mixes documents — start with fewer PDFs and more specific questions.
Practice challenge
Ask Claude Code to add a button to clear the conversation, show the date of the law next to each citation, and try a more powerful model if your machine allows it.