A knowledge base supplements an LLM with private data and up-to-date information. Using retrieval-augmented generation (RAG), the LLM retrieves relevant content from the knowledge base to generate more accurate answers.
Console access restrictions: Only users who created Alibaba Cloud Model Studio applications in the Singapore region before April 21, 2025 can access the Application Development tab.
This tab contains the following features: Applications (agent application and workflow application), Components (prompt engineering and plug-in), and Data (knowledge base and application data). These are all preview features. Use them with caution in production environments.
API call restrictions: Only users who created Alibaba Cloud Model Studio applications in the Singapore region before April 21, 2025 can call the application data, knowledge base, and prompt engineering APIs.
|
Application without a dedicated knowledge base An LLM without a dedicated knowledge base cannot answer domain-specific questions accurately.
|
Application with a dedicated knowledge base An LLM with a dedicated knowledge base can answer domain-specific questions accurately.
|
Supported models
The following models support knowledge bases. Configuring a knowledge base for Qwen
-
Qwen-Max/Plus/Turbo
-
QwenVL-Max/Plus
-
Qwen open-source version (e.g., Qwen2.5)
This list is subject to change. For the latest list, see the Application Management page when you create an application.
Quick start
This section shows how to quickly build an LLM Q&A application that answers domain-specific questions without writing any code. This guide uses "Alibaba Cloud Model Studio phones" as an example.
1. Build a knowledge base
-
Go to the knowledge base page, click Create Knowledge Base, fill in the Name and Description, leave the other settings as default, and click Next Step.
-
Select the Default Category and upload the Alibaba Cloud Model Studio Phone Series Product Introduction.docx file. Click Next Step, then click Complete.
2. Integrate with business applications
After creating a knowledge base, associate it with an Alibaba Cloud Model Studio application or an external application in the same workspace to process retrieval requests.
Agent application
-
Go to the App Center page, find the target agent application, click Configure on its card, and select a model for the application.
-
Click the + button to the right of Document Knowledge Base to add the knowledge base you created. You can leave the similarity threshold and weight at their default values.
-
In the input box on the right side of the page, enter a question. The LLM will use the knowledge base you created to generate an answer.
For example: "Help me choose the Alibaba Cloud Model Studio phone with the best camera for under 3,000 CNY."
Workflow application
-
Go to the App Center page, find the target workflow application, and click Configure on its card. Drag a knowledge base node onto the canvas and connect it after the Start.
-
Configure the knowledge base node:
-
Input: To the right of the
contentvariable, click the Value drop-down list and select . You may need to expand the "Built-in Variable" group to find the query variable. -
Select Knowledge Base: The knowledge base node offers two selection methods:
-
Select a fixed knowledge base: Select the knowledge base that you created from the drop-down menu. Use this method when the same knowledge base is required for every call.
-
Dynamic Selection: Configure the
CodeListvariable to dynamically specify which knowledge bases to use based on the output of upstream nodes. Use this method to retrieve from different knowledge bases based on varying inputs.
-
-
Set TopK (Optional): Determines the number of text chunks returned to downstream nodes (typically LLM nodes).
Increasing this value usually improves the accuracy of the LLM's answers but also increases the LLM's input token consumption.
-
-
Drag an LLM node onto the canvas and connect it after the knowledge base node and before the end node.
-
Configure the LLM node:
-
In the Model configuration list, select a model for the node.
-
In the Prompt field, enter a prompt that instructs the LLM to use the knowledge base. Enter "/" to insert the
resultvariable, which represents the results from the knowledge base retrieval.
-
-
Configure the end node: Enter
/and select to set the LLM's response as the final output. -
Click Test in the upper-right corner of the page. In the input box on the right, enter a question. The LLM will use the knowledge base you created to generate an answer.
For example: "Help me choose the Alibaba Cloud Model Studio phone with the best camera for under 3,000 CNY."
External application
Besides building applications in Alibaba Cloud Model Studio, you can use the Alibaba Cloud Model Studio SDK to integrate knowledge base retrieval into external AI applications.
For detailed integration steps, see the Knowledge Base API Guide.
3. Optimize RAG performance (Optional)
If retrieval results are incomplete or inaccurate during the Q&A process, see RAG performance optimization.
Actions
On the knowledge base page, you can view and manage all knowledge bases in the current workspace.
Knowledge base ID: The value of the ID field on each knowledge base card, used for API calls.
Create a knowledge base
Click Create Knowledge Base, follow three steps: provide basic information and select a knowledge base type, configure a data source, and set indexing parameters.
-
From the knowledge base page, click Create Knowledge Base.
-
Provide basic information
Select the Knowledge Base Type based on your use case. Each knowledge base supports only one type. If you select the document search type, you must also select a use case: basic document Q&A, rich-text reply:
-
Basic document Q&A: Ideal for semantic retrieval of plain-text documents.
-
Rich-text reply: Ideal for responses that contain rich text.
The knowledge base type cannot be changed after creation.
-
Document search (retrieval scenario)
-
Use cases
-
This scenario is suitable for retrieving unstructured data, such as internal corporate documents and product manuals. Unstructured data is not organized in a predefined table schema and can include text, tables, and images.
-
If your files contain images that you want your Alibaba Cloud Model Studio application to include in its responses, select Document search.
-
-
Data source: You can upload local files or import them from Object Storage Service (OSS).
-
-
Data query (chatbot or NL2SQL scenarios)
-
Use cases:
-
Ideal for building Q&A systems on structured data (data organized in a predefined table schema) to create assistants that query FAQs, product data, or personnel information.
-
If your data consists of complete FAQ question-and-answer pairs, select Data Query. For example, if an Excel file contains two columns,
QuestionandAnswer, a data query knowledge base can use theQuestioncolumn for retrieval and theAnswercolumn as context for the LLM's response.A document search knowledge base does not support this functionality.
-
You can import multiple Excel files, but their table schemas must be identical.
-
-
Data source integration: You can upload local XLS or XLSX files.
-
-
Image Q&A (image search)
-
Use cases:
-
Ideal for building multimodal retrieval applications for search-by-image and search by image and text, such as product discovery assistants or visual Q&A assistants.
-
-
Data source integration: You can upload local XLS or XLSX files.
XLS and XLSX files must contain publicly accessible image URLs to build an image index. For more information, see the creation instructions below.
-
Choose a use case: basic document Q&A, rich-text reply.
-
During peak request periods, the creation process can take several hours, depending on the data volume. Please be patient.
Update a knowledge base
Changes to a knowledge base automatically synchronize with any application that uses it.
Document search
-
Automatic update (recommended)
You can set up automatic updates by integrating the OSS, FC, and Model Studio knowledge base APIs. Follow these steps:
-
Create a bucket: Go to the OSS console and create an OSS bucket to store your source files.
-
Create a knowledge base: Create an unstructured knowledge base to store your private content.
-
Create a user-defined function: Go to the FC console and create a function to handle file change events, such as file creation and deletion. For more information, see Create a function. The function calls the relevant APIs from the Knowledge Base API Guide to synchronize your knowledge base with file changes in OSS.
-
Create an OSS trigger: In FC, associate an OSS trigger with the previously created user-defined function. When a file change event such as an upload occurs, the trigger activates the function.
-
-
Manual update
On the Knowledge Base page, find the knowledge base that you want to update and click View Details on its card.
-
To add a new file: Click Upload Data and select existing files from the data connector.
-
To delete a file: Find the file and click Delete to its right.
-
To modify file content: In-place updates and overwrites are not supported. First, delete the old version from the knowledge base, and then import the updated version.
Note: Failure to remove the old version can lead to outdated search results.
-
Data query and image Q&A
Note: On the details page for an Image Q&A knowledge base, there is no direct Upload Data button. To update data, click the View Data Source link to open the data connector details page.
-
Automatic update
Not supported.
-
Manual update
If the data source for your knowledge base is a data table in Application Data, follow these two steps for manual updates.
-
Step 1: Update the data table
Go to the Application Data tab. In the left pane, select the target data table and click Upload Data.
-
To insert new data: Set the import type to Incremental Upload. Upload an Excel file that contains only the header row and the new data rows.
The header row of the file must match the current table schema. You can click Download Template to get a standard template file, and then add your new data to it.
-
To delete data: Set the import type to Upload and Overwrite. Upload an Excel file that contains the header row and the latest full dataset, with the unwanted records removed.
To get the full dataset, click the
icon to download the data in XLSX format. -
To modify data: Set the import type to Upload and Overwrite. Upload an Excel file that contains the header row and the full, modified dataset.
-
-
Step 2: Synchronize changes to the knowledge base
Return to the Knowledge Base list, find the target knowledge base, and click View Details on its card. Click the
icon in the upper-left corner of the data table, and then confirm the prompt to synchronize the knowledge base.You must repeat these steps for each manual update.
-
Audio and video search
-
Automatic update
Not supported.
-
Manual update
On the Knowledge Base page, find the knowledge base that you want to update and click View Details on its card.
-
To add a new file: Click Upload Data and select existing files from Application Data.
-
To delete a file: Find the file and click Delete to its right.
This action removes the file only from the knowledge base. This action does not affect the source file in Application Data.
-
To modify file content: In-place updates and overwrites are not supported. First, delete the old version from the knowledge base, and then import the updated version.
Note: Failure to remove the old version can lead to outdated search results.
-
Edit knowledge base
After creating a knowledge base, you can modify only its knowledge base name, knowledge base description, and similarity threshold. To change other configurations, you must delete and recreate the knowledge base. This operation is only available in the console and has no corresponding API.
Procedure: On the Knowledge Base page, find the target knowledge base, click the
icon on its card, and then click Edit. Note: You can modify a knowledge base's configuration only once per calendar day. The system silently rejects any subsequent attempts on the same day.
Delete a knowledge base
This action cannot be undone. Proceed with caution.
Before you delete a knowledge base, we recommend that you disassociate it from all published Model Studio applications.
You can still delete a knowledge base associated with unpublished applications.
Change configuration
The Enterprise Edition uses RCUs for high retrieval performance at high QPS and offers larger storage capacity. The Standard Edition is suitable for development, testing, or low-concurrency scenarios.
You can switch between the Standard and Enterprise Editions and change the RCU count for the Enterprise Edition.
You can change a Knowledge Base's configuration only once per calendar day.
RCU: A Retrieval Compute Unit (RCU) is a measure of the retrieval concurrency of a Knowledge Base. One RCU supports approximately 50 QPS for online retrieval. Higher RCU counts support greater concurrency.
-
Note:
-
To downgrade an Enterprise Edition Knowledge Base that uses platform storage to the Standard Edition, you must first reduce its used storage space to less than 80 GB.
You can free up storage space by deleting files or data from the Knowledge Base.
-
-
Procedure:
-
On the Knowledge Base page, for the Knowledge Base you want to edit, click the
icon on its card, and then click Edit. -
In the dialog box, select an action based on the current edition:
-
Standard Edition: Select Upgrade.
-
Enterprise Edition: Select Downgrade or Change RCU Count.
-
-
Follow the on-screen instructions. The new configuration takes effect immediately after you click OK.
-
Hit testing
Use hit testing to verify that your knowledge base provides accurate knowledge input to your AI application. Simulate user queries, evaluate the retrieval results, and fine-tune the similarity threshold.
The reranking model in hit testing supports three modes: q&a mode (default), designed for queries that do not perfectly match the document content; similarity mode, ideal for queries that are highly similar to the document content; and custom advanced mode. The ranking scores for the same query can vary significantly depending on the selected mode. For example, the same text segment might score 47% in q&a mode but up to 69% in similarity mode.
With hit testing, you can:
-
Verify that the knowledge base provides effective knowledge input to your AI application
-
Fine-tune the similarity threshold to balance the recall rate and accuracy
-
Identify content gaps or quality issues in your knowledge base
Use cases
-
Use case 1: Querying product pricing
Test input: "How much does your Model Studio phone cost?" Expected result: Retrieve relevant text segments that contain price information. -
Use case 2: Troubleshooting a technical issue
Test input: "What should I do if my device can't connect to Wi-Fi?" Expected result: Retrieve relevant text segments about troubleshooting Wi-Fi connection issues. -
Use case 3: Retrieval with visual understanding (visual understanding knowledge base)
A visual understanding knowledge base supports three query modes: text-only, image-only, and image+text. Mode 1 (text-only): Enter "Object Storage Service" to retrieve relevant segments from documents and images. Mode 2 (image-only): Upload a product screenshot. The system uses visual understanding to match semantically similar segments. Mode 3 (image+text): Upload an image and enter descriptive text. A combined query can improve retrieval similarity. -
Use case 4: Rapid Q&A (Rapid Q&A knowledge base)
A Rapid Q&A knowledge base supports text-only queries (image input is not supported) and is ideal for fast retrieval from structured documents: Test input: "What is the price of the Qwen Pro 8?" Expected result: Quickly retrieve relevant FAQ segments that include price information.
Procedure
-
On the knowledge base page, find the knowledge base you want to test and click Hit Test on its card.
-
In the test interface, enter a question (we recommend using common user queries) and review the retrieval results.
-
Retrieval results: This section displays the hit results from the current test, sorted by similarity in descending order. Click any segment to view its content.
-
Icon: For image Q&A knowledge bases, the system converts the input image to a vector to retrieve records, then sends these records with the question to an LLM for an answer. By contrast, document search, data query knowledge bases do not use the uploaded image for retrieval. However, a document search knowledge base with its use case set to visual understanding uses the uploaded image for retrieval, supporting text-only, image-only, and image+text query modes. In this context, a combined image and text query improves retrieval similarity.
-
-
Verify that the relevant text segments are correctly retrieved. If not, adjust the similarity threshold and repeat the previous step.
-
Click View Recall History to compare retrieval performance with different threshold settings.
Quotas and limits
-
For information about supported data sources, capacity, and other limits, see Knowledge base quotas and limits.
-
Maximum number of knowledge bases per Model Studio application:
-
Document search: Up to 5
-
Data query: Up to 5
-
Image Q&A: Up to 1
You can associate up to 11 knowledge bases of different types.
-
Billing
The knowledge base feature is free, but you may be charged for calling a Model Studio application that uses a knowledge base.
|
Step |
Billing |
|
|
|
Free of charge. |
|
|
|
When a Model Studio application retrieves text chunks from a knowledge base, it increases the LLM's input token count and can increase model inference fees. For more information, see Billable items and pricing. Note: You are not charged if you only use the Retrieve API to retrieve from a knowledge base and do not use a Model Studio application to generate a response. |
|
|
|
Free of charge. |
|
API reference
-
See the API Directory (Knowledge Base) for a complete list of knowledge base APIs and their parameters.
-
See the Knowledge Base API Guide for detailed usage and code examples.














