Skip to main content

Knowledge Q&A

Streaming RAG Q&A service powered by large language models.

Knowledge Q&A combines a large language model with knowledge retrieval to fetch relevant content and generate a natural-language answer. It supports multi-Knowledge-Base binding, multi-turn dialogue, streaming output, and citation display.

Capabilities

CapabilityDescription
Intelligent Q&AThe LLM combines retrieval results with its own reasoning to produce cited answers.
Multi-Knowledge-Base bindingBind up to 15 Knowledge Bases with per-source priorities and retrieval parameters.
Two retrieval modesFast Mode (single-pass retrieval) and Multi-turn Agentic Mode (Agentic multi-step planning).
In-chat file parsingUpload a file mid-conversation; the system parses it on the fly without importing it into a Knowledge Base.
Generation controlsRefusal policy, prompt-leak protection, and citation rendering.

Create a Q&A service

1

Open Knowledge Q&A

Sign in to the console and click Knowledge Q&A in the left navigation.
2

Create a service

Click New Q&A Service in the top right and fill in a name and description.
3

Configure model and prompt

  • Pick a generation model (such as qwen3-plus or DeepSeek-R1).
  • Optionally enter a prompt (up to 500 characters) to steer the model's tone.
4

Pick a retrieval mode

Choose Fast Mode or Multi-turn Agentic Mode.
5

Bind Knowledge Bases

Click Add to bind Knowledge Bases (up to 15) and configure per-source retrieval parameters.
6

Configure generation controls

Enable the refusal policy, prompt-leak protection, and other controls as needed.
7

Publish

Click Publish in the top right.

Retrieval modes

ModeHow it worksBest for
Fast ModeSingle-pass retrieval with the lowest latency.Simple factual questions.
Multi-turn Agentic ModeThe model plans the search strategy, rewrites the query multiple times, and merges results.Complex questions, multi-step reasoning, information spread across documents.

Generation controls

ParameterDescription
PromptSteers the model's tone — for example, "Answer only based on the Knowledge Base."
Refusal policyIf nothing relevant is retrieved, the model declines instead of fabricating an answer.
Prompt-leak protectionPrevents the model from echoing the system prompt or internal instructions.
CitationsAdds citation markers in the answer that link back to the source Chunk.
Multimodal replyAnswers can include images, tables, and other rich media.

API calls

Knowledge Q&A is invoked through the chat endpoint and returns an SSE stream:
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

The Q&A response streams these events in order:
EventDescription
plan_start → planning → plan_endPlanning — the model plans the retrieval and answer strategy.
tool_calling → tool_returnTool calling — tool_calling emits the retrieval request; tool_return returns matched chunks.
generation_start → generating → generation_endGeneration — streams the final answer; finish_reason is stop at generation_end.
In Multi-turn Agentic Mode, the plan → tool_calling → tool_return segment can repeat multiple times. See the chat endpoint for full event details.

Multi-turn dialogue

The platform doesn't persist conversation state — pass the full messages history on every request. Recommendations:
  • Cap history length (around the last 10 turns) to stay within the model's context window.
  • Retrieve based on the most recent user message only — older messages add noise.
After publishing the Q&A service, check Service Channels for integration options via API, MCP, CLI, and more.