Skip to main content
Knowledge Service

Knowledge Q&A

Streaming RAG-based Q&A service powered by large language models

The Knowledge Q&A service leverages large language models combined with knowledge retrieval capabilities. It supports binding multiple knowledge bases, automatically retrieves relevant content, and generates natural-language answers. You can create and configure the Q&A service via the console and integrate it into your applications via API after publishing.

Creating a Q&A Service

1

Navigate to the Knowledge Q&A page

Log in to the console and go to Knowledge Services → Knowledge Q&A.
2

Create a service

Click Create in the top-right corner. In the pop-up dialog, fill in:
  • Service Name (required, up to 40 characters)
  • Description (optional, up to 200 characters)
Click Confirm to complete creation.
3

Configure model and prompt

After successful creation, you’ll be redirected to the configuration page:
  • Model: Select the large language model used to generate answers (e.g., qwen3.6-plus). Click the Settings icon next to the model to configure parameters such as temperature and enable_thinking.
  • Prompt (optional, up to 500 characters): Guides the model’s response style and behavior.
4

Select retrieval mode

Choose a retrieval strategy — see Retrieval Modes below.
5

Bind knowledge bases

Click + Add, then bind one or more knowledge bases (up to 15). When enabling the Priority toggle, each bound knowledge base displays a priority selector where you can assign High / Medium / Low priority for retrieval ranking.
Knowledge Base Priority Settings
To configure independent parameters for a single knowledge base, click the expand icon on its right side to reveal its dedicated configuration panel — see Independent Knowledge Base Configuration below.
6

Configure generation controls

Enable generation control options as needed — e.g., file pre-parsing, refusal-to-answer, leakage prevention — see Generation Control Parameters below.
7

Test Q&A

Enter questions in the debug pane on the right to view generated answers, cited sources, and the full retrieval process. File uploads are supported if file pre-parsing is enabled.
8

Publish

Once configured, click Publish in the top-right corner. The Q&A service becomes callable via API after publishing.
  • At least one knowledge base must already exist, and it must contain at least one successfully parsed document.
  • For multi-knowledge-base joint Q&A, all bound knowledge bases must reside within the same business workspace.

Retrieval Modes

ModeHow It WorksUse Cases
Ultra-FastPerforms single-round retrieval and directly generates an answer; supports toggling query rewritingSimple, well-defined questions; latency-sensitive scenarios
Multi-Round Intelligent RetrievalUses LLM-powered agentic planning to iteratively perform intent recognition, query rewriting, and knowledge-base routing; supports configuring maximum ReAct roundsComplex or ambiguous questions; cross-knowledge-base synthesis required
Click the Settings icon to the right of the retrieval mode dropdown to configure advanced retrieval parameters.

Independent Knowledge Base Configuration

Click the expand icon on the right side of a knowledge base to configure its independent retrieval parameters:
ParameterValid RangeDescription
Query RewritingOn / OffOptimizes user input to improve retrieval quality. Controlled by this toggle in Ultra-Fast mode; automatically handled by the agent in Multi-Round Intelligent Retrieval mode.
Initial Vector Retrieval TopK1–100Number of chunks initially retrieved during vector search.
Initial Keyword Retrieval TopK1–100Number of chunks initially retrieved during keyword search.
Reranking Modele.g., qwen3-rerank / NoneApplies independent reranking to retrieval results from this knowledge base. Use qwen3-rerank series for text-only knowledge bases; use qwen3-vl-rerank for multimodal knowledge bases.
Reranking ModeQA Mode / Similarity ModeQA Mode ranks by question-answer relevance; Similarity Mode ranks by semantic similarity. Available only when a reranking model is selected.
Similarity Threshold0.01–1.0Filters out chunks whose scores fall below this threshold after reranking. Higher values yield more precise but potentially incomplete results.
Max Retrieved Chunks1–20Number of top-ranked chunks returned per knowledge base after reranking.
Tag FilteringRestricts retrieval scope using document tags. Type a tag and press Enter, or select from the dropdown list of existing tags.
Available parameters vary by knowledge base type. Document-search-type knowledge bases display all parameters; multimodal types (e.g., image Q&A) omit Query Rewriting and TopK parameters.

Generation Control Parameters

ParameterDescription
File Pre-ParsingWhen enabled, allows uploading files (including images and documents) via the attachment button in the debug pane. Offers two parsing modes: Full-text Citation, which parses entire content as context; and Chunk-Based Retrieval, which slices uploaded files and integrates them with knowledge-base retrieval.
Refusal-to-AnswerWhen enabled, the model refuses to answer if retrieved evidence is insufficient, returning a custom refusal message instead.
Leakage PreventionWhen enabled, prevents verbatim leakage of source content from knowledge bases. Triggers a custom protective response upon detecting potential leakage.
Multimodal ResponseWhen enabled, includes multimodal content (e.g., images) from knowledge bases in model responses.
CitationWhen enabled, displays source citations in model responses, indicating which document each part of the answer originates from.

API Invocation

The Knowledge Q&A service is invoked via the chat API, returning Server-Sent Events (SSE) streaming responses:
curl -X POST https://{workspaceId}.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
  }'

SSE Event Types

Q&A responses emit events in the following sequence:
EventDescription
plan_startplanningplan_endPlanning phase: the model plans retrieval and response strategies.
tool_callingtool_returnTool-calling phase: tool_calling triggers a retrieval request; tool_return returns matched chunks.
generation_startgeneratinggeneration_endGeneration phase: final answer is streamed incrementally; finish_reason equals "stop" in generation_end.
In Multi-Round Intelligent Retrieval mode, the entire plan → tool_calling → tool_return cycle may repeat multiple times. Full event documentation is available in the chat API reference.

Multi-Turn Conversations

The platform does not retain conversation state. Each request must include the full messages history. Best practices include:
  • Limiting history length (e.g., last 10 turns) to avoid exceeding model context windows.
  • Using only the most recent user message for retrieval to reduce noise.
After creating a Q&A service, visit Integration Channels to explore integration methods — including API, MCP, CLI, and more — for embedding the service into your applications.