The invention provides an RAG-based text block dynamic segmentation method and
system, and the method comprises the steps: analyzing a multi-level
directory structure of a document, and segmenting a text block by taking a
directory node as a reference; for a document without a
directory or with an incomplete directory, a mixed segmentation mode of rules and
semantics is switched; performing potential
Dirichlet distribution topic modeling on the continuous
text stream, and calculating a topic distribution vector of each text segment in real time; performing adaptive segmentation on the detected topic boundary, inserting a hard segmentation mark at a topic
mutation point, and performing soft segmentation on a gradual change topic area; the
initial window size of the sliding window is set according to the document type, and the semantic density in the window is monitored in real time; and layering, blocking and recombining. The
system comprises a segmentation mode module, a mark confirmation module and a block recombination module. According to the method, the RAG retrieval accuracy is improved, the memory occupation is reduced, and meanwhile, the streaming
throughput is supported.