Class Introduction

Function

Extracts and summarizes the content of a document.

Prototype

from mx_rag.summary import Summary
Summary(llm, llm_config)

Parameters

Parameter

Data Type

Required/Optional

Description

llm

Text2TextLLM

Required

LLM object instance. For details, see Text2TextLLM.

llm_config

LLMParameterConfig

Optional

Parameters for calling an LLM. Change the default value of temperature to 0.5 and that of top_p to 0.95. For details about other parameters, see LLMParameterConfig.

Example

from langchain_text_splitters import RecursiveCharacterTextSplitter
from mx_rag.document.loader import DocxLoader
from mx_rag.llm import Text2TextLLM
from mx_rag.summary import Summary
from mx_rag.utils import ClientParam
client_param = ClientParam(ca_file="/path/to/ca.crt")
llm = Text2TextLLM(base_url="https://ip:port/v1/chat/completions", model_name="qianwen-7b", client_param=client_param)
loader=DocxLoader("/home/HwHiAiUser/MindIE.docx")
docs = loader.load_and_split(RecursiveCharacterTextSplitter(chunk_size=750, chunk_overlap=150))
summary = Summary(llm=llm)
# Call the summarize method.
sub_summaries = summary.summarize([doc.page_content for doc in docs])
# Call the merge_text_summarize method.
res = summary.merge_text_summarize(sub_summaries)
print(res)