Government affair document generation method and device based on large language model, equipment and medium

By using large language models and document knowledge graph generation methods, the problems of low efficiency and error-prone formatting in government document writing have been solved, achieving efficient and standardized document generation and secure storage.

CN121145802APending Publication Date: 2025-12-16INSPUR ENTERPRISE CLOUD TECHNOLOGY (SHANDONG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511353159.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-22
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

The current system for writing government documents is inefficient and prone to formatting errors. In particular, the need to frequently update templates due to policy changes leads to high costs for manual adjustments.

Method used

By leveraging a large language model and a document knowledge graph, the system collects document requirement texts through a multimodal entry point, performs preprocessing and encapsulation, and transmits them to the large language model via an encrypted channel for semantic parsing and type recognition. This generates standard-compliant document formats, and file conversion tools are used to generate documents in target formats such as Word, PDF, and OFD.

Benefits of technology

It significantly reduces the time cost of manual drafting and format adjustment, ensures the standardization and consistency of official document formats, and guarantees document security through encryption algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121145802A_ABST
    Figure CN121145802A_ABST
Patent Text Reader

Abstract

The invention discloses a government affair official document generation method and device based on a large language model, equipment and a medium, and relates to the technical field of computers, and the method comprises the following steps: determining an official document demand text by using a preset multi-modal entry, preprocessing the official document demand text to obtain a processed demand text, and storing the processed demand text in a server; packaging the processed demand text and metadata corresponding to the processed demand file, and performing semantic analysis and document type identification on the obtained packaged demand file by using a preset large language model and a few-sample prompt technology to obtain a target document type; constructing an official document knowledge graph based on each official document type, each official document element and each format attribute, generating an intermediate file by using the official document knowledge graph based on the target official document type, and converting the intermediate file into a document in a target format to obtain a target official document file; the target official document file is a file encrypted based on a preset encryption algorithm. And the problems of low efficiency and easy format error in the existing document writing are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for generating government documents based on a large language model. Background Technology

[0002] In the fields of e-government and smart office, official document writing has long relied on manual templates and manual formatting. Staff first select the corresponding Word template based on the document type (notice, request, report, etc.), then copy or type the text paragraph by paragraph, and subsequently repeatedly adjust formatting elements such as font, font size, paragraph indentation, headers and footers, and attachment labels. However, this method is inefficient and prone to errors. A thousand-word document needs to go through multiple steps, including "selecting a template, filling in the content, adjusting the format, checking the header, and proofreading the page numbers." Manual adjustments result in a high rate of formatting errors, such as inconsistent fonts, line spacing discrepancies, and misaligned official seals. Moreover, with policy changes, hundreds of templates need to be manually updated every year, making it very difficult to obtain a Word / PDF file that conforms to a standard format.

[0003] As can be seen from the above, how to avoid the low efficiency and error-prone format in existing official document writing is an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for generating government documents based on a large language model, which can avoid the low efficiency and error-prone formatting problems existing in current document writing. The specific solution is as follows:

[0005] Firstly, this application provides a method for generating government documents based on a large language model, including:

[0006] The document requirement text is determined by using a preset multimodal entry point. The document requirement text is preprocessed to obtain a processed requirement text. The metadata corresponding to the processed requirement text and the processed requirement file is encapsulated to obtain an encapsulated requirement file.

[0007] The encapsulated requirement file is transmitted to a preset large language model through a preset encrypted channel. The preset large language model and few-shot prompting technology are used to perform semantic parsing and document type identification on the encapsulated requirement file to obtain the target document type. The preset encrypted channel is an encrypted channel determined based on the transport layer security protocol.

[0008] Based on various document types, document elements, and format attributes, and utilizing preset document standards, a document knowledge graph is constructed. Based on the target document type and utilizing the document knowledge graph, an intermediate file is generated. A preset file conversion tool is used to convert the intermediate file into a document in the target format to obtain the target document file. The intermediate file is an HTML file containing inline CSS styles. The target document file is a file encrypted using a preset encryption algorithm.

[0009] Optionally, the step of determining the document requirement text using a preset multimodal entry point and preprocessing the document requirement text to obtain a processed requirement text includes:

[0010] Based on the web, mini-program, and desktop terminals, a preset multimodal entry point is determined, and the document requirement text, including natural language description, structured fields, and attachments, is obtained using the preset multimodal entry point;

[0011] Sensitive words that do not meet the preset government affairs norms in the official document requirement document are removed to obtain the requirement document after removal;

[0012] The removed requirement file is deduplicated by removing spaces to obtain a deduplicated requirement file, and the deduplicated requirement file is then segmented into sentences to obtain a processed requirement file.

[0013] Optionally, the step of encapsulating the processed requirement text and the metadata corresponding to the processed requirement file to obtain the encapsulated requirement file includes:

[0014] The metadata corresponding to the processed requirement file is determined based on the urgency of the document requirement text, the issuing department, and the number of attachments.

[0015] The processed requirement file and the metadata are encapsulated into a JSON format file to obtain the encapsulated requirement file.

[0016] Optionally, the step of transmitting the encapsulated requirement file to a preset large language model via a preset encrypted channel, and then using the preset large language model and few-shot hint technology to perform semantic analysis and document type identification on the encapsulated requirement file to obtain the target document type, includes:

[0017] A preset encryption channel is determined based on the transport layer security protocol. The encapsulated requirement file is then transmitted to a preset large language model through the preset encryption channel. The preset large language model and few-shot prompting technology are used to perform semantic parsing on the encapsulated requirement file to obtain the target document information.

[0018] Based on the target document information and using the preset large language model, the initial document type and corresponding confidence level are determined, and it is determined whether the confidence level is less than the target confidence level threshold.

[0019] If the confidence level is not less than the target confidence level threshold, then the initial document type is determined as the target document type.

[0020] Optionally, after determining whether the confidence level is less than the target confidence level threshold, the method further includes:

[0021] If the confidence level is less than the target confidence level threshold, an inquiry pop-up window including the initial document type will be sent to the user terminal so that the user terminal can return the corresponding response result based on the inquiry pop-up window;

[0022] If the response result indicates that the initial document type is correct, then the initial document type is determined as the target document type;

[0023] If the response result indicates that the initial document type is incorrect, then proceed to the step of transmitting the encapsulated requirement file to the preset large language model based on the preset encrypted channel, until the target document type is obtained.

[0024] Optionally, the construction of a document knowledge graph based on various document types, document elements, and format attributes, and utilizing preset document standards, includes:

[0025] Each document type is determined as the root node, each document element is determined as the child node, and each of the format attributes is determined as the leaf node. Based on the root node, the child nodes, and the leaf nodes, and using the preset document standards, a document knowledge graph is constructed.

[0026] Each of the sub-nodes is bound to its corresponding format attribute; the document elements include title, addressee, body, signature, header, and footer; the format attributes include font-related attributes, paragraph-related attributes, and page-related attributes.

[0027] Optionally, the step of generating intermediate files based on the target document type and utilizing the document knowledge graph, and then converting the intermediate files into a target format document using a preset file conversion tool to obtain the target document file, includes:

[0028] Obtain the target document elements and target format attributes corresponding to the target document type from the document knowledge graph, and construct an initial HTML file containing inline CSS styles based on the target document elements and target format attributes;

[0029] Based on the target document information and using the preset large language model and preset document logic, document text is generated. The document text and the target document information are then filled into the target position of the initial HTML file to obtain the target HTML file, and the target HTML file is determined as an intermediate file.

[0030] If the target format is Word format, the intermediate file is parsed, and the parsed inline CSS styles are mapped to font style nodes and paragraph style nodes of open document format. Based on the font style nodes, paragraph style nodes, headers, footers, page breaks and official seal floating images in the intermediate file, a Word format document is generated to obtain the target official document.

[0031] If the target format is PDF, the intermediate file is loaded and rendered using a preset command-line tool or a headless browser to obtain a rendered page. A PDF document is then generated based on the rendered page and preset printing style rules to obtain the target official document.

[0032] If the target format is OFD format, the intermediate file is converted into an OFD format document using a preset software development kit to obtain the target official document.

[0033] Secondly, this application provides a government document generation device based on a large language model, comprising:

[0034] The file encapsulation module is used to determine the document requirement text using a preset multimodal entry, preprocess the document requirement text to obtain the processed requirement text, and encapsulate the metadata corresponding to the processed requirement text and the processed requirement file to obtain the encapsulated requirement file.

[0035] The document type identification module is used to transmit the packaged requirement file to a preset large language model based on a preset encrypted channel, so as to use the preset large language model and few-sample prompting technology to perform semantic analysis and document type identification on the packaged requirement file to obtain the target document type; the preset encrypted channel is an encrypted channel determined based on the transport layer security protocol;

[0036] The target document determination module is used to construct a document knowledge graph based on various document types, document elements, and format attributes using preset document standards. It then generates an intermediate file based on the target document type and the document knowledge graph. Finally, it uses a preset file conversion tool to convert the intermediate file into a document in the target format to obtain the target document file. The intermediate file is an HTML file containing inline CSS styles. The target document file is an encrypted file based on a preset encryption algorithm.

[0037] Thirdly, this application provides an electronic device, comprising:

[0038] Memory, used to store computer programs;

[0039] A processor is used to execute the computer program to implement the aforementioned method for generating government documents based on a large language model.

[0040] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned method for generating government documents based on a large language model.

[0041] This application utilizes a preset multimodal entry point to determine the document requirement text, preprocesses the document requirement text to obtain a processed requirement text, encapsulates the metadata corresponding to the processed requirement text and the processed requirement file to obtain an encapsulated requirement file; transmits the encapsulated requirement file to a preset large language model based on a preset encrypted channel, and uses the preset large language model and few-shot hint technology to perform semantic analysis and document type identification on the encapsulated requirement file to obtain the target document type; the preset encrypted channel is an encrypted channel determined based on a transport layer security protocol; constructs a document knowledge graph based on each document type, each document element, and each format attribute and using a preset document standard; generates an intermediate file based on the target document type and using the document knowledge graph; and uses a preset file conversion tool to convert the intermediate file into a document of the target format to obtain the target document file; the intermediate file is an HTML file containing inline CSS styles; the target document file is a file encrypted based on a preset encryption algorithm.

[0042] As can be seen from the above, this application achieves diversified collection of official document requirement texts through a preset multimodal entry point. Combined with preprocessing and encapsulation operations, it ensures the compliance and standardization of input information and forms structured requirement data. A preset encrypted channel ensures the security of requirement data during transmission. Then, using a large language model and few-sample prompting technology, it achieves accurate semantic parsing and type identification of official document requirements to match the corresponding target document type. Based on preset document standards and various document types, elements, and format attributes, it constructs an official document knowledge graph. This knowledge graph is then used to generate HTML intermediate files containing inline CSS styles, ensuring the standardization and consistency of document formats. In this way, a preset file conversion tool converts the intermediate files into target document files in Word, PDF, OFD, and other target formats, and a preset encryption algorithm encrypts the target document files, ensuring file security and significantly reducing the time cost of manual drafting and format adjustment. Attached Figure Description

[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0044] Figure 1 This application discloses a flowchart of a method for generating government documents based on a large language model.

[0045] Figure 2 This application discloses a specific method for generating government documents based on a large language model.

[0046] Figure 3 This is a schematic diagram of the structure of a government document generation device based on a large language model disclosed in this application;

[0047] Figure 4 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. 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.

[0049] Currently, official document writing relies heavily on manual templates and layout. Manual adjustments result in a high rate of formatting errors, such as inconsistent fonts, line spacing discrepancies, and misaligned seals. With policy changes, hundreds of templates need to be manually updated annually, making it difficult to obtain a document that conforms to a standard format. To address this, this application provides a method for generating government documents based on a large language model. It utilizes a pre-set file conversion tool to convert intermediate files into target document formats such as Word, PDF, and OFD, and encrypts the target document using a pre-set encryption algorithm, ensuring document security and significantly reducing the time cost of manual drafting and formatting adjustments.

[0050] See Figure 1 As shown, this embodiment of the invention discloses a method for generating government documents based on a large language model, including:

[0051] Step S11: Determine the document requirement text using a preset multimodal entry point, preprocess the document requirement text to obtain the processed requirement text, and encapsulate the metadata corresponding to the processed requirement text and the processed requirement file to obtain the encapsulated requirement file.

[0052] In this embodiment, a preset multimodal entry point is determined based on the Web, Mini Program, and Desktop platforms. This preset multimodal entry point is used to obtain the document requirement text, which includes natural language descriptions, structured fields, and attachments. The document requirement text is then cleaned to remove sensitive words, deduplication, spaces, and sentence segmentation, resulting in a processed requirement text. Specifically, the process of determining the document requirement text using the preset multimodal entry point and preprocessing it to obtain the processed requirement text includes: determining a preset multimodal entry point based on the Web, Mini Program, and Desktop platforms, and using this preset multimodal entry point to obtain the document requirement text, which includes natural language descriptions, structured fields, and attachments; removing sensitive words from the document requirement text that do not meet preset government regulations, resulting in a removed requirement text; deduplicating spaces from the removed requirement text, resulting in a deduplicated requirement text; and segmenting the deduplicated requirement text into sentences, resulting in the processed requirement text.

[0053] It is understood that the metadata corresponding to the processed requirement file can be determined based on the urgency of the document requirement text, the issuing department, and the number of attachments. The processed requirement file and the metadata are then encapsulated into a JSON file, i.e., the encapsulated requirement file. Specifically, encapsulating the processed requirement text and the metadata corresponding to the processed requirement file to obtain the encapsulated requirement file includes: determining the metadata corresponding to the processed requirement file based on the urgency of the document requirement text, the issuing department, and the number of attachments; and encapsulating the processed requirement file and the metadata into a JSON file to obtain the encapsulated requirement file.

[0054] Step S12: The encapsulated requirement file is transmitted to a preset large language model based on a preset encrypted channel, so as to use the preset large language model and few-sample prompting technology to perform semantic parsing and document type identification on the encapsulated requirement file to obtain the target document type; the preset encrypted channel is an encrypted channel determined based on the transport layer security protocol.

[0055] In this embodiment, a preset encrypted channel is created using the Transport Layer Security (TLS) protocol. The encapsulated requirement file is then transmitted to a preset large language model via this encrypted channel. The preset large language model and few-shot hinting technology are used to perform semantic parsing on the encapsulated requirement file to obtain the target document information. The few-shot hinting technology in this embodiment includes a three-part structure consisting of a document type definition, an example, and the text to be identified. Based on the target document information and using the preset large language model, an initial document type and its corresponding confidence level are determined. The initial document types include notifications, requests, reports, and letters. Then, it is determined whether the confidence level is less than a target confidence threshold. If the confidence level is not less than the target confidence threshold, the initial document type is determined as the target document type. It is worth noting that the target confidence threshold can be adjusted according to actual circumstances and is not specifically limited here.

[0056] Specifically, the step of transmitting the encapsulated requirement file to a preset large language model based on a preset encrypted channel, and using the preset large language model and few-shot hint technology to perform semantic parsing and document type identification on the encapsulated requirement file to obtain the target document type, includes: determining a preset encrypted channel based on a transport layer security protocol; transmitting the encapsulated requirement file to the preset large language model based on the preset encrypted channel; using the preset large language model and few-shot hint technology to perform semantic parsing on the encapsulated requirement file to obtain target document information; determining an initial document type and its corresponding confidence level based on the target document information and using the preset large language model, and determining whether the confidence level is less than a target confidence level threshold; if the confidence level is not less than the target confidence level threshold, then the initial document type is determined as the target document type.

[0057] Understandably, if the confidence level is less than the target confidence level threshold, a pop-up query window including the initial document type will be sent to the user terminal so that the user terminal can determine whether the initial document type is consistent with the target document type. If the user terminal indicates that the initial document type is consistent with the target document type, the initial document type will be determined as the target document type. If the user terminal indicates that the initial document type is inconsistent with the target document type, the process will proceed to the step of transmitting the encapsulated requirement file to the preset large language model based on the preset encrypted channel, until the target document type is obtained. Specifically, after determining whether the confidence level is less than the target confidence level threshold, the method further includes: if the confidence level is less than the target confidence level threshold, sending a pop-up query window including the initial document type to the user terminal, so that the user terminal returns a corresponding response result based on the pop-up query window; if the response result indicates that the initial document type is correct, then determining the initial document type as the target document type; if the response result indicates that the initial document type is incorrect, then proceeding to the step of transmitting the encapsulated requirement file to the preset large language model based on the preset encrypted channel, until the target document type is obtained.

[0058] Step S13: Construct a document knowledge graph based on each document type, document element, and format attribute, and using a preset document standard. Generate an intermediate file based on the target document type and the document knowledge graph. Use a preset file conversion tool to convert the intermediate file into a document in the target format to obtain the target document file. The intermediate file is an HTML file containing inline CSS styles. The target document file is a file encrypted using a preset encryption algorithm.

[0059] In this embodiment, after obtaining the target document type, each document type is determined as the root node, such as notice, request, report, etc.; each document element is determined as the child node, such as title, body, addressee, attachment, header and footer, etc.; each format attribute is determined as the leaf node, such as the font, size, and position of the title, etc.; a document knowledge graph is constructed based on the root node, the child nodes, and the leaf nodes, using preset document standards. It is worth noting that the values ​​corresponding to the leaf nodes are stored in key-value pairs, and the document knowledge graph is stored in a combined database of Redis (RemoteDictionary Server) and MySQL (My Structured Query Language), supporting hot updates. Specifically, the construction of a document knowledge graph based on document types, document elements, and format attributes using preset document standards includes: determining each document type as the root node, each document element as a child node, and each format attribute as a leaf node; constructing a document knowledge graph based on the root node, the child nodes, and the leaf nodes using preset document standards; wherein each child node is bound to its corresponding format attribute; the document elements include title, addressee, body, signature, header, and footer; the format attributes include font-related attributes, paragraph-related attributes, and page-related attributes.

[0060] Understandably, after obtaining the document knowledge graph, the target document elements and target format attributes corresponding to the target document type are retrieved from the document knowledge graph. An initial HTML file containing inline CSS (Cascading Style Sheets) styles is constructed based on the target document elements and target format attributes; inline CSS refers to directly writing formatting instructions within HTML tags. Then, based on the target document information and using the preset large language model and preset document logic, document text is generated. The document text and the target document information are then filled into the target positions of the initial HTML file to obtain the target HTML file, which is then designated as the intermediate file. If the target format of the final target document file is Word format, then docx4j (a Java library for document conversion and processing) is used to parse the intermediate file, and the attributes in the parsed inline CSS styles are mapped to the Office Open XML format. <w:rpr> 、 <w:ppr>If the target format is a PDF format, the intermediate file is loaded and rendered by using a wkhtmltopdf (an open source command line tool), the same HTML is loaded and the print style sheet is injected @media print, ensuring that the page margin, page break, and paper type are matched, and then a PDF format document is generated to obtain the target official document file; if the target format is an OFD (Open Fixed-layout Document) format, the intermediate file is converted into an OFD format document by using an OFD rendering SDK (Software Development Kit), to obtain the target official document file. It is worth mentioning that the target official document file can be encrypted by using an SM4 block cipher algorithm.

[0061] Specifically, the method comprises the following steps: obtaining target official document elements and target format attributes corresponding to the target official document type from the official document knowledge graph, and constructing an initial HTML file containing inline CSS styles based on the target official document elements and the target format attributes; generating official document text based on the target official document information and by using a preset large language model and a preset official document logic, filling the official document text and the target official document information into a target position of the initial HTML file to obtain a target HTML file, and determining the target HTML file as an intermediate file; if the target format is a Word format, the intermediate file is parsed, and the parsed inline CSS styles are mapped into font style nodes and paragraph style nodes of an open document format, a Word format document is generated based on the font style nodes, the paragraph style nodes, header, footer, page break, and official seal floating pictures in the intermediate file, to obtain a target official document file; if the target format is a PDF format, the intermediate file is loaded and rendered by using a preset command line tool or a headless browser to obtain a rendered page, a PDF format document is generated based on the rendered page and a preset print style rule to obtain a target official document file; if the target format is an OFD format, the intermediate file is converted into an OFD format document by using a preset software development kit to obtain a target official document file.

[0062] It can be seen from the above that the application realizes diversified collection of document demand text through a preset multi-modal portal, ensures compliance and standardization of input information through preprocessing and packaging operations, and forms structured demand data; the security of the demand data in the transmission process is ensured based on a preset encryption channel, and then the precise semantic analysis and type identification of the document demand are realized by using a large language model and a few sample prompt technology, so as to match the corresponding target document type; a document knowledge graph is constructed based on preset document standards and various document types, document elements and format attributes, so as to ensure the standardization and consistency of the document format by using the document knowledge graph to generate an HTML intermediate file containing inline CSS styles; in this way, the intermediate file is converted into a target document file in a target format such as Word, PDF, OFD, etc. by using a preset file conversion tool, and the target document file is encrypted by using a preset encryption algorithm, thereby ensuring the security of the file and greatly reducing the time cost of manual writing and format adjustment.

[0063] As can be seen from the above embodiments, the application realizes the generation and format layout of the document by using a preset large language model and a document knowledge graph, and therefore the process of realizing the generation and format layout of the document by using a preset large language model and a document knowledge graph is described.

[0064] Referring to Figure 2 As shown in the drawings, the embodiment of the application discloses a specific government document generation method based on a large language model, which comprises the following steps:

[0065] In this embodiment, first, a preset multi-modal portal is used to obtain a document demand text corresponding to a user demand, then the document demand file is preprocessed to obtain a processed demand file, then a transmission layer security protocol is used to construct a preset encryption channel, the encrypted demand file is transmitted to a preset large language model based on the preset encryption channel, the semantic analysis of the encrypted demand file is performed by using the preset large language model and a few sample prompt technology to obtain target document information, the initial document type and the corresponding confidence are determined based on the target document information and by using the preset large language model, and then it is judged whether the confidence is less than a target confidence threshold; if the confidence is not less than the target confidence threshold, the initial document type is determined as the target document type; if the confidence is less than the target confidence threshold, an inquiry pop-up window including the initial document type is sent to the user end, so that the user end returns a corresponding reply result based on the inquiry pop-up window; if the reply result indicates that the initial document type is correct, the initial document type is determined as the target document type; if the reply result indicates that the initial document type is incorrect, the step of transmitting the encrypted demand file to the preset large language model based on the preset encryption channel is jumped to until the target document type is obtained.

[0066] It can be understood that after obtaining the target document type, each document type is determined as a root node, each document element is determined as a child node, and each format attribute is determined as a leaf node, a document knowledge graph is constructed based on the root node, the child node and the leaf node and by using a preset document standard, target document elements and target format attributes corresponding to the target document type are acquired from the document knowledge graph, and an initial HTML file containing an inline CSS style is constructed based on the target document elements and the target format attributes; then a document text is generated based on the target document information and by using the preset large language model and a preset document logic, the document text and the target document information are filled into a target position of the initial HTML file to obtain a target HTML file, and the target HTML file is determined as an intermediate file.

[0067] Further, a target document file in a target format is generated based on user demand. Specifically, if the target format is a Word format, the intermediate file is parsed, and the parsed inline CSS style is mapped to an open document format font style node and a paragraph style node, a document in the Word format is generated based on the font style node, the paragraph style node, a header, a footer, a page break and a public seal floating picture in the intermediate file, and a target document file is obtained; if the target format is a PDF format, a preset command line tool or a headless browser is used to load and render the intermediate file to obtain a rendered page, and a document in the PDF format is generated based on the rendered page and a preset printing style rule to obtain a target document file; if the target format is an OFD format, a preset software development kit is used to convert the intermediate file into a document in the OFD format to obtain a target document file.

[0068] As can be seen from the above, the document knowledge graph is constructed by using the document type, the document element and the format attribute, and the generation and determination of the document text and the target document content are performed by using the document knowledge graph and the preset large language model, so that the document format error rate is greatly reduced; then the typeset target HTML file is used as an intermediate file, the target document file in the Word / PDF / OFD format can be directly exported according to user demand, and secondary format adjustment is performed during the exporting process, so that the accuracy of the document format is greatly improved, and manual document format adjustment and writing are no longer needed, thereby saving costs.

[0069] Correspondingly, referring to Figure 3 The application further provides a government document generation device based on a large language model, which comprises:

[0070] The file packaging module 11 is configured to determine a government document demand text by using a preset multi-modal portal, preprocess the government document demand text to obtain a processed demand text, and package the processed demand text and metadata corresponding to the processed demand file to obtain a packaged demand file.

[0071] The government document type identification module 12 is configured to transmit the packaged demand file to a preset large language model based on a preset encrypted channel, perform semantic analysis and government document type identification on the packaged demand file by using the preset large language model and a few-sample prompt technology, and obtain a target government document type; the preset encrypted channel is an encrypted channel determined based on a transport layer security protocol.

[0072] The target file determination module 13 is configured to construct a government document knowledge graph based on each government document type, each government document element and each format attribute and by using a preset government document standard, generate an intermediate file based on the target government document type and by using the government document knowledge graph, and convert the intermediate file into a document in a target format by using a preset file conversion tool to obtain a target government document file; the intermediate file is an HTML format file containing an inline CSS style; and the target government document file is a file encrypted based on a preset encryption algorithm.

[0073] In some embodiments, the file packaging module 11 can specifically include:

[0074] The demand file acquisition unit is configured to determine a preset multi-modal portal based on a web end, an applet end and a desktop end, and acquire a government document demand text including a natural language description, a structured field and an attachment by using the preset multi-modal portal.

[0075] The sensitive word elimination unit is configured to eliminate sensitive words in the government document demand file that do not meet preset government affairs specification conditions to obtain an eliminated demand file.

[0076] The file sentence division unit is configured to remove spaces from the eliminated demand file to obtain a de-duplicated demand file, and divide the de-duplicated demand file into sentences to obtain a processed demand file.

[0077] In some embodiments, the file packaging module 11 can specifically include:

[0078] The metadata determination unit is configured to determine metadata corresponding to the processed demand file based on an urgency of the government document demand text, a document issuing department and a number of attachments.

[0079] The file packaging unit is configured to package the processed demand file and the metadata into a file in a JSON format to obtain a packaged demand file.

[0080] In some embodiments, the official document type identification module 12 can specifically include:

[0081] A file parsing unit is configured to determine a preset encryption channel based on a transport layer security protocol, transmit the encapsulated demand file to a preset large language model based on the preset encryption channel, and perform semantic parsing on the encapsulated demand file by using the preset large language model and a few-shot prompting technique to obtain target official document information.

[0082] An initial type determination unit is configured to determine an initial official document type and a corresponding confidence based on the target official document information and by using the preset large language model, and determine whether the confidence is less than a target confidence threshold.

[0083] A target type determination unit is configured to determine the initial official document type as a target official document type if the confidence is not less than the target confidence threshold.

[0084] In some embodiments, the official document generation device based on a large language model can further specifically include:

[0085] A reply result returning unit is configured to transmit an inquiry pop-up window including the initial official document type to a user terminal if the confidence is less than the target confidence threshold, so that the user terminal returns a corresponding reply result based on the inquiry pop-up window.

[0086] A first result determination unit is configured to determine the initial official document type as a target official document type if the reply result indicates that the initial official document type is correct.

[0087] A second result determination unit is configured to jump to the step of transmitting the encapsulated demand file to the preset large language model based on the preset encryption channel until a target official document type is obtained if the reply result indicates that the initial official document type is incorrect.

[0088] In some embodiments, the target file determination module 13 can specifically include:

[0089] A graph construction unit is configured to determine each official document type as a root node, each official document element as a child node, and each format attribute as a leaf node, and construct an official document knowledge graph based on the root node, the child node, and the leaf node and by using a preset official document standard.

[0090] In some embodiments, the target file determination module 13 can specifically include:

[0091] An initial file construction unit is configured to acquire target official document elements and target format attributes corresponding to the target official document type from the official document knowledge graph, and construct an initial HTML file containing inline CSS styles based on the target official document elements and the target format attributes;

[0092] An intermediate file determination unit is configured to generate an official document text based on the target official document information and by using the preset large language model and a preset official document logic, fill the official document text and the target official document information into a target position of the initial HTML file to obtain a target HTML file, and determine the target HTML file as an intermediate file;

[0093] A first format judgment unit is configured to, if the target format is a Word format, parse the intermediate file, map the parsed inline CSS styles to font style nodes and paragraph style nodes in an open document format, generate a document in the Word format based on the font style nodes, the paragraph style nodes, a header, a footer, a page break, and a public seal floating picture in the intermediate file, and obtain a target official document file.

[0094] A second format judgment unit is configured to, if the target format is a PDF format, load and render the intermediate file by using a preset command line tool or a headless browser to obtain a rendered page, generate a document in the PDF format based on the rendered page and a preset printing style rule, and obtain a target official document file.

[0095] A third format judgment unit is configured to, if the target format is an OFD format, convert the intermediate file into a document in the OFD format by using a preset software development kit, and obtain a target official document file.

[0096] Further, the present application also discloses an electronic device, Figure 4 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the contents in the figure cannot be considered as any limitation on the use range of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, the computer program is loaded and executed by the processor 21, and the related steps in the official document generation method based on the large language model disclosed in any of the preceding embodiments are implemented. In addition, the electronic device 20 in the present embodiment can be an electronic computer.

[0097] In this embodiment, the power supply 23 is configured to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 is configured to create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which will not be specifically limited herein; the input and output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which will not be specifically limited herein.

[0098] In addition, the memory 22 as a carrier for storing resources can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.

[0099] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the government document generation method based on the large language model executed by the electronic device 20 disclosed in any of the preceding embodiments, the computer program 222 can further include a computer program capable of completing other specific work.

[0100] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the government document generation method based on the large language model disclosed above. For the specific steps of the method, please refer to the corresponding content disclosed in the preceding embodiments, which will not be described here.

[0101] In the specification, each embodiment is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. For the same or similar parts between the embodiments, please refer to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and please refer to the method part for the relevant part.

[0102] The skilled person can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of the two. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in the above description. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0103] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0104] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0105] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.< / w:ppr> < / w:rpr>

Claims

1. A method for generating government documents based on a large language model, characterized in that, include: The document requirement text is determined by using a preset multimodal entry point. The document requirement text is preprocessed to obtain a processed requirement text. The metadata corresponding to the processed requirement text and the processed requirement file is encapsulated to obtain an encapsulated requirement file. The encapsulated requirement file is transmitted to a preset large language model through a preset encrypted channel. The preset large language model and few-shot prompting technology are used to perform semantic parsing and document type identification on the encapsulated requirement file to obtain the target document type. The preset encrypted channel is an encrypted channel determined based on the transport layer security protocol. Based on various document types, document elements, and format attributes, and utilizing preset document standards, a document knowledge graph is constructed. Based on the target document type and utilizing the document knowledge graph, an intermediate file is generated. A preset file conversion tool is used to convert the intermediate file into a document in the target format to obtain the target document file. The intermediate file is an HTML file containing inline CSS styles. The target document file is a file encrypted using a preset encryption algorithm.

2. The method for generating government documents based on a large language model according to claim 1, characterized in that, The step of determining the document requirement text using a preset multimodal entry point and preprocessing the document requirement text to obtain the processed requirement text includes: Based on the web, mini-program, and desktop terminals, a preset multimodal entry point is determined, and the document requirement text, including natural language description, structured fields, and attachments, is obtained using the preset multimodal entry point; Sensitive words that do not meet the preset government affairs norms in the official document requirement document are removed to obtain the requirement document after removal; The removed requirement file is deduplicated by removing spaces to obtain a deduplicated requirement file, and the deduplicated requirement file is then segmented into sentences to obtain a processed requirement file.

3. The method for generating government documents based on a large language model according to claim 1, characterized in that, The process of encapsulating the processed requirement text and the metadata corresponding to the processed requirement file to obtain the encapsulated requirement file includes: The metadata corresponding to the processed requirement file is determined based on the urgency of the document requirement text, the issuing department, and the number of attachments. The processed requirement file and the metadata are encapsulated into a JSON format file to obtain the encapsulated requirement file.

4. The method for generating government documents based on a large language model according to claim 1, characterized in that, The process involves transmitting the encapsulated requirement file to a preset large language model via a preset encrypted channel. This model, along with few-shot hints technology, is used to perform semantic analysis and document type identification on the encapsulated requirement file to obtain the target document type. This includes: A preset encryption channel is determined based on the transport layer security protocol. The encapsulated requirement file is then transmitted to a preset large language model through the preset encryption channel. The preset large language model and few-shot prompting technology are used to perform semantic parsing on the encapsulated requirement file to obtain the target document information. Based on the target document information and using the preset large language model, the initial document type and corresponding confidence level are determined, and it is determined whether the confidence level is less than the target confidence level threshold. If the confidence level is not less than the target confidence level threshold, then the initial document type is determined as the target document type.

5. The method for generating government documents based on a large language model according to claim 4, characterized in that, After determining whether the confidence level is less than the target confidence level threshold, the method further includes: If the confidence level is less than the target confidence level threshold, an inquiry pop-up window including the initial document type will be sent to the user terminal so that the user terminal can return the corresponding response result based on the inquiry pop-up window; If the response result indicates that the initial document type is correct, then the initial document type is determined as the target document type; If the response result indicates that the initial document type is incorrect, then proceed to the step of transmitting the encapsulated requirement file to the preset large language model based on the preset encrypted channel, until the target document type is obtained.

6. The method for generating government documents based on a large language model according to claim 1, characterized in that, The construction of a document knowledge graph based on various document types, document elements, and format attributes, and utilizing preset document standards, includes: Each document type is determined as the root node, each document element is determined as the child node, and each of the format attributes is determined as the leaf node. Based on the root node, the child nodes, and the leaf nodes, and using the preset document standards, a document knowledge graph is constructed. Each of the sub-nodes is bound to its corresponding format attribute; the document elements include title, addressee, body, signature, header, and footer; the format attributes include font-related attributes, paragraph-related attributes, and page-related attributes.

7. The method for generating government documents based on a large language model according to claim 4, characterized in that, The process of generating intermediate files based on the target document type and utilizing the document knowledge graph, and then converting the intermediate files into a target format document using a preset file conversion tool to obtain the target document file, includes: Obtain the target document elements and target format attributes corresponding to the target document type from the document knowledge graph, and construct an initial HTML file containing inline CSS styles based on the target document elements and target format attributes; Based on the target document information and using the preset large language model and preset document logic, document text is generated. The document text and the target document information are then filled into the target position of the initial HTML file to obtain the target HTML file, and the target HTML file is determined as the intermediate file. If the target format is Word format, the intermediate file is parsed, and the parsed inline CSS styles are mapped to font style nodes and paragraph style nodes of open document format. Based on the font style nodes, paragraph style nodes, headers, footers, page breaks and official seal floating images in the intermediate file, a Word format document is generated to obtain the target official document. If the target format is PDF, the intermediate file is loaded and rendered using a preset command-line tool or a headless browser to obtain a rendered page. A PDF document is then generated based on the rendered page and preset printing style rules to obtain the target official document. If the target format is OFD format, the intermediate file is converted into an OFD format document using a preset software development kit to obtain the target official document.

8. A government document generation device based on a large language model, characterized in that, include: The file encapsulation module is used to determine the document requirement text using a preset multimodal entry, preprocess the document requirement text to obtain the processed requirement text, and encapsulate the metadata corresponding to the processed requirement text and the processed requirement file to obtain the encapsulated requirement file. The document type identification module is used to transmit the packaged requirement file to a preset large language model based on a preset encrypted channel, so as to use the preset large language model and few-sample prompting technology to perform semantic analysis and document type identification on the packaged requirement file to obtain the target document type; the preset encrypted channel is an encrypted channel determined based on the transport layer security protocol; The target document determination module is used to construct a document knowledge graph based on various document types, document elements, and format attributes using preset document standards. It then generates an intermediate file based on the target document type and the document knowledge graph. Finally, it uses a preset file conversion tool to convert the intermediate file into a document in the target format to obtain the target document file. The intermediate file is an HTML file containing inline CSS styles. The target document file is an encrypted file based on a preset encryption algorithm.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor is configured to execute the computer program to implement the government document generation method based on a large language model as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the government document generation method based on a large language model as described in any one of claims 1 to 7.