Skip to content

Latest commit

 

History

History
136 lines (113 loc) · 9.32 KB

README.md

File metadata and controls

136 lines (113 loc) · 9.32 KB

KíLín tutorials: start here

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.

Before opening a notebook

  1. Follow the operating-system setup instructions in the project README. Use Python 3.12, as required by pyproject.toml.
  2. Open the notebook in Jupyter from the project checkout. Select the Python interpreter in the checkout's .venv as its kernel. The initial setup cells check the environment; if they request a kernel switch, switch and rerun.
  3. Start with Tutorial 10 to check the computing backend. Choose auto, mlx (Apple Silicon), or torch where supported.
  4. 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.

Tutorials

Choose a learning path

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.

Where the examples get their data

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 under papers/.
  • 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 informative FileNotFoundError instead 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.

Runtime cost and data safety

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.

After a tutorial

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.