Skip to main content

Knowledge Q&A

The Knowledge Q&A service combines large language models with knowledge retrieval capabilities to automatically find relevant content from multiple knowledge bases and generate natural language answers. You can configure models, retrieval parameters, and generation strategies in the console, or integrate the service into your applications using an API.

Create a Q&A Service

  1. Log on to the console and go to Knowledge Services → Knowledge Q&A.
  2. Click Create in the upper-right corner. In the dialog box that appears, enter a Service Name (required, up to 40 characters) and a Description (optional, up to 200 characters), then click Confirm.
  3. After the service is created, you are redirected to its configuration page. Select the Model used to generate answers, such as qwen3.6-plus. Click the Settings icon to the right of the model to configure the temperature and enable_thinking parameters. The Prompt (optional, up to 500 characters) guides the model's response style and behavior.
  4. Select a retrieval strategy. For details, see Retrieval Modes below.
  5. Click + Add to associate one or more knowledge bases (up to 15). After you turn on the Priority switch, each knowledge base displays a priority option. You can select High / Medium / Low to set its retrieval priority. To configure independent parameters for a single knowledge base, click the expand icon to the right of the knowledge base to expand its configuration panel. For details, see Independent Knowledge Base Configuration below.
  6. Enable generation control parameters, such as file pre-parsing, answer refusal, and leakage prevention, as needed. For details, see Generation Control Parameters below.
  7. Enter a question in the debugging window on the right to view the answer generated by the model, including citations and the retrieval process. You can upload attachments after file pre-parsing is enabled.
  8. After you complete the configuration, click Publish in the upper-right corner. After publishing, you can call the Q&A service through the API.
  • At least one knowledge base must exist, and it must contain successfully parsed documents.
  • For multi-knowledge-base joint Q&A, all knowledge bases must reside in the same workspace.

Retrieval Modes

ModeHow It WorksUse Cases
Ultra-FastGenerates an answer directly after a single round of retrieval, with a switch for query rewritingSimple and clear questions, and scenarios that are sensitive to response speed
Multi-Round Intelligent RetrievalPerforms multi-round planning searches (Agentic) based on a large model, which automatically performs intent recognition, query rewriting, and knowledge base routing. You can configure the maximum number of ReAct roundsComplex or ambiguous questions, and scenarios that require answers synthesized across knowledge bases
Click the Settings icon to the right of the retrieval mode drop-down list to configure the advanced parameters of the retrieval mode.

Independent Knowledge Base Configuration

Click the expand icon to the right of a knowledge base to configure its independent retrieval parameters:
ParameterValid RangeDescription
Query RewritingOn/OffRewrites and optimizes the user input to improve retrieval performance. In Ultra-Fast mode, this feature is controlled by this switch. In Multi-Round Intelligent Retrieval mode, the agent automatically rewrites queries
Initial Vector Retrieval TopK1~100The number of chunks initially retrieved in the vector search phase
Initial Keyword Retrieval TopK1~100The number of chunks initially retrieved in the keyword search phase
Re-ranking Modelqwen3-rerank, etc. / No modelIndependently sorts the results retrieved from this knowledge base. For text-only knowledge bases, select the qwen3-rerank series. For multimodal knowledge bases, select qwen3-vl-rerank
Re-ranking ModeQ&A Mode / Similarity ModeQ&A Mode ranks chunks by Q&A matching score. Similarity Mode ranks chunks by semantic similarity. Available only when a re-ranking model is selected
Similarity Threshold0.01~1.0Filters out chunks whose scores fall below the threshold after re-ranking. A higher value yields more precise results but may exclude relevant content
Max Recall Count1~20The number of chunks returned from this knowledge base after re-ranking
Tag Filtering—Filters the retrieval scope based on document tags. Enter a tag and press Enter, or select an existing tag from the drop-down list
The displayed parameters vary by knowledge base type. Document search knowledge bases display all parameters. Multimodal types, such as image Q&A, do not display the Query Rewriting and TopK parameters.

Generation Control Parameters

ParameterDescription
File Pre-parsingWhen enabled, you can upload files (including images and documents) by clicking the attachment button in the debugging window for Q&A. Two parsing modes are available: Full-text Reference, which parses the complete content as context, and Chunk-based Retrieval, which splits the file into chunks and combines them with knowledge base retrieval
Answer RefusalWhen enabled, the model refuses to answer and returns a custom refusal message if the retrieval results are insufficient to answer the question
Leakage PreventionWhen enabled, prevents the original text of the knowledge base from being directly leaked in answers. If a potential leak is detected, a custom protection response is returned
Multimodal ResponseWhen enabled, the model's answers include multimodal content from the knowledge base, such as images
CitationWhen enabled, the model's answers display citation sources, indicating which document the answer content comes from

API Invocation

The Knowledge Q&A service is called through the chat API and returns SSE streaming responses:
curl -X POST https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v2/apps/knowledge/chat \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "input": {
      "messages": [
        {"role": "user", "content": "How do I choose a chunking strategy?"}
      ]
    },
    "parameters": {
      "agent_options": {
        "agent_id": "${YOUR_AGENT_ID}"
      }
    },
    "stream": true
  }'
You can also start a knowledge Q&A session through the Alibaba Cloud Bailian CLI: bl knowledge chat --message "How do I choose a chunking strategy?" --agent-id <qa-service-id>. For more information, see Use the CLI.

SSE Event Types

Q&A responses return events in the following order:
EventDescription
plan_start → planning → plan_endPlanning phase: the model plans retrieval and response strategies
tool_calling → tool_returnTool calling phase: tool_calling issues a retrieval request, and tool_return returns the matched chunks
generation_start → generating → generation_endGeneration phase: the final answer is streamed. In generation_end, finish_reason is stop
In Multi-Round Intelligent Retrieval mode, the entire plan → tool_calling → tool_return cycle can repeat multiple times. For a complete description of the events, see the chat API.

Multi-Turn Conversations

The platform does not retain conversation state. Each request must include the complete messages history. We recommend that you:
  • Limit the history length (for example, to the last 10 turns) to avoid exceeding the model's context window.
  • Retrieve content based only on the most recent user message to reduce noise.
After you create a Q&A service, you can view integration methods on the Integration Channels page and integrate the service into your applications through API, MCP, CLI, and other methods.
Agent Development
Agent Context
Agent Governance & Evolution
Store
Application Marketplace