These notebooks explain the local KíLín assistant from model setup to
retrieval-augmented chat and extensions. They are intended for a source
checkout: they import the local kilin/ package and the repository's
setup/notebook.py helper. Each notebook can be opened independently.
- Follow the operating-system setup instructions in the project README.
Use Python 3.12, as required by
pyproject.toml. - Open the notebook in Jupyter from the project checkout. Select the Python
interpreter in the checkout's
.venvas its kernel. The initial setup cells check the environment; if they request a kernel switch, switch and rerun. - Start with Tutorial 10 to check the computing backend.
Choose
auto,mlx(Apple Silicon), ortorchwhere supported. - Cache chat and embedding models deliberately. Model IDs depend on the selected backend and may require substantial disk space and memory. Tutorial 20 explains inspecting and downloading Hugging Face models.
The prepare_notebook() helper may invoke uv sync or a platform
setup script to repair missing Python dependencies. That step can
require network access even when model downloads are disabled. Install
dependencies before working offline and review setup commands if
automatic package installation is not acceptable.
The notebooks that load models now use ALLOW_DOWNLOAD = False by default.
Set it to True only when you intend to access the network and download
missing weights. The Hugging Face cache is shared outside the checkout.
An already-cached model may still require a substantial first load.
Tutorials 140 and 150 use the download setting saved in each project
profile: newly created tutorial projects disable downloads, while
resuming a project preserves its existing setting.
- 10 · Setup: Check the environment and computation backend without loading a model.
- 20 · Hugging Face models: Inspect the model cache and optionally download a chat model.
- 30 · Model chat: Load a model, exchange messages, and release it.
- 40 · Repository files: Select the files KíLín will read from a repository.
- 50 · Source structure: Read source files and split their structural units into searchable chunks.
- 60 · Embeddings: Convert chunks and questions into vectors with an embedding model.
- 70 · Semantic retrieval: Rank chunks by similarity in meaning.
- 80 · Lexical retrieval: Rank chunks by matching words and identifiers without an embedding model.
- 90 · Code-aware retrieval: Find code through symbols and relationships such as calls and imports.
- 100 · Persistent indexes: Save retrieval indexes and reuse them when their inputs are unchanged.
- 110 · Hybrid ranking: Combine semantic, lexical, and code-aware rankings.
- 120 · Retrieval expansion: Add context for explicitly named files, functions, and code relationships.
- 130 · Source cards: Inspect scientific-paper cards, provenance, independent persistence, and four-channel source-first retrieval without loading a model.
- 140 · Project chat: Prepare or resume a project and ask questions with citations and saved history.
- 150 · Execution traces: Inspect the recorded inputs, outputs, retrieval steps, and timings of a session.
- 160 · Project types: Customize project types, instructions, and intents using JSON configuration.
- 170 · Conversation memory: Explore project-local indexing, Save/Like/Dislike, exclusion, branch origins, and verified historical recall using a model-free example.
- 180 · Custom tools: Explore a paper-summary tool and build a custom tool.
- 190 · Research-assistant capstone: Create a literature project from bundled example notes, evaluate offline retrieval and citations, and optionally run a complete RAG session.
| Goal | Recommended notebooks | Model needed? |
|---|---|---|
| Verify setup and inspect model availability | 10, 20 | No model loaded |
| Learn local file processing and retrieval without a language model | 40, 50, 80, 90 | No |
| Experiment with a local chatbot | 30 | Chat |
| Understand semantic retrieval and persistent indexes | 60, 70, 100 | Embedding |
| Combine evidence and examine retrieval guarantees | 110, 120 | Embedding |
| Inspect source-card indexing and source-first retrieval | 130 | No |
| Use the complete project-question-answering workflow | 140, 150 | Chat and embedding |
| Configure project behavior and conversation memory | 160, 170 | No for the memory exercise (deterministic stand-in vectors) |
| Design tools for research workflows | 180 | No for the main example; real-model section optional |
| Apply and verify the complete research workflow | 190 | No for the core checks; chat and embedding models optional |
If you only want an introduction to KíLín as an end user, start with 10, 20, and 140, then try the integrated example in 190. The intermediate notebooks explain the internals; they are not prerequisites for the GUI or project chat.
Most tutorials work with the included kilin/ Python package. The source
code is itself a realistic, reproducible example repository.
Tutorials 150 and 180 use literature PDFs:
- The complete supplementary article corpus, if available, lives under
_si_article_/literature_repo/, with PDF files underpapers/. - Populated
_si_article_/code_repo/and_si_article_/literature_repo/are intentionally absent from space-saving source ZIP exports. Their contents remain part of the full supplementary materials, not mandatory dependencies of the tutorial series. - When a paper is absent from that corpus, Tutorials 150 and 180 use the
small PDFs provided in
tests/fixtures/pdfs/. They tell you which file was selected. If neither location exists, the notebook raises an informativeFileNotFoundErrorinstead of silently choosing unrelated documents.
Tutorial 170 uses fictional saved conversation turns and a deterministic
stand-in embedding model; it does not download weights or call an LLM.
Tutorial 190 instead uses four small, fictional Markdown research notes
from tutorials/data/190_research_pilot/. Its deterministic steps work
without a language model; the full RAG run is explicitly opt-in. The
fictional measurements must not be cited as research findings.
For a real project, replace the example source directory with your own existing code or literature folder. The original source files are input; KíLín's managed state is written to a separate project workspace.
Embedding every chunk of a large repository can be slow. The early semantic
example works with a few source files; the advanced retrieval examples
start from the retrieval package and rag.py. Broaden include_paths
after checking the smaller examples. Some notebooks use embedding batches
to avoid processing the entire corpus in one model call.
Example workspaces and indexes are created below sandbox/, not in the
original source directory. Tutorials 150, 170, 180, and 190 automatically
choose a new numbered workspace if an earlier run exists; they do not
recursively delete an earlier one. The other tutorials may write to documented paths below sandbox/; inspect these paths before changing them. Do not add
sandbox/, Hugging Face model caches, or source PDFs to version control.
Traces may contain prompts, retrieved passages, model output, paths, and other sensitive information. A trace file may also contain the resumable conversation record. Keep workspaces private and review the trace-recording guide before deleting or sharing them. Disable detailed tracing in Tutorial 140 if not needed.
Every notebook closes model sessions used by its example. It is safe to restart the notebook kernel to release remaining memory. Saved indexes, project files, generated reports, and cached model weights are separate from the live model session. Deleting an example workspace discards its saved outputs and any conversation history in it; do so only intentionally.
The developer documentation explains the core architecture, configuration precedence, project data ownership, retrieval, and extension interfaces in greater detail.