AI RAG

Updated at:

The AI RAG plugin implements Retrieval-Augmented Generation (RAG) for Large Language Models (LLMs) by integrating with Alibaba Cloud DashVector.

You can implement LLM-based RAG by integrating with Alibaba Cloud DashVector. The following figure shows the process:

image

Running Properties

Plugin execution phase: Default phase. Plugin execution priority: 400.

Configuration

Name

Data Type

Requirements

Default Value

Description

dashscope.apiKey

string

Required

-

The authentication token for the Qwen service.

dashscope.serviceFQDN

string

Required

-

The fully qualified domain name (FQDN) of the Qwen service.

dashscope.servicePort

int

Required

-

The port of the Qwen service.

dashscope.serviceHost

string

Required

-

The domain name of the Qwen service.

dashvector.apiKey

string

Required

-

The authentication token for DashVector.

dashvector.serviceFQDN

string

Required

-

The FQDN of the DashVector service.

dashvector.servicePort

int

Required

-

The port of the DashVector service.

dashvector.serviceHost

string

Required

-

The domain name of the DashVector service.

dashvector.topk

int

Required

-

The number of top vectors to retrieve from DashVector.

dashvector.threshold

float

Required

-

The vector distance threshold. Documents with a distance above this value are filtered out.

dashvector.field

string

Required

-

The field name used to store document content in DashVector.

Note

When the plugin is enabled and you use Tracing Analysis, the id of documents retrieved by RAG is added to the attribute of the span for troubleshooting.

Example

dashscope:
    apiKey: xxxxxxxxxxxxxxx
    serviceFQDN: dashscope
    servicePort: 443
    serviceHost: dashscope.aliyuncs.com
dashvector:
    apiKey: xxxxxxxxxxxxxxxxxxxx
    serviceFQDN: dashvector
    servicePort: 443
    serviceHost: vrs-cn-xxxxxxxxxxxxxxx.dashvector.cn-hangzhou.aliyuncs.com
    collection: xxxxxxxxxxxxxxx
    topk: 1
    threshold: 0.4
    field: raw

The CEC-Corpus dataset contains a corpus and annotation data for 332 news reports on emergency events. The original news text is extracted, vectorized, and added to DashVector. For more information about text embedding, see Implement Semantic Search Using DashVector and Text Embedding.

The following example shows a RAG-enhanced query. The original query is: Where did the Hainan rear-end collision occur? What was the cause? What were the casualties?

  • Result without the RAG plugin:

    As an AI model, I cannot retrieve and update specific information about news events in real-time, including details such as location, cause, and casualties. For such specific events, consult the latest news reports or official announcements for accurate information. Visit mainstream media websites, use news applications, or follow announcements from relevant government departments for this dynamic information.

  • Result with the RAG plugin:

    The Hainan rear-end collision occurred at the 37 km mark on the Haiwen Expressway in the Wenchang-Haikou direction. At the time of the report, the traffic police department was still investigating the cause of the accident, so the exact cause cannot be determined from the provided information. The casualties included one fatality (the driver died on the spot) and eight injuries (two children and six adults). All injured individuals were rescued and sent to the hospital for treatment.