网页 综合 更新时间 2025-07-30 20:42:47

What is Retrieval Augmented Generation (RAG)? The Key to Smarter, More Accurate AI | DigitalOcean

自动蜘蛛 www.digitalocean.com 正文约 6000 字
What is Retrieval Augmented Generation (RAG)? The Key to Smarter, More Accurate AI | DigitalOcean
Featured AI Products
Build, deploy, and scale cloud compute resources
Containers and Images
Safely store and manage containers and backups
Fully managed resources running popular database engines
Management and Dev Tools
Control infrastructure and gather insights
Secure and control traffic to apps
Help protect your account and resources with these security features
Store and access any amount of data reliably in the cloud
Security and Networking
Web and App Platforms
Businesses that provided automated customer support, content generation, or AI-driven services relied on pre-trained models, including large language models (LLMs) like GPT-2, which gained traction around 2018. These models generated responses based solely on the data on which they were trained. While effective for handling static tasks, these models had limitations for dynamic scenarios. They could not access updated information, making them less adaptable to changes in business needs, like product launches or policy updates. This limitation persisted until 2020, when retrieval augmented generation (RAG) was introduced. RAG allowed users to retrieve information from external knowledge sources, improving relevance and accuracy in AI-generated responses.
For instance, if you built a translation tool using an LLM, the model would only provide translations based on the training data it had seen. If a new term or phrase emerged after the model was trained, the translation tool wouldn’t have access to this information and might produce inaccurate or outdated translations. This could hinder effective communication with international clients or partners, resulting in misinterpretations of key messages, marketing materials, or contracts. With the introduction of RAG, companies can now structure their LLMs to retrieve relevant information from external knowledge sources, ensuring that responses remain accurate and up to date. Besides retrieving the latest information, RAG could also provide specialized information, such as accessing a company’s support tickets (to provide tailored responses based on previous inquiries), where the focus is on retrieving detailed and contextually relevant data. Read on to learn about RAG, how it works, and its benefits.
Retrieval Augmented Generation (RAG) is a technique that combines an AI language model with a retrieval system: when asked a question, the system first retrieves relevant documents or data, and then the AI model uses that information to produce a more accurate, context-informed answer.
RAG addresses the limitations of standalone language models (which have fixed training data) by allowing real-time access to external knowledge sources, thus keeping answers up-to-date and grounded in factual references.
By using RAG, AI applications like chatbots or Q&A systems become smarter and more reliable—providing answers that can be traced back to source documents—making it a key approach for building AI systems that require both the creativity of generation and the accuracy of retrieved knowledge.
RAG is a technique in natural language processing and artificial intelligence that combines two components: information retrieval and text generation.
In this approach, external documents or data sources from web pages/research papers/proprietary company datasets are first retrieved in response to a query (based on a user’s input). This retrieval process uses a vector database, where the data is pre-processed into vector embeddings. These embeddings capture *semantic meanings, allowing for efficient search and retrieval of the most relevant documents based on the query. Then, generative models like generative pre-trained transformers (GPT) or bidirectional and auto-regressive transformers (BART) use the retrieved information to produce a coherent and relevant response. RAG builds more informed and accurate outputs, combining existing knowledge bases with generative capabilities.
*Semantic meaning deciphers the relationships between words and their usage in context. For example, the words “bank” (as a financial institution) and “bank” (as the side of a river) have different meanings depending on the context.
The user initiates this step by providing a query through a user interface like a chatbot, search bar, or API request. Technically, the input is captured and processed by the system, mostly using natural language processing (NLP) techniques like tokenization (breaking down the query into smaller units like words or phrases), stemming/lemmatization (reducing words to their base forms), and named entity recognition (NER) (identifying key entities like dates, names, or locations) to understand the context and intent of the query.
At this stage, the RAG system embeds the query into vectors — converting the text into numerical representations that can be used for document retrieval. These vectors enable the RAG system to perform similarity searches against a vector database provided by the organization, which stores pre-embedded document representations. This query embedding step allows the RAG system to perform vector-based similarity searches against the document corpus. The input query is passed into the RAG framework via REST APIs or integrated systems that accept text inputs from web applications, mobile apps, or other platforms for further processing.
Once the list of documents is identified based on relevance to the user’s query, the system searches within a pre-built knowledge base, which could include internal company documents, databases, or pre-scraped external repositories (such as Wikipedia). The system compares the query embeddings with document embeddings, applying vector scoring techniques to rank and retrieve the most relevant information. This process ensures that only the most pertinent documents are selected. The retrieved documents provide factual data or context to support the response.
The retrieved contexts can be in any one or a combination of the formats—structured data (text, JS
访问原文 返回搜索 https://www.digitalocean.com/resources/articles/rag
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。