Insights

RAG or fine-tuning: which fits when an LLM is to work with company knowledge?

RAG fits when the model is to answer questions from company knowledge that changes and has to be backed by sources: at run time the application retrieves the relevant passages and passes them to the model. Fine-tuning fits when the model is to master a behaviour reliably, such as a format, a style or a classification. The two can be combined. For company knowledge, RAG is usually the starting point.

Deutsche Fassung

Background

Two ways of adapting a model to the company

A language model does not know a company’s documents, policies and data. RAG (retrieval-augmented generation) closes this gap at run time: for each question the application retrieves the relevant passages from the connected sources and passes them to the model together with the question. The model itself stays unchanged.

Fine-tuning changes the model: it is further trained with examples of input and desired output and thus adopts a behaviour permanently.

Both are preceded by prompt engineering: clear instructions and examples in the prompt. Often only then does it become clear what is still missing.

Comparison

RAG and fine-tuning compared

RAG and fine-tuning compared
CriterionRAGFine-tuning
What changesThe context of the request. The model stays as it is.The model itself: it is further trained with examples.
CurrencyNew documents are usable as soon as they are in the index.New knowledge requires retraining.
SourcesAnswers can be backed by the retrieved passages.The model names no source for what it has learned.
Access rightsCan be applied per user at retrieval.What has been learned is available to all users of the model.
StrengthQuestions about knowledge that changes.Consistent behaviour: format, style, terminology, classification.
EffortPrepare data, operate search and index.Create training examples, training and tests per model version.

General classification, not a statement about individual providers.

Decision

When which route fits

RAG

An assistant answers questions about policies, contracts or product documentation. The content changes, and every answer is to name its source.

Fine-tuning

The model is to classify inputs by the same scheme every time or produce text in a fixed format and terminology.

Both

RAG supplies the current knowledge, a fine-tuned model keeps to format and terminology.

Approach

Four steps to the decision

  1. Start with prompt and examples

    Check how far an unchanged model gets with clear instructions.

  2. Connect knowledge via RAG

    Prepare sources, build search and return answers with sources.

  3. Measure quality on tasks

    Test the results on concrete tasks from daily work and record where they fall short.

  4. Use fine-tuning deliberately

    Fine-tune when a behaviour is not stable despite good prompts and suitable sources.

Digital David

What Digital David contributes

LLM engineering

RAG systems, fine-tuning, prompt engineering, model selection and vector database integration.

Models and tools

We work with models from OpenAI, Anthropic and Mistral as well as Azure OpenAI, plus LangChain, LlamaIndex, Pinecone and Weaviate. The selection follows your requirements.

Knowledge in our own product

Factify supports research and customer processes with open interfaces and traceable processing logs.

Good to know

Common questions

Answers from our AI engineers to questions that come up before a project.

Discuss your question
Can a model learn our company knowledge through fine-tuning?

Fine-tuning is suited to behaviour, less so to facts. Learned knowledge cannot be backed by a source and cannot be restricted per user. For knowledge, RAG is the right route.

Do we need a vector database for RAG?

For semantic search, content is stored as vectors. This is done by a dedicated vector database or by an extension of an existing database.

Which model fits our use case?

The selection follows your requirements. At Digital David, model selection is part of LLM engineering.

How do you handle our data?

We clarify data sources, access rights, hosting and review processes as part of the architecture. Requirements for data protection, governance and human approvals are taken into account in the specific project.

Which knowledge should your model work with?

Our AI engineers discuss sources, quality criteria and the right route with you.

Discuss your project30 minutes with our AI engineers