This guide walks you through quickly building a private-knowledge Q&A application using Alibaba Cloud Bailian’s agent application development capabilities.
Why Can’t LLMs Answer Private Knowledge Questions?
Core Concept
An LLM’s knowledge comes solely from its training data and does not include any private, domain-specific, or up-to-date information. As a result, asking it directly about specific products or internal knowledge often yields inaccurate or hallucinated responses.
Solution: RAG (Retrieval-Augmented Generation)
Retrieval-Augmented Generation (RAG) is a technique that integrates external knowledge bases with large language models. It retrieves relevant information and feeds it to the model, enabling answers grounded in your proprietary knowledge. Its core workflow is as follows:
- Data Processing & Vectorization: Uploaded documents are automatically split into chunks. An embedding model converts each chunk into a mathematical vector, which is stored in a dedicated vector database.
- Retrieval: When a question arrives, the system vectorizes it and retrieves the Top-k most semantically similar document chunks from the vector database.
- Generation: The original question and retrieved document snippets are combined into a prompt and submitted to the LLM, which then generates the final answer.
Building a Private-Knowledge Q&A Application
This tutorial uses the new Agent application (Agent 2.0). In the current console, clicking Create Agent creates an Agent 2.0 application by default; to create a legacy (Agent 1.0) application, click the Legacy Agent creation link at the bottom of the creation dialog — the page will redirect to the legacy Bailian console.
Creating an Agent
Create the Application
Select a Model
- Smart Mode: the platform automatically balances cost and quality—no manual model selection required. Recommended for beginners. The AUTO tier routes each request to an appropriate performance tier based on task complexity.
- Specific Model: choose a concrete model. For better multi-step planning, we recommend models with strong tool-calling capabilities, such as the
Qwen-Maxseries; click More Models for additional options.
Design the Prompt
/ to insert a configured variable.Test the Application
Creating a Knowledge Base
Open the Knowledge Management Page
Enter Basic Information
Upload Knowledge Documents
Finish Creation
Creating and Publishing a Knowledge Retrieval Service
The new Agent uses knowledge bases through a knowledge retrieval service. One retrieval service can contain one or more knowledge bases; it must be created and published before an application can reference it.
Create the Retrieval Service
Bind Knowledge Bases
Test and Publish
Attaching the Retrieval Service to Your Agent
Enter Application Configuration
Attach the Service
Testing and Publishing
Test Q&A Performance
Publish the Application
Best Practices
You’ve now mastered the fundamentals of building a basic RAG application. Next steps include:
- Optimize RAG Performance: Learn how to fine-tune RAG at every stage—query rewriting, retrieval, recall, and re-ranking. See Knowledge Base Optimization for details.
- Add External Tools: Extend your agent’s capabilities by integrating plugins, MCP tools, and more. See Agent applications (Agent 2.0).
- Build Advanced Applications: Use Workflow Applications for complex process orchestration, with conditional branches, loops, and parallel execution for multi-step business scenarios.
- External Integration: Integrate your application into business systems via the DashScope SDK or HTTP APIs.
Frequently Asked Questions
Why are answers inaccurate—or why isn’t the application using knowledge from my knowledge base?
Why are answers inaccurate—or why isn’t the application using knowledge from my knowledge base?
- Document chunking breaks semantic coherence.
- The embedding model fails to capture core meaning accurately.
- Retrieval misses the most relevant document chunks.
- Use well-structured documents (e.g., Markdown, JSON).
- In knowledge base configuration, switch to Custom Mode, experiment with different embedding models and ranking settings to improve response quality.
How can I make the model explicitly say “I don’t know” when no answer exists in the knowledge base—instead of fabricating one?
How can I make the model explicitly say “I don’t know” when no answer exists in the knowledge base—instead of fabricating one?