
The answer starts with your documents.
RAG in Delphi
Learn to build AI assistants that answer questions using your documents
Build a Delphi assistant that retrieves information from your documents and lets you check the sources behind its answers.
This book is being prepared in Brazilian Portuguese.
A complete view of the book.
RAG in Delphi addresses a challenge in business applications: finding rules stored in documents and checking whether an answer respects them. It introduces retrieval-augmented generation and develops a document assistant using Delphi 13 and VCL for Windows, with fictional Aurora store procedures as its learning scenario.
The planned journey spans four parts and 16 chapters, covering TXT, Markdown, DOCX, PDF, OCR, chunking, lexical search, embeddings, and hybrid retrieval. Local persistence, model integration, and source presentation lead into evaluation of retrieval, answers, permissions, and costs. Thirteen appendices contain complete source code; the public examples evolve alongside the manuscript review.
Does this situation sound familiar?
Your system records operations, but rules live in manuals, PDFs, and procedures. When a delivery quantity differs from the order, a plausible answer may assign an operator authority reserved for a supervisor. How do you find the current rule and check the generated answer?
From questions to evidence, through Delphi.
Follow the construction of a document assistant in Delphi 13 and VCL: prepare files, retrieve relevant passages, assemble context, and present answers with sources. Learn to recognize when the documents cannot support an answer.
“A genuine source must still support what the answer claims.”
Answers begin with the right questions.
Questions explored through context, criteria, and examples.
When should keyword search and vector similarity be combined?
How can you check whether a citation actually supports an answer?
How should restricted documents and questions without sufficient evidence be handled?
A structured journey that helps you move forward.
Concepts and applications presented in a coherent sequence.
Foundations and architecture
Understand the path of a question and separate responsibilities in Delphi.
Document reading and OCR
Read TXT, Markdown, DOCX, and PDF; recognize text in images and examine extraction dependencies and limitations.
Chunks and retrieval strategies
Prepare chunks, compare BM25 with embeddings, and combine results through hybrid retrieval.
Persistence and updates
Reopen the local collection, track versions, and avoid reusing incompatible content or vectors.
Context, models, and VCL
Integrate models, organize evidence, and present answers with sources in a Windows application.
Evaluation and responsible use
Compare claims with evidence and examine document access, performance, costs, and insufficient information.
Planned book structure
Explore the 4 parts and 16 planned chapters. Titles may be refined during editorial review.
View chapters16 chapters
Part I — Foundations and the first assistant
- When AI needs your documents
- How a RAG system works
- Project architecture in Delphi
Part II — Document preparation and retrieval
- Reading TXT, Markdown, and DOCX, normalization, and metadata
- Extracting text from PDF
- OCR for images and scanned documents
- Splitting documents into chunks
- Keyword search and relevance
- Embeddings and vector similarity
- Persistence, updates, and hybrid retrieval
Part III — From evidence to answers
- Direct integration with AI models
- Context, answers, and sources
- A document assistant in VCL
Part IV — Quality and real-world use
- Evaluating retrieval and answers
- Document security and permissions
- Performance, costs, and implementation limits
Depth to understand. Clarity to keep moving forward.
A progressive Delphi 13 and VCL project for Windows
One consistent document scenario with verifiable fictional procedures
Thirteen appendices with complete source code and an evolving public repository
Evaluation of failures and limitations alongside implementation
Find your place in this book.
Delphi developers who want to integrate document queries into business applications.
What you need to benefit from the book
✓Knowledge of Object Pascal, classes, and basic file handling
✓Delphi 13 or later and Windows to follow the VCL examples
✓PDF, OCR, and model dependencies are introduced at the relevant stages
This may not be the right book if…
—Readers seeking an introduction to Delphi programming
—Readers expecting a finished commercial assistant or guaranteed correct answers
Receive resources and updates about RAG in Delphi.
Sign up for content, samples, and new resources related to the book.

RAG in Delphi is coming soon.
Official links will be published as soon as the editions are available.
The reading continues over there.
Follow Books de Régys for excerpts, new releases, and a look behind the books. The profile is in Portuguese.


