Getting Started
A 10-minute walkthrough that takes you from a fresh checkout to your first chatbot answer about a real Pascal codebase.
Prerequisites
You need four pieces of software installed and reachable:
- mORMot 2 — clone or download
the source. The
src/tree is what the project compiles against. - A Pascal compiler — either:
- FPC 3.2.2+ with
Lazarus (
lazbuildon PATH). - Or Delphi 11+ (RAD Studio).
- PostgreSQL 18 with the pgvector extension. On Windows install PostgreSQL via the EDB installer, then add pgvector either through Stack Builder or by building it from source.
- Ollama — runs locally as a single executable. Pulls the embedding and generative models on demand.
Pull the models
The default embedder is embeddinggemma, a 300 M-parameter Google model
trained on a corpus that includes code:
ollama pull embeddinggemma
For chat (optional, only needed for 03_chat_cli):
ollama pull gemma3:1b # ~815 MB, fast
# or
ollama pull gemma4:e2b # ~1.6 GB, higher quality
Create the test database
Pgvector lives as a PostgreSQL extension; create a database and enable it once:
CREATE DATABASE mormot2_pgvector_test;
\c mormot2_pgvector_test
CREATE EXTENSION vector;
Configure mORMot 2 path
The project ships an .claude/mormot2.config.json template that the
build scripts read. Point it at your mORMot 2 clone:
{
"mormot2_path": "C:/Users/you/.../mORMot2",
"mormot2_doc_path": "C:/Users/you/.../mORMot2/doc",
"compiler": "auto"
}
Build
From the project root:
# Run the unit + live test suite
lazbuild --build-mode=Default --build-all test\test_runner.lpi
# Build the three CLI programs
lazbuild --build-mode=Default --build-all examples\01_ingest_mormot2.lpi
lazbuild --build-mode=Default --build-all examples\02_query_cli.lpi
lazbuild --build-mode=Default --build-all examples\03_chat_cli.lpi
The binaries land under build\.
Set runtime variables
The CLIs accept all configuration as flags, but the test suite reads env vars. Once both are set the same env carries you through ingest, query, chat, and tests:
$env:MORMOT2_PGVECTOR_LIBPQ = "C:\Program Files\PostgreSQL\18\bin\libpq.dll"
$env:MORMOT2_PGVECTOR_TEST_HOST = "localhost:5432"
$env:MORMOT2_PGVECTOR_TEST_DB = "mormot2_pgvector_test"
$env:MORMOT2_PGVECTOR_TEST_USER = "postgres"
$env:MORMOT2_PGVECTOR_TEST_PASS = "..."
$env:MORMOT2_PGVECTOR_OLLAMA_URL = "http://localhost:11434"
$env:MORMOT2_PGVECTOR_OLLAMA_MODEL = "embeddinggemma"
Ingest a small subset
Start with one file so you can see the output before committing to a multi-minute run:
build\01_ingest_mormot2.exe `
--src "C:\path\to\mORMot2\src\orm\mormot.orm.client.pas" `
--pg "host=localhost;port=5432;dbname=mormot2_pgvector_test;user=postgres;password=..." `
--libpq "C:\Program Files\PostgreSQL\18\bin\libpq.dll" `
--model "embeddinggemma" `
--reset
You should see something like files=1 chunks=73 rows=73 elapsed=10125ms.
Query
build\02_query_cli.exe `
--pg "host=localhost;port=5432;dbname=mormot2_pgvector_test;user=postgres;password=..." `
--libpq "C:\Program Files\PostgreSQL\18\bin\libpq.dll" `
--model "embeddinggemma" `
--query "How do I serialize a TOrm to JSON?" `
--top-k 3
Output: ranked chunks with cosine similarity, tsvector rank, combined score, and a 200-character excerpt per result.
Chat
The chat CLI retrieves chunks, builds a RAG prompt, and forwards it to a local LLM:
build\03_chat_cli.exe `
--pg "host=localhost;port=5432;dbname=mormot2_pgvector_test;user=postgres;password=..." `
--libpq "C:\Program Files\PostgreSQL\18\bin\libpq.dll" `
--model "embeddinggemma" `
--query "What is TRestOrmClient and how does it relate to TRestClientUri?" `
--top-k 5 `
--llm-url "http://localhost:11434" `
--llm-model "gemma4:e2b"
Provenance lines (one per retrieved chunk, with file:line ranges) go to
stderr so you can pipe stdout into another tool while still seeing
where each fact came from.
Next
- Read Concepts for a 5-minute primer on vector search and what the chunker actually does.
- Read CLI Reference for every flag.
- Read Library Guide if you want to embed the pieces into your own program rather than shell out to the CLIs.