LLM integration for enterprise RAG architecture follows this sequence: source data is collected and cleaned, documents are split into meaningful chunks and written to vector and keyword indexes via embeddings, at query time only the content the user is authorized to see is retrieved through hybrid search and reranking, and that content is then passed to the LLM as context to generate an answer that cites its sources. Access control, masking, logging and evaluation layers are an integral part of this flow.
What is RAG and why is it different in an enterprise setting?
RAG (Retrieval-Augmented Generation) is an approach that lets a language model retrieve relevant passages from an external knowledge source before generating an answer. The concept was defined in the RAG paper by Lewis et al., published in 2020. In an enterprise setting, the issue is not just getting the right answer; access control, auditability and regulation matter just as much.
At a bank or a large manufacturer, knowledge lives in scattered sources such as SAP, file servers, contract archives, wiki pages and product documentation. Each source has its own access rules. That is why enterprise RAG is more of a data platform project than a general-purpose chatbot. In the data projects we run with large organizations, the most time-consuming work is not connecting the model but preparing the data and mapping out the authorization model.
How it differs from fine-tuning
Fine-tuning changes the model's weights. RAG, on the other hand, adds knowledge at query time without touching the model. Because enterprise knowledge changes often, RAG is more manageable in terms of updates, source citation and deletion (for example, removing a withdrawn regulation from the index). The two methods are not mutually exclusive; using light tuning for tone and format and RAG for knowledge is a common combination.
LLM integration for enterprise RAG: reference layers
A good enterprise RAG architecture is divided into six layers. Keeping the layers independent reduces the need for rewrites when the model or the vector store changes.
| Layer | Role | Typical tools | Decision point |
|---|---|---|---|
| Data sources | Collecting documents, databases, emails and wiki content | Connectors, Kafka, ETL | Which sources are in scope? |
| Preparation (ingestion) | Converting to text, cleaning, chunking, adding metadata | OCR, parsers | Chunk size and overlap |
| Index | Generating embeddings, vector and keyword indexes | pgvector, Qdrant, OpenSearch | Is hybrid search needed? |
| Retrieval | Candidate selection, access filtering, reranking | BM25 + vector, cross-encoder | How many candidates, how many chunks? |
| Generation | Building the prompt, calling the LLM, citing sources | vLLM, Ollama, cloud API | Cloud or on-premises model? |
| Governance | Access control, logging, masking, evaluation | IAM, SIEM, evaluation set | Which records are kept, and for how long? |
Data flow is not one-way. Changes in source systems (a new document, a deleted document, changed permissions) should flow into the preparation layer as events. If the organization already has an event infrastructure such as Kafka, using it for index updates keeps the index much fresher than nightly batch jobs.
Step-by-step integration plan
1. Define the use case and the data inventory
Instead of "all company knowledge," pick a single use case: internal policy questions, technical support documentation or loan procedures, for example. Identify each source's owner, update frequency and sensitivity class. A solid data management foundation, meaning data classification and ownership information, speeds up this step considerably.
2. Define your chunking strategy
No single chunk size fits every document type. Regulations should be split by article, contracts by section, and FAQ content as question-answer pairs. For plain text, chunks of a few hundred tokens with a small overlap between them are a common starting point; the right value is found by testing against your own question set. Each chunk should carry metadata such as document name, section heading, date, version, owner and access group. Parsing quality for tables and scanned PDFs should be checked separately.
3. Choose an embedding model and a vector store
For Turkish content, choose a multilingual embedding model and benchmark it with your own questions. On the vector store side, there are plenty of options:
- PostgreSQL + pgvector: If the organization already has experience running PostgreSQL, it provides vector search without adding a new component; backups, access control and monitoring are handled by existing processes.
- Qdrant, Milvus, Weaviate: These are engines built specifically for vector search; they offer strong metadata filtering and horizontal scaling and can be deployed on-premises.
- OpenSearch or Elasticsearch: If already used for enterprise search, they combine keyword and vector search in a single engine.
4. Set up hybrid search and reranking
Vector search is strong at semantic similarity but can fall short on product codes, article numbers and abbreviations. That is why enterprise scenarios combine keyword search such as BM25 with vector search and merge the results with a method like Reciprocal Rank Fusion. In the first stage, for example, 20-50 candidates are retrieved; in the second stage they are reranked with a cross-encoder so that only the 3-8 most relevant chunks are passed to the LLM. Needlessly filling the context window raises both cost and the risk of wrong answers.
5. Write a prompt contract for grounding and citations
Instruct the model to rely only on the context provided, to say so explicitly when the answer is not in the context, and to cite every claim with a chunk ID. In the interface, show a clickable link to the source document and the relevant article. If the retrieval score falls below a certain threshold, the system should not guess but route the question to a human expert.
6. Put the LLM behind your own service layer
Make model calls from a central service layer, not directly from applications. That way model switching, rate limiting, caching, masking and logging are managed from a single point. This service is usually integrated with existing systems such as SAP, core banking and Kafka as part of custom software development.
Example scenario: an internal policy assistant for a bank
Let's make the flow concrete with a hypothetical example. A bank's compliance team wants to answer incoming questions about internal regulations and regulatory announcements quickly.
- Only published regulation PDFs and the announcement archive are taken as sources; draft documents are left out.
- Each document is chunked by article; each chunk is tagged with the document name, article number, effective date and the "compliance team" access group.
- When a user asks "What approval is required for the international wire transfer limit?", the system first filters by the user's group, then retrieves candidates through hybrid search and reranks them.
- The LLM writes the answer based only on the retrieved articles and lists the article numbers as sources.
- For questions that fall below the threshold, the system does not generate an answer; it routes the question to the compliance team.
In this design, every answer is traceable. During an audit, the question "which document was this answer based on?" can be answered from the logs.
Choosing an LLM: on-premises or cloud?
Choosing an LLM is not a one-time decision; the architecture should be built so that the model can be swapped out.
| Criterion | On-premises (vLLM, Ollama) | Organization's own cloud account | Managed cloud API |
|---|---|---|---|
| Data control | Highest; data never leaves the organization | High; network and access stay with the organization | Depends on the contract and region choice |
| Time to start | Requires hardware procurement | Medium | Fastest |
| Operational burden | GPUs, updates and monitoring handled in-house | Shared | Low |
| Cost structure | Mostly up-front investment | Usage-based infrastructure | Per-token pricing |
| Model quality | Limited to open-weight models | Depends on the choice | Widest range of options |
In on-premises scenarios, vLLM is preferred for high-concurrency production services, while Ollama is preferred for development and small-scale deployments. In a hybrid approach, sensitive data is processed by a local model, while masked or public content can be routed to models in the organization's cloud solutions account.
Managing cost and latency
- Embeddings are mostly generated once, during indexing; the main recurring cost is the LLM call per query.
- Shortening the context sent to the LLM lowers both token cost and time-to-first-token latency.
- Use a semantic cache for frequently asked questions.
- Set up a routing layer that sends simple questions to a small model and complex ones to a large model.
- Measure the latency budget layer by layer: search, reranking and generation times should be tracked separately.
Security, authorization and KVKK compliance
The most common risk in enterprise RAG is a document the user would not normally be able to see leaking into an answer. To prevent this, access control must be applied at the retrieval stage, before anything reaches the LLM.
- Document-level permissions: Each chunk's access group is stored in its metadata; queries are filtered by the user's identity and groups. Permission changes in the source system are synced to the index.
- Personal data masking: Fields such as Turkish national ID numbers (TCKN), IBANs, phone numbers and addresses are masked before indexing or before being sent to the LLM. For obligations, KVKK resources and the organization's legal department should be the reference.
- Data location: The region where data is processed, and whether the model provider uses the data for training, are clarified by contract.
- Prompt injection: Indexed documents are untrusted input too. These risks are covered in the OWASP Top 10 for LLM Applications.
- Risk management: For enterprise governance, the NIST AI Risk Management Framework is a good starting point.
- Audit trail: The question, retrieved chunk IDs, the model used and the answer are logged together with the user's identity, in line with the retention policy.
Measuring quality and monitoring
A RAG system is not a product you set up once and walk away from. Measure success at three levels:
- Retrieval: Does the right document show up in the top five results? Metrics such as Recall@k and MRR are used.
- Answer: Is the answer faithful to the context (faithfulness), relevant to the question, and is the source cited correctly?
- Operations: Latency, cost per query, error rate and "no answer found" rate.
Build a golden dataset of 50-100 questions prepared by subject-matter experts, and run regression tests against it after every index, chunking or prompt change. Open-source evaluation tools such as Ragas and LLM-based evaluators speed up the process, but they do not replace human review of a sample. Tracking these metrics on business intelligence dashboards lets non-technical stakeholders follow the system too.
Notes from the field: common mistakes
While building the retrieval layer for the Copilot in our own product, CentraQL, and in enterprise data projects, we have seen first-hand how the following mistakes degrade results:
- Indexing uncleaned, outdated and contradictory documents; if there are three versions of the same topic, the model cannot tell which one is valid.
- Trying to enforce access control after the answer has been generated.
- Declaring that it "works well" without an evaluation set.
- Applying a single chunk size to all document types.
- Relying solely on vector search and overlooking exact-match needs such as article numbers and product codes.
- Scattering model calls across applications and not setting up central logging.
Our experience is that a small evaluation set prepared together with the data owners makes a bigger quality difference than the choice of model.
Conclusion
Enterprise RAG success depends less on model choice than on data quality, chunking and search design, the authorization model and measurement discipline. An architecture that starts with a narrow use case, keeps its layers separate and ties every answer to a source is ready for both regulation and growth. BIART Bilişim works with banks and large organizations using a technology-agnostic approach. Let's work together on a RAG plan that fits your existing infrastructure and respects KVKK requirements: Get in Touch.
Frequently asked questions
What is the difference between RAG and fine-tuning?
RAG retrieves context from enterprise documents at query time without changing the model. Fine-tuning, on the other hand, trains the model's weights. For frequently changing enterprise knowledge, RAG is generally a more manageable approach that can be kept up to date and can cite its sources.
Does enterprise RAG always require a separate vector database?
No, it is not mandatory. Organizations using PostgreSQL can start with pgvector, and those using OpenSearch or Elasticsearch can start with their existing search engine. Dedicated engines such as Qdrant or Milvus stand out when high volume and advanced filtering are needed.
Can a RAG system be KVKK-compliant?
Yes, when designed correctly. It requires masking of personal data, document-level access filtering, an audit trail and control over where the data is processed. For a legal assessment, the organization's KVKK officer should be consulted.
Should we choose an on-premises LLM or a cloud API?
If data cannot leave the organization, an on-premises model with vLLM or Ollama is preferred. A cloud API suits a fast start and the widest choice of models. Many organizations build a hybrid setup that processes sensitive data locally and masked data in the cloud.
Does RAG completely eliminate hallucinations?
No, but it can reduce them significantly. The risk is managed through mandatory source citation, declining to answer when the retrieval score is low, and regular evaluation sets.
Photo: Albert Stoynov · Unsplash · Unsplash License




