A Smart Paragraph Merging Translation Method and System Based on Structured Prompt Words

By constructing structured prompts and merging rules, a large language model can complete batch translation and intelligent merging of multiple paragraphs in a single API call, solving the problems of low efficiency, high cost, and semantic fragmentation in document translation, improving translation efficiency and quality, and reducing economic costs.

CN121118923BActive Publication Date: 2026-03-06北京领初医药科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511678909.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-03-06
Estimated Expiration
2045-11-17

AI Technical Summary

Technical Problem

Existing document translation technologies based on large language models suffer from problems such as low translation efficiency, semantic fragmentation, high cost, and complex format processing. In particular, in the translation of long documents, the contextual understanding capabilities of large language models cannot be effectively utilized, resulting in low translation efficiency, high cost, and poor quality.

Method used

By constructing structured prompt words, the large language model is guided to complete batch translation and intelligent merging of multiple paragraphs in a single API call. Paragraph identifiers and merging rules are used to ensure semantic coherence between paragraphs and physical merging is performed in the document structure, simplifying format processing.

Benefits of technology

Significantly improves translation efficiency, reduces translation costs, ensures semantic coherence between paragraphs, simplifies formatting, and enhances translation quality and readability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121118923B_ABST
    Figure CN121118923B_ABST
Patent Text Reader

Abstract

This invention provides an intelligent paragraph merging translation method and system based on structured prompt words, belonging to the field of natural language processing technology. The method first performs structured processing on the paragraphs of the document to be translated, constructing a data body for each paragraph containing identifiers, source text, and translation. Then, it constructs structured prompt words containing paragraph merging instructions, defines merging rules, and instructs the model to store the merged translation in a specific paragraph while setting the translation fields of other merged paragraphs to null. Next, it sends all structured data and merging instructions to a large language model for batch translation and intelligent merging through a single API call. Finally, it reconstructs the document structure based on the returned merging information, achieving the physical merging of paragraphs. This invention significantly improves translation efficiency and economy, ensures semantic coherence of the context, simplifies the formatting of the translated document, and solves the problems of low efficiency, high cost, and semantic fragmentation associated with traditional paragraph-by-paragraph translation methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, specifically to an intelligent paragraph merging and translation method and system based on structured prompt words. Background Technology

[0002] With the acceleration of globalization and the increasing demand for cross-language communication, document translation has become an indispensable part of various fields. Especially in the translation of professional texts such as technical documents, academic papers, and business reports, how to efficiently, accurately, and economically complete large-scale document translation tasks has become a pressing technical challenge for the industry. In recent years, large language models have demonstrated powerful capabilities in the field of machine translation, providing new technological pathways for document translation.

[0003] Existing document translation technologies based on large language models typically employ a paragraph-by-paragraph translation approach. This involves breaking the document down into independent paragraphs, translating each paragraph individually using the large language model API, and then reassembling the translations in their original order. This traditional approach suffers from numerous technical drawbacks in practical applications.

[0004] First, translation efficiency is severely limited. Because each paragraph requires a separate API call, a long document containing hundreds of paragraphs necessitates a corresponding number of network requests. Each API call involves network transmission latency, model inference time, and result return, resulting in an overall translation time of 10 to 30 minutes. Frequent network requests not only increase cumulative latency but also raise the risk of failure due to network instability, requiring additional retry mechanisms, further impacting translation efficiency and system stability.

[0005] Secondly, semantic coherence between paragraphs is difficult to guarantee. Translating each paragraph independently severs the semantic connections between them, preventing the large language model from acquiring complete contextual information. This semantic fragmentation manifests in inconsistencies in terminology translation, confused referential relationships, and improper logical connections. Particularly in technical documents and academic papers, paragraphs often contain complex logical progressions, conceptual dependencies, or chains of argumentation. Independent translation cannot maintain this inherent coherence, severely impacting translation quality. When related paragraphs are processed separately, the same technical term may have multiple different translations, damaging the document's professionalism and readability.

[0006] Furthermore, translation costs are difficult to control effectively. Large language model API services typically charge based on the number of calls or the number of tokens processed, leading to a rapid accumulation of costs with multiple API calls. For large documents, translation costs can reach $5 to $15, which is a significant expense for enterprises or organizations that need to process large volumes of documents. Existing solutions lack effective cost optimization mechanisms and cannot reduce economic costs while ensuring translation quality, thus limiting the large-scale commercial application of large language models in the field of document translation.

[0007] Furthermore, maintaining formatting and reorganizing paragraphs after translation presents a significant technical challenge. Traditional methods require complex algorithms to match and reorganize the translated text with the original paragraphs after translation. Due to differences in expression and sentence structure between languages, the number and length of paragraphs in the translated text may not perfectly correspond to those in the original. This necessitates the use of complex matching algorithms, such as binary search, to determine paragraph correspondences. These algorithms are not only computationally complex but also prone to errors when handling special cases such as paragraph merging and splitting, lacking an intuitive and effective mechanism for managing paragraph correspondences.

[0008] While existing natural language processing toolkits and translation systems have made improvements in some aspects, they still fail to fundamentally solve the aforementioned problems. They either continue to use the traditional model of multiple calls, or, although attempting batch processing, lack intelligent paragraph organization strategies and cannot fully utilize the contextual understanding capabilities of large language models. Especially in scenarios that require dynamically adjusting paragraph translation strategies based on semantic relationships, existing technical solutions prove inadequate. Summary of the Invention

[0009] The purpose of this invention is to provide an intelligent paragraph merging translation method and system based on structured prompt words, which can fully utilize the powerful translation capabilities of large language models while solving technical problems such as low efficiency, semantic fragmentation, high cost, and complex format processing, thereby achieving efficient, accurate, and economical document translation.

[0010] To achieve the above objectives, the present invention provides the following technical solution:

[0011] A method for intelligent paragraph merging and translation based on structured prompt words, comprising:

[0012] S1: Perform structured processing on the paragraphs of the document to be translated, and construct a structured data body for each paragraph containing paragraph identifiers, source text content, and translation fields;

[0013] S2: Construct a structured prompt word containing paragraph merging instructions. The structured prompt word defines the merging rules for the paragraphs to be merged. The merging rules indicate that the merged translation is stored in the translation field of the paragraph with the smallest paragraph identifier in the merged paragraph group, and the translation fields of the remaining merged paragraphs are set to empty.

[0014] S3: Send the structured prompt words containing all paragraph structured data and merging instructions to the large language model through a single API call to obtain a translation response containing the paragraph merging processing results;

[0015] S4: Based on the paragraph merging information in the translation response, reconstruct the document structure and physically merge the paragraphs to be merged within the document.

[0016] Further: the structured data body in step S1 includes:

[0017] The paragraph unique identifier, paragraph_id, is used to identify the sequence number of each paragraph in the document;

[0018] The original_text field stores the original text of the paragraph.

[0019] The translation_text field is used to store the translated text content, and is initially empty.

[0020] Furthermore, step S1 also includes: performing semantic correlation analysis on adjacent paragraphs; identifying mergeable paragraph combinations based on semantic correlation, paragraph length, and content complexity; generating a candidate merging list and determining the optimal paragraph merging strategy.

[0021] Furthermore, the structured prompts constructed in step S2 include: a paragraph data structure description section, which defines the data format of paragraph identifiers and original text content; a merging rule instruction section, which clearly specifies which paragraphs need to be merged and translated and the storage location of the merged translation; and a list of paragraphs to be translated section, which contains all the structured paragraph data that needs to be translated.

[0022] Further: The document structure reconstruction in step S4 includes: identifying paragraphs with empty translation fields in the translation response and determining them as the paragraphs to be merged; locating the paragraph node corresponding to the merged paragraph in the document DOM tree; transferring the content of the merged paragraph node to the target paragraph node with the merged translation; updating the reference relationships and indexes between paragraphs to maintain the integrity of the document format.

[0023] Furthermore, the content transfer of the paragraph nodes specifically includes: extracting the content of all text nodes of the paragraphs to be merged and appending it to the text nodes of the target paragraph; setting the merged complete translation in the text nodes of the target paragraph; deleting or clearing the DOM nodes of the merged paragraphs while retaining the document structure markup.

[0024] Furthermore, it also includes: performing structured parsing of the translation response returned by the large language model; verifying the execution of the merging rules to ensure that the translation fields of the merged paragraphs meet the preset null value requirements; and implementing error handling and retry mechanisms when an abnormality in the execution of the merging rules is detected.

[0025] Furthermore, the method supports multiple paragraph merging modes: two-paragraph merging mode, which merges two adjacent paragraphs into one translation unit; multi-paragraph merging mode, which merges three or more consecutive paragraphs into one translation unit; and hybrid merging mode, which applies multiple different merging strategies simultaneously in the same document.

[0026] Furthermore, the method also includes dynamic merging strategy adjustment: real-time analysis of the semantic similarity of paragraph content; dynamic determination of paragraph combinations to be merged based on a preset similarity threshold; and automatic generation of corresponding structured prompt words based on the dynamic analysis results.

[0027] This invention also provides an intelligent paragraph merging and translation system based on structured prompt words, comprising:

[0028] The data structuring module is used to perform structuring processing on the paragraphs of the document to be translated, and to build a structured data body for each paragraph, which includes paragraph identifiers, source text content and translation fields;

[0029] The prompt word construction module is used to construct a structured prompt word containing paragraph merging instructions. The structured prompt word defines the merging rules for the paragraphs to be merged. The merging rules indicate that the merged translation is stored in the translation field of the paragraph with the smallest paragraph identifier in the merged paragraph group, and the translation fields of the remaining merged paragraphs are set to empty.

[0030] The translation execution module is used to send the structured data body containing all paragraphs and the merging instructions to the large language model through a single API call, and obtain a translation response containing the paragraph merging processing results;

[0031] The structure reconstruction module is used to reconstruct the document structure based on the paragraph merging information in the translation response, and to physically merge the paragraphs to be merged in the document.

[0032] Compared with the prior art, the present invention has the following advantages:

[0033] I. Significantly Improved Translation Efficiency. This invention guides a large language model using structured prompts to complete batch translation and intelligent merging of multiple paragraphs in a single API call, reducing the multiple API calls required in traditional solutions to a single call. This optimization fundamentally reduces the number of network requests, eliminates the cumulative effect of network latency and the time loss caused by multiple retries, significantly shortens the overall document translation time, and significantly improves the execution efficiency and system response speed of translation tasks.

[0034] Second, it significantly reduces translation costs. By optimizing multiple API calls into a single call, this invention fundamentally reduces API usage fees. Since API services are typically charged based on the number of calls or the number of tokens processed, single batch processing significantly reduces overall costs compared to multiple independent calls. This cost advantage makes the commercial application of large-scale document translation more economically feasible, providing enterprises and institutions with a cost-controllable solution.

[0035] Third, ensuring semantic coherence between paragraphs. This invention provides complete contextual information in a single request, enabling the large language model to fully understand the semantic connections and logical relationships between paragraphs. In particular, by explicitly specifying paragraph merging rules through structured prompts, it ensures the holistic processing of related paragraphs during translation. This method effectively solves problems such as inconsistent terminology, confused referential relationships, and improper logical connections in traditional paragraph-by-paragraph translation, significantly improving the translation quality and readability of professional documents.

[0036] IV. Simplified Formatting Complexity. This invention establishes a clear paragraph correspondence through paragraph identifiers (paragraph_id). The merged translations are stored in designated locations according to predetermined rules, and the translation fields of the merged paragraphs are set to empty. This explicit data structure avoids the complex binary matching algorithm in traditional solutions. The DOM tree reconstruction process directly performs node operations based on the explicit merging information, eliminating the need for complex paragraph matching and reorganization calculations, greatly reducing the technical complexity and error probability of formatting processing. Attached Figure Description

[0037] Figure 1 This is a flowchart illustrating one embodiment of the intelligent paragraph merging and translation method based on structured prompt words according to the present invention;

[0038] Figure 2 This is a schematic diagram of the framework of the intelligent paragraph merging and translation system based on structured prompt words according to one embodiment of the present invention. Detailed Implementation

[0039] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0040] The intelligent paragraph merging and translation method based on structured prompt words provided by this invention is based on constructing a structured data body and prompt words in a specific format to guide a large language model to complete the batch translation and intelligent merging of multiple paragraphs in a single API call.

[0041] In specific implementation, such as Figure 1 As shown, it includes the following steps:

[0042] S1: Perform structured processing on the paragraphs of the document to be translated, and construct a structured data body for each paragraph containing paragraph identifiers, source text content, and translation fields.

[0043] Specifically, after receiving the input document, the system parses and numbers each paragraph, creating a structured data body for each paragraph. This structured data body contains three key fields: a unique paragraph identifier (paragraph_id), the original text content (original_text), and the translation text (translation_text). The paragraph_id is numbered according to the paragraph's order in the document, such as 1, 2, 3, up to n, ensuring each paragraph has a unique identifier. The original_text field stores the original text content of the paragraph. The translation_text field stores the translated text; initially, this field is an empty string. This structured data organization provides a clear data foundation for subsequent paragraph merging and result mapping.

[0044] While structuring paragraphs, the system can also perform semantic analysis. By analyzing the content relevance, thematic coherence, and logical relationships between adjacent paragraphs, the system can identify paragraph combinations suitable for merging and translation. The semantic analysis process considers multiple factors, including paragraph length, content complexity, and density of technical terms, to generate a candidate merging list. For example, when adjacent paragraphs are detected discussing the same technical concept or exhibiting a clear causal relationship, the system marks these paragraphs as candidate combinations suitable for merging.

[0045] S2: Construct a structured prompt word containing paragraph merging instructions. The structured prompt word defines the merging rules for the paragraphs to be merged. The merging rules indicate that the merged translation should be stored in the translation field of the paragraph with the smallest paragraph identifier in the merged paragraph group, and the translation fields of the remaining merged paragraphs should be set to empty.

[0046] Specifically, the structured prompts consist of three main components. The first part is a paragraph data structure description, explicitly informing the large language model of the format of the input data, including paragraph IDs and the organization of the original text content. The second part is the merging rule instruction, which is one of the core innovations of this invention. The merging rule explicitly specifies the processing logic for paragraph merging: when multiple paragraphs need to be merged, the merged complete translation is stored in the translation_text field of the paragraph with the smallest paragraph ID in the merged paragraph group, while the translation_text fields of the other merged paragraphs are set to empty strings. The third part is a list of paragraphs to be translated, containing all the structured paragraph data that needs to be translated.

[0047] Let's take a specific technical document translation example. Suppose there's a technical manual containing 50 paragraphs that needs to be translated. The system will generate the following structured prompts: First, it will state that the system should translate the following structured paragraph data, informing the large model to maintain overall structural consistency, ensuring the returned translation array has the same length as the input array, and if two translations are merged into one sentence, to retain the merged paragraph_id, and setting the translation to an empty string. Then, it will list the structured data for all 50 paragraphs, with each data item containing a paragraph_id, original_text, and an initially empty translation_text field.

[0048] S3: Send the structured prompt words containing all paragraph structured data and merging instructions to the large language model through a single API call to obtain a translation response containing the paragraph merging processing results.

[0049] Specifically, after the structured prompts are sent to the large language model via a single API call, the model processes them according to the instructions in the prompts. Once the large language model understands the merging rules, it merges and translates the specified paragraphs while maintaining the independent translation of other paragraphs. In the example above, the model understands and translates paragraphs 7 and 8 as a whole, generating a semantically coherent and terminologically consistent translation. This merged translation is then added to the `translation_text` field of paragraph 7, while leaving the `translation_text` field of paragraph 8 empty.

[0050] After receiving the translation results from the large language model, the system performs structured parsing and verification. During parsing, the system extracts the translation_text content corresponding to each paragraph_id and checks whether the merging rules are executed correctly. The verification mechanism confirms that among the paragraphs to be merged, only the paragraph with the smallest ID contains a translation, and the translation field of the remaining paragraphs is indeed empty. If an anomaly is detected, the system will activate the error handling mechanism, which may include rebuilding the prompt words or adjusting the merging strategy and retrying.

[0051] S4: Based on the paragraph merging information in the translation response, reconstruct the document structure and physically merge the paragraphs to be merged within the document.

[0052] Document structure reconstruction is the final step in the entire process and a crucial step in ensuring the integrity of the translated document's format. Specifically, based on the paragraph merging information in the translation results, the system performs corresponding physical merging operations within the document's DOM tree structure. Specifically, the system first identifies paragraphs with empty translation fields; these paragraphs are the ones to be merged. Then, it locates the corresponding paragraph nodes in the DOM tree, typically the paragraph tag nodes in the document.

[0053] When performing a DOM tree merging process, the system extracts the content of all text nodes from the paragraphs to be merged. For example, all text nodes from paragraph 8 are appended to the text nodes of paragraph 7, creating a new paragraph containing both paragraphs. The system then sets the complete merged translation within this merged paragraph node. The original paragraph nodes can be deleted or cleared as needed, but it's crucial to preserve the document structure markup to maintain the overall formatting integrity of the document. During this process, the system also updates the reference relationships and indexes between paragraphs, ensuring that cross-references and table of contents links within the document remain correct.

[0054] When handling more complex scenarios, the system demonstrates greater flexibility. For example, for an academic paper, it might be necessary to merge and translate paragraphs 3, 4, and 5, as well as paragraphs 12 and 13. The system explicitly specifies these two merging rules in the structured prompts: the translation of the merged paragraphs 3, 4, and 5 is placed in paragraph 3, while the translation of paragraphs 4 and 5 is empty; the translation of the merged paragraphs 12 and 13 is placed in paragraph 12, while the translation of paragraph 13 is empty. The large language model processes these two paragraph merges simultaneously, completing all translation and merging operations in a single API call.

[0055] The method of this invention can be implemented using a corresponding system. For example... Figure 2As shown, the system includes a data structuring module, a prompt word construction module, a translation execution module, and a structure reconstruction module. The data structuring module is responsible for parsing the input document and creating a structured data body; the prompt word construction module generates structured prompt words containing merging instructions based on the merging strategy; the translation execution module manages API interactions with the large language model; and the structure reconstruction module is responsible for performing DOM tree merging operations based on the translation results. These modules work together to achieve efficient and intelligent paragraph merging translation.

[0056] Through the specific implementation methods described above, this invention successfully solves the problems of low efficiency, high cost, and semantic fragmentation in traditional document translation, providing an innovative technical solution for the field of document translation. Practice shows that this method can significantly improve translation efficiency and reduce costs while ensuring translation quality, demonstrating promising application prospects.

[0057] The above embodiments are only for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent transformations or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for intelligent paragraph merging translation based on structured prompt words, characterized in that, Comprise: S1: structuring the paragraphs of the document to be translated, constructing a structured data body for each paragraph containing paragraph identification, original content and translation fields; S2: constructing a structured prompt containing paragraph merging instructions, which contains a paragraph data structure description part, a merging rule instruction part and a list of paragraphs to be translated, wherein the paragraph data structure description part defines the data format of the paragraph identification and the original content, the merging rule instruction part specifies which paragraphs need to be merged and the storage location of the merged translation, and the list of paragraphs to be translated contains all structured paragraph data that need to be translated; the merging rule of the merged paragraph is defined in the structured prompt, which indicates that the merged translation is stored in the translation field of the paragraph with the smallest paragraph identification in the merged paragraph group, and the translation fields of the remaining merged paragraphs are set to empty; S3: sending the structured prompt containing all paragraph structured data bodies and merging instructions to the large language model through a single API call to obtain a translation response containing paragraph merging processing results; S4: according to the paragraph merging information in the translation response, reconstruct the document structure and physically merge the merged paragraphs in the document.

2. The method of claim 1, wherein, The structured data body in step S1 comprises: Paragraph unique identifier paragraph_id, used to identify the serial number of each paragraph in the document; Original content field original_text, used to store the original text of the paragraph; Translation field translation_text, used to store the translated text content, initially empty.

3. The method of claim 1, wherein, The step S1 further comprises: performing semantic correlation analysis on adjacent paragraphs; identifying the paragraph combination that can be merged based on semantic correlation, paragraph length and content complexity; generating a candidate merging list to determine the optimal paragraph merging strategy.

4. The method of claim 1, wherein, The document structure reconstruction in step S4 includes: identifying paragraphs with empty translation fields in the translation response as merged paragraphs; locating the paragraph nodes corresponding to the merged paragraphs in the document DOM tree; transferring the content of the merged paragraph nodes to the target paragraph node with the merged translation; updating the reference relationship and index between paragraphs to maintain the integrity of the document format.

5. The method of claim 4, wherein, The content transfer of the paragraph node specifically includes: extracting and appending all text node contents of the merged paragraph to the target paragraph text node; setting the complete translation after merging in the target paragraph text node; deleting or emptying the DOM node of the merged paragraph while retaining the document structure markers.

6. The method according to any one of claims 1 to 5, characterized in that, Further comprising: structurally analyzing the translation response returned by the large language model; verifying the execution of the merging rule to ensure that the translation field of the merged paragraph meets the preset null value requirement; when detecting abnormal execution of the merging rule, performing error handling and retry mechanism.

7. The method of claim 1, wherein, The method supports multiple paragraph merging modes: two-paragraph merging mode, which merges two adjacent paragraphs into one translation unit; multi-paragraph merging mode, which merges three or more consecutive paragraphs into one translation unit; Hybrid merge mode, which applies multiple different merge strategies simultaneously in the same document.

8. The method of claim 1, wherein, The method further comprises dynamic merge strategy adjustment: real-time analysis of semantic similarity of paragraph content; dynamically determine the paragraph combination that needs to be merged based on the preset similarity threshold; automatically generate the corresponding structured prompt word according to the dynamic analysis result. 9.A structured prompt word based intelligent paragraph merging translation system, characterized in that, Comprise: The data structure module is used for structuring the paragraphs of the document to be translated, and constructing a structured data body containing paragraph identification, original content and translation field for each paragraph; The prompt word construction module is used for constructing a structured prompt word containing paragraph merge instructions, which contains a paragraph data structure description part, a merge rule instruction part and a list of paragraphs to be translated, wherein the paragraph data structure description part defines the data format of the paragraph identification and the original content, the merge rule instruction part specifies which paragraphs need to be merged and translated and the storage location of the merged translation, and the list of paragraphs to be translated contains all structured paragraph data that need to be translated; the merge rule of the merged paragraph is defined in the structured prompt word, which indicates that the merged translation is stored in the translation field of the paragraph with the smallest paragraph identification in the merged paragraph group, and the translation fields of the remaining merged paragraphs are set to empty; The translation execution module is used for sending the structured prompt word containing all paragraph structured data bodies and merge instructions to a large language model through a single API call, and obtaining a translation response containing paragraph merge processing results; The structure reconstruction module is used for reconstructing the document structure according to the paragraph merge information in the translation response, and physically merging the merged paragraphs in the document.

Citation Information

Patent Citations

  • File extraction and reduction method favorable for translation work

    CN104933041A

  • Contract document translation method and system based on large model

    CN120509421A