Artificial intelligence

RAG: building an AI assistant for your organisation’s documents

Retrieve before answering: sources, chunks, permissions, citations and evaluation for a maintainable documentation assistant.

Portocelo Networks SLPublished: 5 min read
Indexed documents feed permission-aware retrieval and a response supported by sources.

RAG means retrieval-augmented generation. The application searches authorised documents and gives relevant passages to a model as context for an answer. It does not need to incorporate every document into the model’s parameters.

This can make internal knowledge available, but it does not guarantee correctness. An outdated instruction, a missing page or a citation that does not support a claim can lead to a convincing but wrong answer.

The project is more than uploading PDFs: it needs curated sources, access controls and tests of whether the system can answer, cite and admit that information is missing.

Two paths: prepare knowledge and answer a question

Indexing runs when documents change; answering runs when somebody asks a question. Keeping the paths separate makes updates manageable and helps locate failures in extraction, retrieval or generation.

Conceptual architecture of document RAG

Indexing prepares passages; a query retrieves only authorised ones and carries their provenance into the answer.

  1. Documents

    Identified sources, versions and permissions.

  2. Extraction and chunking

    Text, tables and coherent units.

  3. Embeddings and metadata

    Search representations and verifiable provenance.

  4. Search index

    Vector and text search, not the source of truth.

  5. Authorised retrieval

    Apply identity and filters before fetching context.

  6. Model context

    Relevant passages with references.

  7. Answer and sources

    A checkable explanation or an explicit limit.

Vector search is one option and can be combined with text search and filters. The core principle is to retrieve before answering.

The research paper that introduced RAG combines retrieval and generation for knowledge tasks. An enterprise implementation must also solve permissions, versions and operations.

Inventory sources before generating embeddings

Identify which document is authoritative for each topic. If two manuals disagree, the system may retrieve both and blend their instructions. A knowledge owner must resolve current versions and historical archives.

  • Stable identifier and link to the source.
  • Version, effective date and owner.
  • Document type, language and scope.
  • Permissions and use restrictions.
  • A procedure for adding, updating and retiring material.

Check reading order and tables in PDFs. OCR adds another step for scans and must be evaluated. The document automation guide covers those checks.

Chunking divides documents into retrievable units. A fixed size can separate a rule from its exception. For example, a travel policy needs its spending limit, approval condition and exceptions together.

An embedding represents content numerically for semantic matching. Similarity is not proof of truth or relevance. Exact product codes may work better with text search, while differently worded questions may benefit from semantic search. Test a combined approach on real abbreviations, short queries and vague requests.

Permissions follow the document into the answer

A person’s identity determines which documents may enter retrieval. Filtering only the final screen is too late: a restricted passage in model context may leak into the response. Suggestions and shared caches must observe the same boundary.

Azure AI Search documents a security-filter pattern based on identities or groups. The application must bind the authenticated identity to that filter; a user must not be able to substitute an arbitrary group.

Access tests for a pilot
SituationExpected result
Two roles ask about one topicEach retrieves only permitted sources
Folder access is revokedThe change reaches the index and caches
A document instructs the model to reveal anotherThe text cannot alter permissions
A cited link needs accessOpening it checks identity again

External embedding or generation services may receive content. Decide that data flow before indexing. RAG does not automatically mean private AI.

Citations should enable verification

Each important claim needs a source that actually supports it, ideally linked to a page or section. A link to an entire hundred-page manual shifts most verification back to the reader.

Distinguish supported answers, contradictory sources and missing information. “I could not find this rule in the available documents” is a useful result with an escalation route. An application can check that cited identifiers were retrieved; evaluation must also check whether the passage supports the claim.

Three evaluations and an update procedure

Find which layer failed
LayerEvaluation questionIf it fails
ExtractionAre text and tables complete?Correct extraction or the source
RetrievalWas the needed authorised passage found?Review chunks, metadata and search
AnswerIs the explanation faithful and cited?Review context and answer checks

Prepare real questions with expected sources and questions without answers. Hold out some for testing changes. Include withdrawn documents, contradictions and unauthorised access attempts.

When replacing a document, withdraw old chunks or mark them inactive. Deletion policy should cover the index, storage and caches. Record index version and cited references while minimising personal data in logs.

When RAG is the wrong tool

Current stock or order status belongs in a transactional system, not a document index that may lag. Use deterministic tools for calculations. Fine-tuning can change model behaviour, but does not replace source updates or access control.

For a few well-organised files, conventional search may be enough. With many sources, recurring questions and an owner who can maintain the knowledge, a private knowledge assistant may merit a pilot.

From knowledge to a working process

Make your documents useful and verifiable.

We can assess sources, permissions and a representative question set before choosing the search architecture.

Discuss a knowledge assistant ↗

Sources and references

Do you have a similar process?

Tell us how it works. We can assess whether AI, automation, software or a combination makes sense.

Tell us about your process ↗
Portocelo Networks

Privacy preferences

We collect only what is needed to handle your enquiry. Here you can review and save this site’s privacy settings.

Essential preference

Only to remember your choice

When you save your choice, we remember it on this device for 180 days. It contains no name, email address or tracking identifier. You can delete it in your browser settings.

Analytics and advertising

Inactive

We do not load third-party measurement or advertising services. If this changes, we will ask for a new choice before enabling technologies that require consent.

What about contact form data?

It is used to answer your enquiry. Saving these preferences does not authorise marketing or replace the information and choice in the form. Email us with data protection questions.

ia@portocelonetworks.com