A small, fully-local Retrieval-Augmented Generation demo. It indexes Markdown files and answers questions through a browser, using a local LLM (Ollama) and local embeddings. Every pipeline stage is hand-rolled on the Go standard library so you can read and learn how RAG works.
- Ingest: walk one or more docs dirs (
DOC_PATHS) → read*.md→ chunk → embed → in-memory vector store (persisted toINDEX_PATH, reloaded and incrementally updated on restart). - Retrieve: embed the question → cosine similarity → top-K chunks.
- Generate: build a prompt with retrieved context → chat model → answer.
- Serve: minimal web UI + JSON API.
- Go 1.22+ (tested with 1.27)
- Ollama running locally, with models pulled:
ollama pull nomic-embed-text(embeddings)ollama pull qwen2.5:7b(chat)
go build -o output/ask-my-docs .
./output/ask-my-docsFor development tasks, install Task and run task build
to build or task dev to start the development server. Run task prepare to
install the development tools used by the git hooks and enable those hooks.
Configuration can be provided via a config.yaml file and/or environment
variables (environment variables take precedence over file values).
Config file lookup order:
--config/-c /path/to/config.yaml(relative or absolute)config.yaml(orconfig.yml) in the current working directory- OS-specific global path:
- Windows:
%APPDATA%\ask-my-docs\config.yaml - macOS/Linux:
~/.config/ask-my-docs/config.yaml
- Windows:
The working directory can be overridden with --cwd /path/to/dir.
Example config.yaml:
doc_paths:
- ./docs
- ./more-docs
api_base: http://localhost:11434/v1
chat_model: qwen2.5:7b
port: 8080doc_paths can also be given as a single comma-delimited string (same format
as DOC_PATHS below) if you prefer not to use a YAML list.
Environment variables (override file values):
| Var | Default |
|---|---|
| DOC_PATHS | ./docs |
| API_BASE | http://localhost:11434/v1 |
| API_KEY | (empty) |
| CHAT_MODEL | qwen2.5:7b |
| EMBED_MODEL | nomic-embed-text |
| TOP_K | 4 |
| PORT | 8080 |
| CHUNK_SIZE | 800 |
| CHUNK_OVERLAP | 100 |
| MAX_FILES | 0 (no limit) |
| INDEX_PATH | ./index.json |
| INDEX_WATCH_SECONDS | 30 |
API_BASE may point at any OpenAI-compatible provider (OpenAI, LM Studio,
vLLM, ...).
Point DOC_PATHS at your own Markdown corpus — one folder, or a comma-delimited
list of folders in different locations on the device. For a fast first run over
a subset, use MAX_FILES:
DOC_PATHS=/path/to/docs MAX_FILES=50 ./ask-my-docsDOC_PATHS=/path/to/docs,/another/path/to/more-docs ./ask-my-docsmain.go minimal entrypoint shim (installability)
cli/run.go application logic + embedded web UI
cli/web/index.html chat UI (embedded)
cli/internal/config env- and config.yaml-based configuration
cli/internal/chunker text chunking
cli/internal/llm OpenAI-compatible client (embed + chat)
cli/internal/vectorstore in-memory cosine-similarity store
cli/internal/ingest document ingestion
cli/internal/rag RAG orchestration + prompt building
specs/ask-my-docs requirements, design, tasks
go test ./...