Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Hpcaitech ColossalAI RetrievalConversation

From Leeroopedia


Knowledge Sources
Domains RAG, NLP
Last Updated 2026-02-09 00:00 GMT

Overview

Conversational RAG pipeline with query disambiguation and rejection filtering, provided by ColossalQA.

Description

ChineseRetrievalConversation and EnglishRetrievalConversation implement language-specific RAG pipelines. They combine a CustomRetriever, an LLM (via ColossalAPI), conversation memory (ConversationBufferWithSummary), a disambiguation chain, and a RetrievalQA chain into a complete conversational QA system.

Usage

Create from a retriever and LLM configuration, then call run() with user queries.

Code Reference

Source Location

  • Repository: ColossalAI
  • File (Chinese): applications/ColossalQA/colossalqa/retrieval_conversation_zh.py
  • Lines: 23-96
  • File (English): applications/ColossalQA/colossalqa/retrieval_conversation_en.py
  • Lines: 23-88

Signature

class ChineseRetrievalConversation:
    def __init__(
        self,
        retriever: CustomRetriever,
        model_path: str,
        model_name: str,
    ) -> None:
        """
        Args:
            retriever: Configured CustomRetriever with indexed documents
            model_path: Path to local LLM model
            model_name: Model type identifier (e.g., "chatglm2")
        """

    def run(
        self,
        user_input: str,
        memory: ConversationBufferWithSummary,
    ) -> Tuple[str, ConversationBufferWithSummary]:
        """Process a user query through the RAG pipeline."""

    @classmethod
    def from_retriever(cls, retriever, model_path, model_name):
        """Factory method to create from a retriever."""

Import

from colossalqa.retrieval_conversation_zh import ChineseRetrievalConversation
from colossalqa.retrieval_conversation_en import EnglishRetrievalConversation

I/O Contract

Inputs

Name Type Required Description
retriever CustomRetriever Yes Configured retriever with indexed documents
model_path str Yes Path to local LLM
model_name str Yes Model type identifier
user_input str Yes User's question
memory ConversationBufferWithSummary Yes Conversation history

Outputs

Name Type Description
answer str Generated answer (first line of response)
memory ConversationBufferWithSummary Updated conversation memory

Usage Examples

from colossalqa.retrieval_conversation_zh import ChineseRetrievalConversation
from colossalqa.memory import ConversationBufferWithSummary

conversation = ChineseRetrievalConversation(
    retriever=retriever,
    model_path="/models/chatglm2-6b",
    model_name="chatglm2",
)

memory = ConversationBufferWithSummary(llm=conversation.llm)
answer, memory = conversation.run("什么是ColossalAI?", memory)
print(answer)

Related Pages

Implements Principle

Environment and Heuristic Links

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment