> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/agentic-commerce-intelligence/agentic-intelligence/configuration/tools/rag.md).

# RAG AI Tool

RAG AI Tools allow agents to perform LLM-based semantic search.

Retrieval-Augmented Generation (RAG) framework is capable of combining a large language model (LLM) with an external knowledge base to provide more accurate and up-to-date responses. Its inner mechanism consists in first retrieving relevant information from sources (like documents or databases) and then using that information in the LLM, enhancing its output with the specific context. RAG helps AI to generate answers that are highly-grounded in factual, real-time data, reducing "hallucinations".

In the Emporix Agentic AI, Retrieval-Augmented Generation is a capability facilitated by the RAG AI tools that you can use within an AI agent.

These native tools enable agents to perform LLM-based semantic search across various domain-specific entities stored in vector databases.

The RAG AI tools transform user queries into vector embeddings and match them against pre-computed entity embeddings using similarity metrics (for example, cosine similarity).

```mermaid
---
config:
  layout: fixed
  theme: base
  look: classic
  themeVariables:
    background: transparent
    lineColor: "#9CBBE3"
    arrowheadColor: "#9CBBE3"
    edgeLabelBackground: "#FFC128"
    edgeLabelTextColor: "#4C5359"
---
flowchart TD
  A["USER QUERY"]
  B["Transform query into<br>vector embedding"]
  C["Match against pre-computed<br>entity embeddings"]
  D["Rank by similarity<br>(e.g. cosine similarity)"]
  E["Return context-aware results"]

  A -->|"Initiate RAG mechanism"| B --> C --> D --> E

  style A fill:#3B73BB,stroke:#4C5359,color:#FFFFFF
  style B fill:#DDE6EE,stroke:#4C5359
  style C fill:#DDE6EE,stroke:#4C5359
  style D fill:#DDE6EE,stroke:#4C5359
  style E fill:#F2F6FA,stroke:#4C5359

  A@{ shape: rounded}
  B@{ shape: rounded}
  C@{ shape: rounded}
  D@{ shape: rounded}
  E@{ shape: rounded}
```

Crucially, RAG AI tools operate on semantic meaning. This differs from traditional keyword-based search, as RAG enables more accurate and context-aware retrieval even when there is no explicit keyword overlap.

To enhance search for indexed entities (like products or orders) with RAG, an agent must be used with a previously defined RAG AI tool attached to it. The tool configuration requires a prompt, which informs the agent when the tool must be triggered. The Agentic AI provides two tool types designed for RAG workflows:

<table data-view="cards"><thead><tr><th align="center"></th><th align="center"></th><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><i class="fa-database">:database:</i></td><td align="center"><strong>RAG Emporix Tool</strong></td><td align="center">Index and retrieve Emporix-managed entities (<code>RAG_EMPORIX</code>) using the native Emporix Vector Database — products, orders, or custom entities.</td><td><a href="/agentic-commerce-intelligence/agentic-intelligence/configuration/tools/rag/rag-emporix.md">RAG Emporix Tool</a></td></tr><tr><td align="center"><i class="fa-server">:server:</i></td><td align="center"><strong>RAG Custom Tool</strong></td><td align="center">Connect to an external vector database (<code>RAG_CUSTOM</code>) when you need full control over storage, scaling, or cost.</td><td><a href="/agentic-commerce-intelligence/agentic-intelligence/configuration/tools/rag/rag-custom.md">RAG Custom Tool</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.emporix.io/agentic-commerce-intelligence/agentic-intelligence/configuration/tools/rag.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
