compress_texts

Function

Compresses text based on question (prompt), context (long text), and compress_rate (compression rate).

Prototype

def compress_texts(context, question, compress_rate, context_reorder)

Parameters

Parameter

Data Type

Required/Optional

Description

context

String

Required

Long text to be summarized. Its length range is [1, 16 MB].

question

String

Required

Prompt for summarizing the long text, which is used to calculate the relevance with the context chunk. Its length range is [1, 1000 × 1000].

compress_rate

Float

Optional

Compression rate. The default value is 0.6. The value range is (0, 1).

context_reorder

Bool

Optional

Whether to perform re-ranking based on the score. The default value is False. If the value is True, after the relevance is calculated, chunks with low relevance are preferentially retained based on the compression rate.

Return Value

Data Type

Description

String

Compressed text