LLM Hallucinations, Lack of Domain Specificity: LLMs (Generative AI) understand natural language questions or requests as input and produce answers in natural language. However, LLMs are prone to producing incorrect answers due to ‘hallucinations’. And, LLMs suffer from the lack of focused domain specificity in the answers they generate.

A new technique ‘Retrieval Augmented Generation’ or RAG on top of LLMs has been the go to solution to solve the issues and get improved answers from LLMs.
Semantic Matching & Contextualization: RAG utilizes a database of the embedding vectors of the text within documents from the domain of interest. The user query is transformed into an ‘embedding vector’ and semantically matched against the Vector DB of document vectors. Text corresponding to the matched vectors is collated into the context of the LLM prompt along with the user query. The LLM, now restricted to the context within which to find answers to the user query, is reined in to produce relevant answers.