Book cover: RAG in Delphi
Delphi & Artificial Intelligence

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.

Notify me when it is available

This book is being prepared in Brazilian Portuguese.

EditionIn preparation2026Book languagePortugueseBrazilFormatsComing soonComing soon
About the book

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.

The challenge

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?

The book’s approach

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.”
By the end of the book, you will be able to:
✓Prepare documents while preserving sources, metadata, and conditions
✓Split content into useful retrieval chunks
✓Compare lexical, vector, and hybrid retrieval
✓Persist and update the document collection in local files
✓Integrate models and present answers with sources in VCL
✓Evaluate evidence, permissions, latency, and answer limitations
Questions that guide the reading

Answers begin with the right questions.

Questions explored through context, criteria, and examples.

01

How can documents be prepared without losing sources and important conditions?

02

When should keyword search and vector similarity be combined?

03

How can you check whether a citation actually supports an answer?

04

How should restricted documents and questions without sufficient evidence be handled?

Inside the book

A structured journey that helps you move forward.

Concepts and applications presented in a coherent sequence.

01

Foundations and architecture

Understand the path of a question and separate responsibilities in Delphi.

02

Document reading and OCR

Read TXT, Markdown, DOCX, and PDF; recognize text in images and examine extraction dependencies and limitations.

03

Chunks and retrieval strategies

Prepare chunks, compare BM25 with embeddings, and combine results through hybrid retrieval.

04

Persistence and updates

Reopen the local collection, track versions, and avoid reusing incompatible content or vectors.

05

Context, models, and VCL

Integrate models, organize evidence, and present answers with sources in a Windows application.

06

Evaluation and responsible use

Compare claims with evidence and examine document access, performance, costs, and insufficient information.

Content in preparation

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

  1. When AI needs your documents
  2. How a RAG system works
  3. Project architecture in Delphi

Part II — Document preparation and retrieval

  1. Reading TXT, Markdown, and DOCX, normalization, and metadata
  2. Extracting text from PDF
  3. OCR for images and scanned documents
  4. Splitting documents into chunks
  5. Keyword search and relevance
  6. Embeddings and vector similarity
  7. Persistence, updates, and hybrid retrieval

Part III — From evidence to answers

  1. Direct integration with AI models
  2. Context, answers, and sources
  3. A document assistant in VCL

Part IV — Quality and real-world use

  1. Evaluating retrieval and answers
  2. Document security and permissions
  3. Performance, costs, and implementation limits
What makes this book different

Depth to understand. Clarity to keep moving forward.

01

A progressive Delphi 13 and VCL project for Windows

02

One consistent document scenario with verifiable fictional procedures

03

Thirteen appendices with complete source code and an evolving public repository

04

Evaluation of failures and limitations alongside implementation

Who this book is for

Find your place in this book.

Delphi developers who want to integrate document queries into business applications.

✓ Delphi developers familiar with Object Pascal✓ Professionals maintaining ERPs and business applications✓ Teams needing to query internal manuals and procedures✓ Developers seeking to understand and evaluate RAG from its foundations
Before you begin

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

An informed choice

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

Why this author, on this subject

Experience that gives the reading context.

Régys Borges da Silveira connects his experience with Delphi and business systems to document assistants, bringing together code, operational rules, and evaluation of AI answers.

Upcoming release

Receive resources and updates about RAG in Delphi.

Sign up for content, samples, and new resources related to the book.

Upcoming release

RAG in Delphi is coming soon.

Official links will be published as soon as the editions are available.

Instagram · @livrosregys

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.

Follow on Instagram ↗