# RAG

**Retrieval-Augmented Generation (RAG)** is a framework that combines traditional information retrieval with generative AI. It enables AI agents to generate contextually accurate and factually grounded responses by retrieving relevant information from a knowledge base or data source and using it to augment the reasoning process. [Learn More](https://docs.uptiq.ai/overview-of-genai/key-concepts/rag-retrieval-augmented-generation)

In UPTIQ AI Workbench, RAG is implemented using a sequence of components designed to manage and use data effectively in AI workflows. Below is a detailed explanation of each related concept:

### How to create a RAG?

{% embed url="<https://youtu.be/5bLNGmgCw5c>" %}
Create a RAG Container in UPTIQ AI Workbench.
{% endembed %}

### What is a Data Store?

* **Definition**: A **data source** is the origin of the data, which can be structured or unstructured.
* **Examples**:
  * **Unstructured**: Files such as PDFs, CSVs, images, or documents.
  * **Structured**: Databases such as PostgreSQL, MongoDB, or MySQL.
* **Purpose**: Data sources feed raw information into the system, which can later be processed and used for workflows.

### How to create a data store?

For details on **how to create a data store**, Watch the setup guide&#x20;

{% embed url="<https://youtu.be/5bLNGmgCw5c?t=26>" %}
How to create a data store.
{% endembed %}

### What is a Data Source?

* **Definition**: A **data store** in UPTIQ is an entity that groups multiple data sources together. It acts as an organizational layer, allowing developers to manage and access related data sources as a single logical unit.
* **Key Features**:
  * Supports the integration of multiple data sources.
  * Provides a unified interface for interacting with grouped data.
* **Example**: A single data store could include a combination of:
  * Product catalogs (from a MySQL database),
  * Policy documents (PDFs), and
  * Logs (CSV files).
  * Postgres Database cluster.

### What is a Vector Store?

* **Definition**: A **vector store** converts the content of a data store into vector embeddings and stores these embeddings using a vector database.
* **How It Works**:
  * Takes raw data from the data store (structured or unstructured).
  * Processes the data to generate vector embeddings using AI models.
  * Stores these embeddings in a vector database for efficient retrieval.
* **Purpose**: Vector embeddings represent the semantic meaning of the data, enabling similarity-based searches. This is crucial for identifying and retrieving contextually relevant information.
* **Underlying Technologies**: Vector databases by renowned providers like MongoDb, Pinecone, Postgres.

### What is a RAG Container?

* **Definition**: A **RAG container** is the entity that links to the vector store and exposes its capabilities for use in workflows via a special **RAG node**.
* **How It Works**:
  1. **Association with Vector Store**: The RAG container uses the embeddings stored in the vector store to perform retrieval-augmented reasoning.
  2. **Exposed to Workflows**: Developers can add the **RAG node** in a low-code/no-code manner to integrate retrieval functionality directly into workflows.
  3. **Dynamic Interaction**: The reasoning engine retrieves relevant information via the RAG container and uses it to augment intent classification and response generation.
* **Developer's Role**:
  * Create or configure the RAG container associated with a vector store.
  * Use the RAG node in workflows to retrieve and incorporate relevant knowledge dynamically.
* **Example in Workflow**: When a user asks, "Show me the loan terms for Plan B," the RAG container retrieves the most relevant embeddings from the vector store (e.g., a section of a document or database record) and feeds it into the reasoning engine (if used in knowledge) or LLMs (if used in RAG node) for a precise response.

### How These Components Work Together

1. **Data Ingestion**:
   * Developers add multiple data sources (PDFs, databases, etc.) to a data store.
2. **Vectorization**:
   * The vector store processes the data in the data store, generating vector embeddings and storing them in a vector database.
3. **RAG Integration**:
   * The RAG container is linked to the vector store.
   * Developers integrate the RAG node into workflows, enabling retrieval and augmentation in their AI agent's logic.
4. **Dynamic Query Handling**:
   * A user query is processed by the reasoning engine.
   * The RAG container retrieves relevant embeddings from the vector store.
   * Retrieved data is used to generate an accurate, context-rich response.

### Key takeaway for developers

✅ Understanding these concepts is essential for leveraging the full potential of UPTIQ’s **low-code/no-code workflows**.

✅ Think of these components as **tools** in a developer's toolkit:

* **Data Sources**: Raw materials.
* **Data Store**: Organizational structure.
* **Vector Store**: Advanced search engine.
* **RAG Container**: Intelligent retrieval and integration.

✅ Mastering the RAG allows developers to build sophisticated AI agents capable of delivering accurate and contextually relevant responses to users
