Benchreads

How to become an AI consultant · Module 02 of 12 · 10 minutes

Generative AI, language models and RAG

How large language models work, why they hallucinate and how to connect them to company knowledge with retrieval-augmented generation.

Since ChatGPT appeared at the end of 2022, generative AI has been the topic clients ask about most often. Large language models write, summarise, translate and program. But they also invent facts, do not know the company’s knowledge and can be manipulated. Anyone who advises on them must be able to explain how these models work, when to connect them to the company’s own data and how to get quality and risks under control.

01How a language model works

A large language model (LLM) is trained to predict the next piece of text. For this purpose, text is broken down into tokens, which are words or parts of words. The basis of almost all of today’s models is the transformer architecture, which researchers at Google presented in 2017 in the paper “Attention Is All You Need”. It makes it possible to weight the relationships between all the words in a text at the same time.

Training takes place in stages. In pre-training, the model learns language and world knowledge from huge amounts of text. It is then tuned with examples and human feedback to follow instructions and give helpful answers. What the model “knows” is stored in its parameters and ends at its training cut-off. It does not know more recent events or internal documents.

02Why models hallucinate

A language model produces the most probable continuation, not the true one. If it does not know an answer, it often still produces a plausible-sounding text, with invented figures, sources or legal sections. This is called hallucination. It can be reduced but not completely ruled out.

For consultants this leads to a simple test question for every use case: what happens if the answer is wrong, and who notices? A draft marketing email that a person reads anyway can tolerate errors. An automatic answer to customers about insurance terms cannot.

03How to connect company knowledge

There are three ways to make a model usable for your own tasks. Prompting means giving the model the necessary information and examples in the instruction. Fine-tuning means training a model further with your own examples, which is useful mainly for style, format or very specific tasks. And retrieval-augmented generation, RAG for short, connects the model to a search in your own documents.

RAG was described in 2020 by researchers at Facebook AI and is now the standard pattern for knowledge assistants. The process: documents are broken down into sections and stored as vectors (embeddings) that represent their meaning. When a user asks a question, the system searches for the most relevant sections and passes them to the model with the instruction to answer only on that basis and to name the sources.

  • Prompting: fast and cheap, good for general tasks.
  • RAG: when current or internal knowledge is needed and sources should be traceable.
  • Fine-tuning: when style, format or a specialist field should be learned permanently, not to keep facts up to date.

04Why RAG projects fail

Most problems lie not in the language model but in the documents and the search. Outdated, contradictory or poorly structured documents lead to poor answers. If tables and sections are split clumsily, the search does not find the decisive paragraph. And permissions have to be considered: an assistant must not show an employee content that they would not be allowed to open in the original.

That is why every project needs a test set: 100 to 200 real questions with verified answers. You use it to measure whether the search finds the right sources and whether the answers are correct, and you measure again after every change.

05Security and agents

Language models can be manipulated by injected instructions, for example by text in a document or web page that asks the model to ignore its rules. The OWASP list of the most important risks for LLM applications puts this prompt injection in first place. The more a system is allowed to do, the greater the risk.

This applies especially to agents, meaning systems that do not just answer but use tools: writing emails, querying data, triggering orders. The rule of thumb for consulting: keep permissions as narrow as possible, require confirmation by a person before any action with external effect, and log everything.

Example

Knowledge assistant for an insurance sales force

An insurer wants to support its field sales force with an assistant that answers questions about tariffs and terms. Instead of retraining a model, the team builds a RAG solution on the current policy terms. Every answer names the source passage so that the agent can check it.

The first test with 150 real questions shows: the answers are good when the right document is found, but for older tariff generations the search often picks the wrong version. The solution is not a better model but better metadata: period of validity and tariff generation on every document. The figures and the process are an example.

Typical mistakes

  • Retraining a model to keep facts up to date, even though RAG can do this better and more cheaply.
  • Starting without a test set and judging quality by feel.
  • Forgetting the permissions of the original documents in the assistant.
  • Allowing agents to take actions with external effect without human confirmation.

+Exercise

Collect 20 typical questions that employees ask in one area of your company and note for each one which document contains the answer. How many answers are clear, and how many are found in several contradictory documents? That is your first estimate of how well a RAG assistant would work there.

+Self-check

QuestionWhen is RAG better than fine-tuning?

When the model should use current or internal knowledge and answers must be traceable with sources. Fine-tuning is better suited to style, format and specialist tasks.

Start the test: 30 questions

QuestionWhy do language models hallucinate?

Because they produce the most probable continuation of a text, not the verified truth. If knowledge is missing, a plausible-sounding text is produced anyway.

Start the test: 30 questions

QuestionWhat is prompt injection?

Injected instructions, for example in documents or web pages, that get a language model to circumvent its rules. OWASP lists it as the most important risk for LLM applications.

Start the test: 30 questions

Module test

30 questions with instant feedback and explanations. At 80 percent or more, you have it.

Start the test

+Keep learning

How to cite this page

APA (7th edition)

Benchreads. (2026). Generative AI, language models and RAG. Learning path: How to become an AI consultant. Retrieved 25 November 2026, from https://benchreads.com/en/learning-paths/become-an-ai-consultant/generative-ai-llms-and-rag/

Benchreads is a secondary source. For academic work, also cite the original sources named in the text. You are welcome to link to this page in course materials.

Last updated: 25 November 2026. Carefully researched, but without guarantee. Not legal, tax or investment advice. Disclaimer