Document generation method and device, equipment and storage medium
By obtaining user needs and knowledge base information, and using template databases and large language models to automatically generate documents, the inconsistency in document quality and time-consuming problems caused by manual writing in the existing technology are solved, and efficient and professional document generation is achieved.
Patent Information
- Application Number
- CN202510612891.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-26
AI Technical Summary
The writing of existing technology documents relies on manual labor, resulting in uneven document quality, time-consuming and complexity, especially in cross-departmental and cross-field cooperation, it is difficult to ensure the unity and professionalism of documents.
By obtaining user demand information and knowledge base information, using template databases and large language models, the target documents are automatically generated, and combining mixed search and multimodal data processing can ensure the accuracy and consistency of the documents.
It realizes automatic generation of documents, reduces labor costs, improves document writing efficiency and quality, and ensures the professionalism and readability of documents.
Smart Images

Figure CN120542398A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a document generation method, apparatus, device and storage medium. Background Art
[0002] With the rapid development of information technology, technical documentation has become an indispensable component across various industries. Technical documentation plays a crucial role in various engineering projects, project development, product design, scientific research, and software development. It provides clear guidance to team members, clients, and partners, ensuring the smooth progress of projects. However, in the current technical documentation process, most companies still rely on manual compilation by technical personnel, a process with many shortcomings.
[0003] Manually writing technical documentation is often tedious and time-consuming, and is susceptible to differences in technical expertise, resulting in inconsistent document quality. Different writing styles and technical proficiency can lead to inconsistent document styles, hindering understanding and readability. Furthermore, as project scale and technology advance, document writing becomes increasingly complex, especially in cross-departmental and cross-disciplinary collaborations, where documentation must encompass not only technical details but also a degree of generalizability. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a document generation method, device, equipment and storage medium, which can realize the automatic generation of documents, thereby reducing labor costs and improving document writing efficiency and quality.
[0005] In order to solve the above technical problems, a first aspect of an embodiment of the present invention discloses a document generation method, the method comprising:
[0006] S1, obtaining demand information and knowledge base information input by the user; the knowledge base information includes a plurality of knowledge base data information;
[0007] S2, processing the demand information according to the template database information to obtain professional field information and target template information;
[0008] S3, using the demand information and the professional field information, searching the knowledge base information to obtain text data information that matches the demand information;
[0009] S4, processing the target template information, the requirement information and the text data information to obtain target document information.
[0010] A second aspect of an embodiment of the present invention discloses a document generation device, comprising:
[0011] An acquisition module is used to acquire the demand information and knowledge base information input by the user; the knowledge base information includes a plurality of knowledge base data information;
[0012] A first processing module is used to process the demand information according to the template database information to obtain professional field information and target template information;
[0013] A second processing module is used to retrieve the knowledge base information using the demand information and the professional field information to obtain text data information matching the demand information;
[0014] The third processing module is used to process the target template information, the requirement information and the text data information to obtain target document information.
[0015] A third aspect of an embodiment of the present invention discloses an electronic device, comprising:
[0016] processor;
[0017] a memory coupled to the processor and storing executable program code;
[0018] The processor calls the executable program code stored in the memory to execute part or all of the steps of the document generation method disclosed in the first aspect of the embodiment of the present invention.
[0019] A fourth aspect of an embodiment of the present invention discloses a storage medium having a computer program stored thereon, which, when executed by a processor, implements part or all of the steps of the document generation method disclosed in the first aspect of the embodiment of the present invention.
[0020] An embodiment of the present application provides a document generation method, apparatus, device and storage medium, the method comprising: obtaining demand information and knowledge base information input by a user; the knowledge base information comprises a plurality of knowledge base data information; processing the demand information according to template database information to obtain professional field information and target template information; using the demand information and the professional field information, retrieving and processing the knowledge base information to obtain text data information matching the demand information; processing the target template information, the demand information and the text data information to obtain target document information.
[0021] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0022] (1) Since the target document can be automatically generated only by the user inputting the required information, the entire process is highly automated and does not require human intervention, thus realizing the automation and intelligence of document generation, improving the accuracy and professionalism of the document, reducing labor costs, and optimizing work efficiency.
[0023] (2) Since relevant text data can be retrieved during the target document generation process, and the target document is generated based on the retrieved relevant text data, it is ensured that the content of the target document is always based on the most accurate information, thereby ensuring the quality of the target document.
[0024] (3) Since the target template is determined based on the user's demand information, the use of the template ensures the standardization and consistency of the document format and improves the professionalism and readability of the document. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0026] Figure 1 A schematic diagram of a flow chart of a document generation method disclosed in an embodiment of the present invention;
[0027] Figure 2 A schematic structural diagram of a document generation device disclosed in an embodiment of the present invention;
[0028] Figure 3 The figure is a schematic structural diagram of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0030] The terms "first," "second," and so on, in the description and claims of the present invention and the accompanying drawings are used to distinguish between different objects, not to describe a specific order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or elements is not limited to the listed steps or elements but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or device.
[0031] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0032] The present invention discloses a document generation method, apparatus, device, and storage medium, which can realize automatic document generation, thereby reducing labor costs and improving document writing efficiency and quality. Detailed descriptions are provided below.
[0033] Example 1
[0034] See also Figure 1 , Figure 1 This is a flow chart of a document generation method disclosed in an embodiment of the present invention. Figure 1 The document generation method described is applied to a document generation device, such as a local server or cloud server for document generation optimization management, etc., which is not limited in the embodiment of the present invention. Figure 1 As shown, the document generation method may include the following operations:
[0035] S1, obtaining the user's input demand information and knowledge base information; the knowledge base information includes several knowledge base data information;
[0036] Requirement information can be understood as a set of requirements that a user must meet for a desired document. User-entered requirement information can be understood as a set of requirements that a user must meet for a desired document, entered through an input device. Requirement information typically includes, but is not limited to, the following aspects: the document's professional field, the document's intended audience, the document's purpose, the document's content scope, the document's format requirements, and the document's technical details.
[0037] Furthermore, the above-mentioned demand information may be information that complies with a specific format or requirement, or may be information in a natural language form input by a user.
[0038] Obtaining user input demand information includes: obtaining user input demand information input by the user through a client interface. A user interface is displayed in the client, allowing the user to input demand information in the user interface. The above-mentioned client can be a web form, a mobile application, desktop software, or other types of clients. The client can interact with an electronic device that executes the document generation method provided by an embodiment of the present application, so that the electronic device that executes the document generation method provided by an embodiment of the present application can obtain the user input demand information input by the user through the client interface.
[0039] Furthermore, obtaining the demand information input by the user may include: obtaining the demand information input by the user in text form, or obtaining the demand information input by the user in voice form, and converting the demand information in voice form into demand information in text form.
[0040] Knowledge base information refers to a collection specifically used to store and manage data, which can be a structured database or an unstructured document collection. Specifically, multimodal data is stored in the knowledge base information. Multimodal data refers to data that combines multiple different forms, which can come from different sources or sensory channels. Storing multimodal data in the knowledge base information means that the knowledge base information contains not only text data, but also image data, audio data, video data, graphical data (such as charts and models), etc. Among them, the knowledge base information also includes structured data and unstructured data. Structured data can include tables, database records, etc. Unstructured data can include social media posts, emails, etc.
[0041] By integrating multimodal data, knowledge base information can provide users with deeper understanding and support, and provide richer and more comprehensive information representation to support complex content creation and analysis tasks.
[0042] S2, processing the demand information according to the template database information to obtain professional field information and target template information;
[0043] The template database can be understood as a collection of predefined document templates. These templates can be any document format, such as contracts, reports, letters, and forms. Furthermore, these templates can include technical documents from various professional fields, such as software development, hardware engineering, network and information security, mechanical engineering, chemical engineering, aerospace engineering, biotechnology, and pharmaceutical engineering.
[0044] The target template information can be understood as a document template manually selected by a user from the template database information.
[0045] The demand information is processed according to the template database information to obtain the target template information, including: in response to receiving the demand information input by the user, the document template in the template database information is sent to the client and displayed in the client interface, and the client responds to the user's selection operation on the document template displayed in the client interface, and receives the document template corresponding to the selection operation sent by the client as the target template information.
[0046] The target template information can also be understood as a document template that matches the requirement information. A document template that matches the requirement information can be understood as one in which the professional field information corresponding to the target template information is the same as or similar to the professional field information to which the requirement information belongs. And / or, the document type corresponding to the target template information is the same as or similar to the document type to which the requirement information belongs.
[0047] In one possible implementation, the demand information is processed according to the template database information to obtain professional field information and target template information, including: performing semantic recognition on the demand information to obtain the professional field information of the document to be generated; screening out multiple templates that match the professional field information of the document to be generated from the template database information as an initial template set; and screening out target template information that matches the user's historical behavior data from the initial template set.
[0048] The professional field information of the document to be generated can be understood as the professional field to which the document to be generated belongs. The index of each document template in the template database information includes the professional field information to which the document template belongs, wherein the index of a document template may include at least one professional field information.
[0049] S3, using the demand information and professional field information, search and process the knowledge base information to obtain text data information that matches the demand information;
[0050] Utilize demand information and professional field information to retrieve and process knowledge base information to obtain text data information that matches the demand information, including preprocessing the demand information input by the user to obtain query content. Preprocessing includes: word segmentation, removal of stop words, and expansion of synonyms, etc., to optimize the query content and obtain more accurate query results.
[0051] Furthermore, hybrid retrieval technology uses demand information and professional field information to search the knowledge base information and obtain text data information that matches the demand information. Hybrid retrieval combines the advantages of sparse vectors and dense vectors to improve the accuracy and efficiency of retrieval.
[0052] Furthermore, hybrid retrieval technology is used to search the knowledge base based on the demand information and professional field information to obtain text data that matches the demand information. Hybrid retrieval combines the advantages of sparse vectors and dense vectors to improve the accuracy and efficiency of retrieval.
[0053] In one possible implementation, the demand information and professional field information are used to retrieve and process the knowledge base information to obtain text data information that matches the demand information, including: performing semantic recognition on the demand information to obtain the professional field information to which the document to be generated belongs; selecting target knowledge base information that matches the professional field information to which the document to be generated belongs, the target knowledge base information storing multimodal data related to the professional field information to which the document to be generated belongs; and using hybrid retrieval technology to search in the target knowledge base information to obtain text data information that matches the demand information.
[0054] In the embodiments of the present application, knowledge base information for different professional fields is pre-integrated. The knowledge base information for each professional field information stores the relevant professional knowledge of the professional field information, and each knowledge base information is indexed by its corresponding professional field information. For example, the knowledge base information for the "construction engineering" professional field information stores professional knowledge related to "construction engineering." The relevant professional knowledge includes: laws and regulations in the construction engineering field, design requirements, structural engineering, construction management, technical literature, building materials, case studies, equipment and tools, and other aspects of knowledge.
[0055] S4, processing the target template information, requirement information and text data information to obtain target document information.
[0056] It should be noted that the requirement information may also include: document style information, generated text length, etc.
[0057] Based on the target template information and demand information, text generation prompt words are generated and input into the large language model. The text generation prompt words are used to guide the large language model to generate text content that matches the demand information and receive the text data information output by the large language model.
[0058] The target template information and demand information are processed to generate text generation prompt words, and the text generation prompt words are input into the large language model. The text generation prompt words are used to guide the large language model to generate a document matching the demand information based on the target template information and text data information matching the demand information, and receive the target document information output by the large language model.
[0059] Using an advanced template engine, the text data generated by the large language model and retrieved text data are intelligently populated into the target template information. The entire process is highly automated, requiring no human intervention, ensuring content accuracy and consistency. The powerful generation capabilities of the large language model ensure that the generated technical documentation is fluent, logically rigorous, and consistent with the conventional expression practices of the professional field. This not only saves significant manpower and time, but also effectively prevents human error.
[0060] The above generated text data information and the text data information matching the demand information are merged to eliminate duplication and contradiction to obtain final high-quality text data information, and the final high-quality text data information is filled into the target template information to obtain the target document information.
[0061] In one possible implementation, the requirement information also includes the document format of the document to be generated, wherein the document format of the document to be generated includes word, pdf, etc. The format of the target document information is converted into the document format included in the requirement information to ensure that the output target document information complies with technical specifications and meets personalized needs.
[0062] In the embodiments of this application, multiple output formats, such as Word and PDF, are supported to meet the diverse needs of users. The generated documents strictly adhere to technical specifications, with attractive formatting and professional layout. Users no longer need to perform tedious format conversions and adjustments, and can directly obtain usable, high-quality technical documents. This significantly improves the user experience and simplifies the workflow.
[0063] In one possible implementation, the requirement information also includes language requirements for the document to be generated, where the languages of the document to be generated include Chinese, English, Japanese, Korean, etc. The document to be generated is translated from Chinese into the language included in the requirement information to ensure that the output target document information meets the language required by the user.
[0064] Furthermore, a professional terminology database is pre-established, which includes professional terms in different languages. When translating a document to be generated from Chinese to the language included in the requirement information, the professional terminology database is called, and the corresponding Chinese professional term in the translated language included in the requirement information is searched from the professional terminology database, and the searched professional term is used for translation. For example, when translating a document to be generated from Chinese to English, the professional terminology database is called, and the corresponding English translation of the Chinese professional term is searched from the professional terminology database, and the translated English is used as the content after the professional term is translated.
[0065] In this application embodiment, the target document information generation in multiple languages is supported. It can automatically translate the generated document into multiple languages based on user needs, thereby forming the final target document information. Leveraging the cross-language capabilities of a large language model, combined with a professional terminology database, this ensures that the translated document meets high standards of professionalism and accuracy. This meets the needs of international enterprises and multinational projects, and has significant practical value.
[0066] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0067] In an optional embodiment, obtaining knowledge base data information includes:
[0068] It should be noted that for different professional fields, knowledge base data information corresponding to each professional field can be constructed, and the construction process of the knowledge base data information corresponding to each professional field adopts the process of obtaining knowledge base data information provided in the embodiment of this application.
[0069] S11, obtaining data information to be processed, data type information corresponding to the data information to be processed, and metadata information;
[0070] Unprocessed data can be understood as data that needs to be stored in the knowledge base. The unprocessed data can be structured or unstructured. Structured data can include tables, database records, and numerical values. Unstructured data can include social media posts and emails.
[0071] Furthermore, the data to be processed can also be multimodal data, which refers to data that combines multiple different forms. Storing multimodal data in the knowledge base means that the knowledge base contains not only text data, but also image data, audio data, video data, graphical data (such as charts and models), etc.
[0072] Furthermore, the data to be processed can come from different sources or sensory channels. In other words, the data to be processed can be obtained from multiple data sources or data channels, where the data sources or data channels include published paper libraries, knowledge bases, social media, public websites, etc.
[0073] In the modern information environment, multimodal data forms are becoming increasingly rich. Multimodal data often contains a large amount of valuable technical information. This application introduces an intelligent preprocessing mechanism for multimodal data fusion, which first receives multimodal raw data from knowledge base data information and other data sources, including but not limited to text, images, audio and video.
[0074] Metadata is data that describes the data being processed—in other words, "data about the data." Metadata includes additional information about the data being processed, helping users understand, manage, and use it. Metadata can contain various types of information, depending on the data object being described and the application scenario.
[0075] Metadata information includes: descriptive metadata, structural metadata, management metadata, usage metadata, technical metadata, legal metadata, preservation metadata, etc.
[0076] Descriptive metadata is used to describe the content characteristics of resources for easy identification and retrieval. It usually includes information such as title, author, abstract, keywords, and subject classification. Structural metadata represents the relationship between data components, such as book chapters and web page link structures. It helps to organize and navigate complex information collections. Administrative metadata involves the management aspects of data, such as copyright statements, access rights, creation date, modification timestamp, file format, and technical requirements. Technical metadata is about the technical details of the data, such as file size, resolution, encoding format, hardware / software environment, etc. Usage metadata reflects information about how the data is used, such as the number of downloads, citations, user comments, etc. Legal metadata contains legal terms related to the data, such as license agreements, privacy policies, and compliance statements. Preservation metadata focuses on the long-term preservation and maintenance of data, and may involve fixity checks, migration records, etc.
[0077] S12, processing the data information to be processed and the data type information to obtain preprocessing model information corresponding to the data information to be processed;
[0078] According to different data types, special pre-processing model information and models are used to process the data information to be processed.
[0079] Specifically, the data types of the data information to be processed include text data, audio data, video data, and image data, and the processing algorithms used for each type of data are different.
[0080] The data type of the data to be processed can be determined by the physical properties, metadata, and content characteristics of the file. The following are the specific methods:
[0081] 1) Determine the data type of the data to be processed by reading the file extension. Different types of files usually have different extensions. If the file extension of the data to be processed is a text extension, such as .txt, .csv, .json, .xml, .html, .md, etc., then determine that the data to be processed is text data; if the file extension of the data to be processed is an audio extension, such as .mp3, .wav, .aac, .flac, .ogg, etc., then determine that the data to be processed is audio data; if the file extension of the data to be processed is a video extension, such as .mp4, .avi, .mkv, .mov, .wmv, etc., then determine that the data to be processed is video data; if the file extension of the data to be processed is an image extension, such as .jpg, .jpeg, .png, .gif, .bmp, .tiff, etc., then determine that the data to be processed is image data.
[0082] 2) For data information to be processed and transmitted on the Internet, the data type of the data information to be processed can be determined by MIME (Multipurpose Internet Mail Extensions) type. The MIME type can be found in the HTTP response header and can be used to more accurately determine the file type.
[0083] 3) Many file formats contain specific byte sequences at the beginning of their files. These byte sequences are called "magic numbers" and can be used to identify the actual format of the file even if the file extension is changed. For example, a JPEG image file usually starts with the byte sequence FF D8 FF.
[0084] When the data to be processed is text, natural language processing (NLP) technology can be used as preprocessing model information. NLP technology refers to a series of computing techniques and theoretical models designed to enable computers to understand, interpret, and generate natural human language.
[0085] When the data to be processed is image data, convolutional neural network (CNN) technology can be used as the preprocessing model information. Convolutional neural networks (CNN) are deep learning models specifically designed to process data with grid-like structures, most commonly two-dimensional image data. CNNs have achieved great success in the field of computer vision and are widely used in tasks such as image recognition, object detection, and image segmentation. The core idea of CNN is to simulate the hierarchical feature extraction mechanism of biological vision systems. It automatically learns the spatial hierarchical features of the input data through a series of convolutional and pooling layers.
[0086] When the data to be processed is audio data, speech recognition technology (Automatic Speech Recognition, ASR) can be used as preprocessing model information. ASR is a technology that converts human speech signals into text.
[0087] When the data to be processed is video data, a combination of image and audio processing techniques can be used as preprocessing model information. Since video is essentially composed of a series of continuous image frames (i.e., video frames), often accompanied by a synchronized audio track, ASR technology is used to identify the audio data in the audio track, while CNN technology is used to extract key data information from the image frames.
[0088] S13, using the preprocessing model information to process the data information to be processed to obtain key data information;
[0089] Key data information in the data to be processed can be understood as data elements or features of great significance in the data to be processed, such as the description objects of the data to be processed, the relationships between objects, etc.
[0090] When the data to be processed is text data, natural language processing technology is used to pre-process the data to obtain key data information. Pre-processing includes word segmentation, part-of-speech tagging, syntactic analysis, named entity recognition, etc. Key data information includes text summaries of the data to be processed, etc.
[0091] Furthermore, we use appropriate parsing tools or conversion algorithms to extract text data from text data in various formats. We then clean the extracted text data to remove noise and redundant information, such as special characters, HTML tags, and blank lines. We then use machine learning algorithms to perform statistical analysis on the text data, calculating the mean, maximum, and minimum text lengths to understand the distribution of the text data.
[0092] When the data to be processed is image data, computer vision techniques, such as convolutional neural networks (CNNs), are used to perform image recognition, object detection, and feature extraction on the image data to obtain key data information. Key data information includes textual descriptions of the image content. For example, structural information can be extracted from device design drawings or key components can be identified from schematics.
[0093] When the data to be processed is audio data, we use speech recognition technology (ASR) to convert the speech content into text and perform sentiment analysis and semantic understanding to obtain key data information from the audio data. For example, we can extract operation steps and precautions from technical explanation audio.
[0094] When the data to be processed is video data, computer vision and speech recognition technologies are used to extract key frames, subtitles, and audio content from the video data, and then conduct a comprehensive analysis of the key data information in the video. For example, operating procedures and safety tips can be extracted from a demonstration video.
[0095] In one possible implementation, for each piece of data to be processed, a large language model is used to clean, organize, and perform semantic understanding on the data to extract key data information. The key data information extracted by the large language model is then fused with the key data information extracted by the preprocessing algorithm to obtain the key data information for each piece of data to be processed. This fusion can be performed by merging, taking an intersection, or other methods, and the specific implementation is not limited in this embodiment of the present invention.
[0096] S14, integrating the data information to be processed, the metadata information and the key data information to obtain the knowledge base data information.
[0097] The data information to be processed, metadata information and key data information are integrated and processed to obtain knowledge base data information, including adding metadata information and key data information such as page number, document name, author, release time, etc. to the data information to be processed, so as to obtain knowledge base data information for subsequent retrieval and reference.
[0098] Furthermore, for each piece of data to be processed, the extracted key data information is divided into blocks and vectorized to establish an index structure.
[0099] Specifically, extract valid information from key data information and eliminate irrelevant content. Then, use recursive character text segmentation technology to cut the long text into multiple structured text blocks. The length and content of each text block are independent, which is convenient for subsequent processing. Use semantic representation models (such as BERT, GPT, etc.) through sparse retrieval technology to deeply understand the deep semantics of each text block. Based on the text embedding model, these text blocks are converted into high-dimensional numerical vectors to capture the semantic features of the text. The numerical vector of the text block and its corresponding key data information, data to be processed, and metadata are stored as an index to establish an efficient retrieval structure. The above-mentioned integration processing is to store the numerical vector of the text block and its corresponding key data information, data to be processed, and metadata as an index to establish an efficient retrieval structure.
[0100] In the embodiments of this application, data preprocessing can efficiently process raw data from different channels, including structured and unstructured data, to adapt to various data sources and avoid processing difficulties caused by the diversity of data formats. By introducing a large language model, the system has a strong semantic understanding capability, capable of deep cleaning and organizing data, and accurately extracting key data information. This not only improves the efficiency of data processing, but also ensures the content quality of the subsequently generated documents.
[0101] In the embodiments of the present application, a preprocessing mechanism for multimodal data fusion is introduced, which can not only process structured and unstructured data, but also process multiple data types such as images, audio, and video. By combining a large language model with a multimodal deep learning model, a unified semantic understanding and information extraction of different types of data can be performed. This breaks through the limitation of related technologies that can only process a single data type, realizes the comprehensive utilization of multi-source and multimodal data, and provides a more comprehensive information foundation for the generation of target documents.
[0102] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0103] In an optional embodiment, the demand information is processed according to the template database information to obtain professional field information and target template information, including:
[0104] S21, obtaining user historical behavior data information;
[0105] User historical behavior data refers to the records of various activities performed by users on the template database within a certain time range. For example, the document templates that users browsed, the document templates that users used, and the document templates that users commented on or liked.
[0106] S22, performing semantic recognition processing on the demand information to obtain professional field information;
[0107] Semantic recognition of the demand information may include: performing word segmentation and part-of-speech tagging on the demand information, and determining whether the words obtained after word segmentation are identical to the professional field information in the professional field information set. If so, the word is directly determined to be the professional field information to which the document to be generated belongs. For example, if the demand information is "help me generate a review paper in the field of construction engineering", then after word segmentation, the word "construction engineering field" may be obtained. In this case, the professional field information to which the document to be generated belongs is directly determined to be "construction engineering field".
[0108] If no words match the domain information, the domain information to be generated is determined based on the word's meaning. For example, if the requirement is "help me generate a paper on the calculation method of power grid line failure risk indicators," then after word segmentation, the word "power grid line" can be obtained. Then, after understanding the meaning of "power grid line," it can be determined that the word belongs to the "power system field." Therefore, the domain information to be generated is determined to be the "power system field."
[0109] In an optional embodiment, semantic recognition processing is performed on the demand information to obtain professional field information, including:
[0110] S221, obtaining a professional field text word vector set; the professional field text word vector set includes a plurality of professional field text word vectors;
[0111] It should be noted that the above-mentioned professional field text word vector set is the professional field vocabulary in all technical fields, and each professional field vocabulary is a professional field text word vector.
[0112] S222, performing word segmentation and part-of-speech tagging on the demand information to obtain a demand word segmentation vector set;
[0113] It should be noted that the above-mentioned word segmentation and part-of-speech tagging can be processed using TF-IDF, and the specific embodiment of the present invention does not limit this.
[0114] S223, using the document generation similarity calculation model, calculates and processes the demand word segmentation vector set and the professional field text word vector set to obtain demand similarity information; the demand similarity information includes a plurality of demand similarity values;
[0115] Among them, the document generation similarity calculation model is:
[0116]
[0117] Where, XS is the demand similarity information, XS i,j is the similarity value between the i-th demand word segmentation vector in the demand word segmentation vector set and the j-th professional field text word vector in the professional field text word vector set, XQ i is the i-th demand segmentation vector in the demand segmentation vector set, ZY j is the jth professional field text word vector in the professional field text word vector set, N is the number of demand word vectors in the demand word vector set, M is the number of professional field text word vectors in the professional field text word vector set, δ1 is the first weight parameter, and |·| represents the modulus of the vector;
[0118] It should be noted that the first weight parameter may be set by a user or obtained based on historical data, and the specific embodiment of the present invention does not limit this.
[0119] It should be noted that by generating a similarity calculation model through documents, it is possible to measure the similarity between demand information and professional field information, thereby helping to understand the relationship between the two.
[0120] It should be noted that the value range of the first weight parameter is between [1, 5], which can make the similarity between the obtained demand information and professional field information more in line with business needs. For example, in some cases it is necessary to strengthen the similarity of certain word vectors, while in other cases it may be necessary to weaken them.
[0121] S224, calculating the magnitude of all demand similarity values in the demand similarity information to obtain a maximum demand similarity value; the maximum demand similarity value is the demand similarity value with the largest value in the demand similarity information;
[0122] S225, determining the professional field text word vector in the professional field text word vector set corresponding to the maximum required similarity value as the professional field information.
[0123] Further, the professional field text word vector in the professional field text word vector set corresponding to the maximum demand similarity value is determined as the professional field information, specifically, when obtaining the maximum demand similarity value XS a1,a2 After that, get XS a1,a2The subscript a2 of the professional field text word vector set is used as the professional field information.
[0124] S23, screening the professional field information based on the template database information to obtain an initial template set;
[0125] It should be noted that the above-mentioned screening process is to determine the professional field information to which the document to be generated belongs, use the professional field information to which the document to be generated belongs as the search term, search in the index of each document template in the template database information, and retrieve multiple templates that match the professional field information to which the document to be generated belongs as the initial template set. For example: if the professional field information to which the document to be generated belongs is "construction engineering field", then the document templates that include "construction engineering field" in the index are used as the initial template set. Alternatively, if the professional field information to which the document to be generated belongs is "power system field", then the document templates that include "power system field" in the index are used as the initial template set.
[0126] S24: Process the initial template set and the user's historical behavior data information to obtain target template information.
[0127] The initial template set and the user's historical behavior data information are processed to obtain the target template information, including: selecting the document template that the user has browsed the most times in the initial template set as the target template information, or selecting the document template that the user has used in the initial template set as the target template information, or selecting the document template that the user has commented on in the initial template set as the target template information, or selecting the document template that the user has liked in the initial template set as the target template information.
[0128] Furthermore, if multiple target template information matching the user's historical behavior data is screened out from the initial template set, any one of the target template information can be selected as the final target template information, or multiple target template information can be sent to the client for display, and the template finally selected by the user sent by the client can be received as the target template information.
[0129] Furthermore, template customization and selection are available. A variety of common document templates are built into the template database, covering various technical document formats. Users can flexibly select the appropriate template based on their specific needs, or customize their own templates to meet specific requirements. This allows for adaptability to various application scenarios, significantly improving user efficiency. Furthermore, the use of templates ensures standardized and consistent document formats, enhancing both professionalism and readability.
[0130] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0131] In an optional embodiment, the knowledge base information is searched and processed using the demand information and the professional field information to obtain text data information that matches the demand information, including:
[0132] S31, matching the professional field information with the knowledge base information to obtain the target knowledge base information;
[0133] The professional field information and the knowledge base information are matched to obtain the target knowledge base information, including, after obtaining the professional field information to which the document to be generated belongs, searching the indexes of multiple knowledge base information with the professional field information to which the document to be generated belongs, to obtain the knowledge base information having the same index as the professional field information to which the document to be generated belongs, as the target knowledge base information.
[0134] S32, using the demand information, searching and processing the target knowledge base information to obtain text data information that matches the demand information.
[0135] It should be noted that the above retrieval process utilizes hybrid retrieval technology, a strategy that combines multiple information retrieval methods and techniques to improve the accuracy and relevance of search results. This strategy incorporates the advantages of different retrieval models and algorithms to overcome the limitations of a single method and provide a more comprehensive and effective retrieval service.
[0136] Exemplarily, the demand information is used to search and process the target knowledge base information to obtain text data information that matches the demand information, including: using semantic retrieval to search in the target knowledge base information to obtain text data information that matches the demand information, using keyword retrieval to search in the target knowledge base information to obtain text data information that matches the demand information, using statistics-based retrieval to search in the target knowledge base information to obtain text data information that matches the demand information, and so on.
[0137] In the embodiment of the present application, knowledge base information and terminology information of different professional fields are pre-integrated for different professional field information. Combined with RAG technology, it is possible to call the professional knowledge of specific professional field information when retrieving text data information, ensuring the professionalism and authority of the document.
[0138] Furthermore, the target knowledge base information is retrieved and processed using the demand information. After obtaining the text data information that matches the demand information, the text data information is scored based on the relevance, the timestamp of the text data information, and the metadata information of the text data information, and the top N text data information with the highest scores are selected as the text data information that finally matches the demand information.
[0139] The relevance score is a score based on the relevance of the retrieved text data to the required information when searching the knowledge base. It measures the similarity between the retrieved text data and the required information. The higher the similarity between the retrieved text data and the required information, the higher the relevance score. The lower the similarity between the retrieved text data and the required information, the lower the relevance score.
[0140] The timestamp of a text data item refers to the time when the retrieved text data item was created or last updated. The later the timestamp of the text data item, the more time-sensitive the data is, and the higher the score is. The earlier the timestamp of the text data item, the less time-sensitive the data is, and the lower the score is.
[0141] Metadata information includes author, source, classification label, and abstract. This information provides additional context, helping to determine a document's relevance and authority. For example, if the text data is related to science and technology, then scientific papers indexed by SCI or SSCI will receive a higher score; articles published on personal websites or public accounts will receive a lower score.
[0142] Based on the relevance, timestamp of the text data information and metadata information of the text data information, after normalization processing, weighted calculation is performed to obtain the score of each text data information, and the text data information with the top N scores are selected as the text data information that finally matches the required information.
[0143] The retrieved text data information is re-scored, and factors such as relevance, timestamp, and metadata information are comprehensively considered to obtain optimized text data information to improve the timeliness and accuracy of the text data information.
[0144] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0145] In an optional embodiment, the target template information, the requirement information, and the text data information are processed to obtain the target document information, including:
[0146] S41, processing the target template information and the requirement information to obtain semantic hierarchical structure information;
[0147] It should be noted that the aforementioned semantic hierarchical structure information may refer to the semantic relationships that reflect the conceptual hierarchy and logical organization of the content of the target document information. Specifically, the aforementioned semantic hierarchical structure information may include the directory structure of the target document information. The directory hierarchy typically refers to a hierarchical structure such as chapters, sections, and subsections. In other words, the directory structure of the target document information is generated based on the target template information and the requirement information.
[0148] S42, processing the semantic hierarchical structure information and the text data information to obtain a target text data set;
[0149] S43, integrating the target text data set and the target template information to obtain target document information.
[0150] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0151] In an optional embodiment, the target template information and the requirement information are processed to obtain semantic hierarchical structure information, including:
[0152] S411, processing the target template information and the requirement information to obtain first prompt word information;
[0153] It should be noted that the above processing can be performed using tools or algorithms such as SpaCy, Word2Vec, FastText, or Stanza, and the embodiments of the present invention do not limit these tools or algorithms.
[0154] It should be noted that the first prompt word mentioned above is to restructure the target template information and demand information to make it more suitable as the input of the large model, thereby guiding the model to correctly understand the semantics and ultimately generate semantic hierarchical structure information.
[0155] S412, obtaining a semantic hierarchical structure training set;
[0156] It should be noted that the semantic hierarchy training set is a dataset used to train the model to parse the semantic hierarchical relationship of text. It usually contains the input text and its corresponding hierarchical structure label.
[0157] S413, using the semantic hierarchical structure training set, training the first document generation initial model information to obtain the first document generation optimization model information;
[0158] It should be noted that the initial model information for generating the first document is LSTM, which is not specifically limited in this embodiment of the present invention.
[0159] It should be noted that the above-mentioned specific training process can be set by the user or obtained based on historical data, and the embodiment of the present invention does not limit this.
[0160] In an optional embodiment, the semantic hierarchical structure training set is used to train the initial model information for generating the first document to obtain the optimized model information for generating the first document, including:
[0161] S4131, using the semantic hierarchical structure training set, training the first document generation initial model information to obtain first document generation training result information and first document generation training model information;
[0162] The above processing is to use the semantic hierarchical structure training set as the input of the first document to generate the initial model information, and to train the first document to generate the initial model information, and obtain the first document generation training result information, wherein the first document generation training model information is the model obtained after training with the semantic hierarchical structure training set.
[0163] S4132, using a loss function, calculating and processing the first document generation training result information to obtain a first document generation loss value;
[0164] Among them, the loss function is:
[0165]
[0166] Among them, YWD is the loss value generated by the first document, ZZ is the real result information generated by the first document corresponding to the training result information generated by the first document, CS is the training result information generated by the first document, and CS i1 Generate the training result value of the i1th sample in the training result information for the first document, ZZ i1 The true result value of the i1th sample in the true result information generated for the first document, N1 is the number of samples in the training result information generated for the first document, θ1 and θ2 are the first deviation coefficient and the second deviation coefficient respectively.
[0167] It should be noted that the first deviation coefficient and the second deviation coefficient may be set by the user or obtained based on historical data, and the embodiments of the present invention do not limit this.
[0168] It should be noted that the loss function is used to optimize the text generated by the model to make it closer to the real text, while maintaining stability and avoiding interference from outliers. It can also improve the quality of text generation and allow the model to focus more on key content rather than treating all samples equally.
[0169] It should be noted that the value range of the first deviation coefficient is between [0.01, 0.1], which is used for numerical balance in the model to avoid the loss value being too small and causing the gradient to disappear.
[0170] It should be noted that the value range of the second deviation coefficient is [0.001, 0.01], which helps to maintain the diversity and naturalness of the generated text. If the value of the second deviation coefficient is too large, it may cause the model to be oversimplified and ignore some important features in the generation process. If the value is too small, the model may generate more complex and unnecessary results, thereby increasing the risk of overfitting.
[0171] S4133, determining whether the first document generation loss value is less than a preset first document generation loss threshold, and obtaining a first determination result;
[0172] It should be noted that the preset first document generation loss threshold has a value range of [0.02, 0.1], which is not specifically limited in the embodiment of the present invention.
[0173] When the first judgment result is no, determining that the first document generation training model information is the first document generation initial model information, and reacquiring the semantic hierarchical structure training set, executing S4131;
[0174] What needs to be processed is that the above-mentioned re-acquiring the semantic hierarchical structure training set is to obtain the second semantic hierarchical structure training set and determine the semantic hierarchical structure training set as the semantic hierarchical structure training set. By updating the semantic hierarchical structure training set, more accurate first document generation optimization model information can be obtained.
[0175] When the first judgment result is yes, it is determined that the first document generation training model information is the first document generation optimization model information.
[0176] S414 , using the first document to generate optimization model information, processing the first prompt word information, target template information and requirement information to obtain semantic hierarchical structure information.
[0177] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0178] In an optional embodiment, the semantic hierarchical structure information and the text data information are processed to obtain a target text data set, including:
[0179] S421, processing the semantic hierarchical structure information and the text data information to obtain second prompt word information;
[0180] It should be noted that the above processing can be performed using BERT, RoBERTa, T5, E5, etc. Specifically, the embodiments of the present invention do not need to be limited. The above processing is used to parse semantic hierarchical information and construct high-quality prompt word information, thereby optimizing the input of document generation to improve the generation effect.
[0181] S422 : Generate optimization model information using the second document, process the second prompt word information, the semantic hierarchical structure information, and the text data information to obtain a target text data set.
[0182] It should be noted that the second document generation optimization model information is a trained and optimized Llama model used to generate a target text dataset.
[0183] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0184] In an optional embodiment, the target text dataset and the target template information are integrated to obtain target document information, including:
[0185] S431, processing the target text data set and the target template information to obtain third prompt word information;
[0186] It should be noted that the above processing can be performed using SpaCy, Template-Based Generation, etc., and the specific embodiment of the present invention does not limit it.
[0187] It should be noted that the third prompt word further optimizes the target text data to make it conform to the structure, format or style of the specific template. The third prompt word information includes format requirements, tone, paragraph structure, etc., which is used to guide the generation of the final document.
[0188] S432: Process the third prompt word information, the target text dataset, and the target template information to obtain target document information.
[0189] It should be noted that the above processing can be performed using GPT-4, T5, or BART, and the specific embodiments of the present invention do not limit this.
[0190] It should be noted that the target document information is the final formal document output for practical applications. The target document information has undergone multiple rounds of optimization to ensure that the quality, format, and logical structure meet the requirements.
[0191] It can be seen that the implementation of the document generation method described in the embodiment of the present invention can realize the automatic generation of documents, which is conducive to reducing labor costs and improving document writing efficiency and quality.
[0192] In an optional embodiment, the target template information, the requirement information, and the text data information are processed to obtain the target document information, including:
[0193] H1. Generate a semantic hierarchical structure based on target template information and requirement information.
[0194] The semantic hierarchy structure may refer to the semantic relationships that reflect the conceptual hierarchy and logical organization of the content of the target document information. Specifically, the semantic hierarchy structure may include the directory hierarchy structure of the target document information. The directory hierarchy structure generally refers to a hierarchical structure (semantic hierarchy) such as chapters, sections, and subsections. Specifically, the directory hierarchy structure of the target document is generated based on the target template information and the requirement information.
[0195] A first prompt word is generated based on the target template information and the requirement information, and the first prompt word is input into the large language model. The first prompt word is used to instruct the large language model to generate a semantic hierarchical structure based on the target template information and the requirement information, and receive the semantic hierarchical structure output by the large language model.
[0196] The Big Language Model is a natural language processing tool based on deep learning. After large-scale training, it has powerful text generation capabilities. It can understand complex contexts and generate coherent and meaningful text based on given prompts.
[0197] A requirement can be a textual description written in natural language. Furthermore, it can include a brief description of the domain or topic, for example, "Please help me generate a review paper on hardware fault detection." Besides the description of the domain or topic, the requirement can also specify other key information.
[0198] Generating a first prompt word based on the requirement information, the target template information, and the pre-set first prompt information includes: filling the requirement information into the requirement blank in the pre-set first prompt information, and filling the target template information into the template blank in the pre-set first prompt information, to obtain the first prompt word. The pre-set first prompt information includes: "Please generate a directory structure based on the following requirement information and target template information; the requirement information is as follows: [aaa], and the target template information is as follows: [bbb]", where aaa represents the requirement blank to be filled with the user-entered requirement information, and bbb represents the template blank to be filled with the selected target template information.
[0199] The first prompt word is input into the large language model, and the semantic hierarchical structure output by the large language model is received. The first prompt word is used to guide or instruct the large language model to generate a semantic hierarchical structure based on the requirement information and the target template information.
[0200] Furthermore, after receiving the semantic hierarchical structure output by the large language model, the semantic hierarchical structure is displayed, and in response to a user's modification operation on the semantic hierarchical structure, a modified semantic hierarchical structure is obtained.
[0201] Alternatively, after receiving the semantic hierarchy structure output by the large language model, the semantic hierarchy structure and modification information are input into the large language model, and the modified semantic hierarchy structure output by the large language model is received. The modification information may include adding a level, deleting a level, or modifying keywords in a level, etc.
[0202] H2. For each semantic level, select text data that matches the semantic level from the text data that matches the required information.
[0203] For each semantic level, text data information matching the semantic level is selected from the text data information matching the requirement information as the target text data information.
[0204] Specifically, for top-level directories (e.g., chapters), in order to select text data that matches the top-level directory, we extract paragraphs or sentences that summarize the core idea or main content of the chapter from the text data that matches the required information. Topic modeling techniques such as LDA (Latent Dirichlet Allocation) can be used to identify the topic distribution of each chapter and select the text fragment that best reflects the topic.
[0205] For sub-directories (e.g., sections), the text data for the sub-directory should be closely related to the specific concepts or discussion points described in the section title. Keyword extraction techniques or semantic similarity algorithms can be used to find the most relevant sentences or paragraphs to the section title.
[0206] For lower-level directories (e.g., subsections, project lists, etc.), this can be achieved through question-answering systems (QAsystems), information retrieval models, or rule-based text parsing.
[0207] In a possible implementation, for each semantic level, text data information matching the requirement information is input into a large language model, and text data information matching the semantic level output by the large language model is received.
[0208] H3, based on the text data information of semantic level matching, generates target text data information corresponding to the semantic level.
[0209] A second prompt word is generated based on the semantic hierarchical structure and text data that matches the demand information, and the second prompt word is input into the large language model. The second prompt word is used to instruct the large language model to generate target text data information corresponding to each semantic level based on the semantic hierarchical structure and text data that matches the demand information; and the target text data information corresponding to each semantic level output by the large language model is received.
[0210] The second prompt is a set of instructions or questions designed to guide the large language model in generating target text data corresponding to each semantic level. It contains a specific description of the desired output, enabling the model to generate the corresponding target text data based on the provided background information.
[0211] Based on the semantic hierarchical structure, text data information matching the demand information, and pre-set second prompt information, a second prompt word is generated, including: filling the semantic hierarchical structure into the semantic blanks in the pre-set second prompt information, and filling the text data information matching the demand information into the text data blanks in the pre-set second prompt information, to obtain the second prompt word. The pre-set second prompt information includes: "Please generate target text data information corresponding to each semantic level based on the following semantic hierarchical structure and text data information matching the demand information; the semantic hierarchical structure is as follows: [ccc], and the text data information matching the demand information is as follows: [ddd]", where ccc represents the semantic blanks in the semantic hierarchical structure that need to be filled, and ddd represents the text data blanks in the text data information matching the demand information that need to be filled.
[0212] The second prompt word is input into the large language model, and the semantic hierarchy structure output by the large language model is received. The second prompt word is used to guide or instruct the large language model to generate target text data information corresponding to each semantic hierarchy based on the semantic hierarchy structure and text data information matching the required information.
[0213] In one possible implementation, specific second prompt information is provided for each semantic structure in the semantic hierarchy to instruct the large language model on how to generate target text data corresponding to each semantic structure. For example, the second prompt information could be: "In the 'Experimental Methods' section, please describe in detail the experimental design, sample selection criteria, equipment, and materials used."
[0214] The carefully designed second prompt word is submitted to the large language model as the basis for generating text. The target text data corresponding to each semantic level generated according to the semantic hierarchy structure is received from the large language model.
[0215] Check whether the generated target text data meets the requirements of the required information, including accuracy, completeness, and consistency. If necessary, adjust the prompt words based on the review results and request the large language model to generate new target text data again until satisfactory results are achieved.
[0216] In one possible implementation, the second prompt word is also used to instruct the large language model to obtain annotation information of the target text data information corresponding to the semantic level when generating the target text data information corresponding to the semantic level. The annotation information includes source information of the text data information matching the semantic level and the reasoning process of the large language model to generate the target text data information corresponding to the semantic level.
[0217] In this embodiment of the present application, the second prompt word is used to guide or instruct the large language model to generate target text data information corresponding to each semantic level based on the semantic hierarchy structure and the text data information that matches the required information. It is also necessary to guide the large language model to determine the annotation information required for each semantic level. Furthermore, the second prompt word needs to clarify the specific content of the annotation information, such as source information, reasoning process, etc.
[0218] Furthermore, the large language model can be adjusted or configured so that, while generating target text data at each semantic level, it also records the source and reasoning process of this data. The large language model may need to be trained to understand and respond to a second prompt word to trigger the collection of annotation information.
[0219] When the large language model generates target text data at each semantic level based on the semantic hierarchy and text data matching the required information, it also determines the source of the data (for example, whether it is extracted from an existing knowledge base or generated based on the model's own knowledge). The logic and basis for the model's decision-making are recorded, which may be achieved by tracking state changes within the model, weight application, etc.
[0220] When a large language model generates target text data information corresponding to the semantic level, it simultaneously obtains annotation information at each semantic level, which can enhance the interpretability of the target document.
[0221] Using methods such as keyword matching and contextual understanding, the target text data corresponding to each semantic level is mapped to the corresponding position in the target template information according to its semantic level. Program logic is used to insert specific text content into the placeholders in the target template information. Any necessary formatting adjustments or edits are made to the generated target document to ensure that the document conforms to the expected standards and style guidelines.
[0222] Furthermore, if the position corresponding to the semantic level does not exist in the target template information, the target template information is adjusted, for example, the position corresponding to the semantic level is added to the target template information.
[0223] In one possible implementation, a third prompt word is generated using the target text data information and target template information corresponding to each semantic level, and the third prompt word is input into the large language model. The third prompt word is used to instruct the large language model to generate target document information based on the target text data information and target template information corresponding to each semantic level; and the target document information output by the large language model is received.
[0224] The target text data information, target template information and third prompt information corresponding to each semantic level are used to generate a third prompt word.
[0225] The third prompt is a specially designed input string or set of instructions that instructs the large language model on how to generate the desired document using the given target text data and following the target template. The third prompt should clearly express the requirements for each semantic level. The third prompt should also specify any specific language style or tone preferences, such as formal, informal, or academic.
[0226] After constructing the third prompt word, you can provide it as input to the large language model. Upon receiving the third prompt word, the large language model begins processing and attempting to understand the instructions. The large language model then generates target document information that meets the requirements based on its internal algorithms and training data, combined with the provided target text data and template. The generated target document information is then received from the large language model.
[0227] In one possible implementation, the third prompt word is also used to instruct the large language model to add annotation information of the target text data information corresponding to each semantic level to the set position of the target document information when generating the target document based on the target text data information and target template information corresponding to each semantic level.
[0228] In an embodiment of the present application, when the large language model generates target text data information at each semantic level, it simultaneously generates corresponding annotation information. The third prompt word is used to instruct the large language model to correctly map the annotation information corresponding to the semantic level to a preset position in the target template when generating the target document based on the target text data information corresponding to each semantic level and the target template information. Program logic or scripts are used to fill the template with the target text data information and its annotation information.
[0229] In the embodiments of this application, a content generation method based on semantic hierarchy is proposed. First, a semantic tree of the content is constructed, and the content of the technical document is expanded layer by layer according to the theme, sub-theme, and details. When generating content, the large language model generates it step by step according to the semantic hierarchy, ensuring a clear logical structure and distinct levels of the document. This improves the readability and professionalism of the document.
[0230] Furthermore, to enhance the credibility and verifiability of generated content, we introduced an interpretable large language model generation mechanism. When generating target text data at each semantic level, the corresponding information source, reasoning process, and references are generated and presented in the document as annotations or appendices. This ensures that the target document information not only contains conclusive content but also provides detailed reasoning and reference information, making it easier for users to verify and trace.
[0231] Example 2
[0232] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a document generation device disclosed in an embodiment of the present invention. Figure 2 The document generation device described is applied to a document generation optimization system, such as a local server or cloud server for document generation, etc., which is not limited in the embodiment of the present invention. Figure 2 As shown, the document generating device includes:
[0233] The acquisition module 201 is used to acquire the demand information and knowledge base information input by the user; the knowledge base information includes a plurality of knowledge base data information;
[0234] The first processing module 202 is used to process the demand information according to the template database information to obtain professional field information and target template information;
[0235] The second processing module 203 is used to retrieve and process the knowledge base information using the demand information and professional field information to obtain text data information that matches the demand information;
[0236] The third processing module 204 is used to process the target template information, the requirement information and the text data information to obtain the target document information.
[0237] It can be seen that the document generation device described in the embodiment of the present invention can realize the automatic generation of documents, which is beneficial to reducing labor costs and improving document writing efficiency and quality.
[0238] Example 3
[0239] See also Figure 3 , Figure 3 It is a structural diagram of an electronic device disclosed in an embodiment of the present invention.
[0240] like Figure 3 As shown, the device includes:
[0241] Processor 301;
[0242] A memory 302 coupled to the processor 301 and storing executable program code;
[0243] The processor 301 calls the executable program code stored in the memory 302 to execute part or all of the steps of the document generation method of the first embodiment.
[0244] It can be seen that the electronic device described in the embodiment of the present invention can realize the automatic generation of documents, which is beneficial to reducing labor costs and improving document writing efficiency and quality.
[0245] Example 4
[0246] An embodiment of the present invention discloses a storage medium on which a computer program is stored. When the program is executed by a processor, part or all of the steps of the document generation method of the first embodiment are implemented.
[0247] Example 5
[0248] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps in the document generation method described in the first embodiment.
[0249] The system embodiments described above are merely illustrative. Modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules. They may be located in one place or distributed across multiple network modules. Some or all of these modules may be selected based on actual needs to achieve the objectives of this embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0250] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by means of hardware. Based on this understanding, the above technical solution, in essence, or the portion that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, including a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0251] Finally, it should be noted that the document generation method and device disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, and are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A document generation method, characterized in that: The method comprises: S1, obtaining demand information and knowledge base information input by the user; the knowledge base information includes a plurality of knowledge base data information; S2, processing the demand information according to the template database information to obtain professional field information and target template information; S3, using the demand information and the professional field information, searching the knowledge base information to obtain text data information that matches the demand information; S4, processing the target template information, the requirement information and the text data information to obtain target document information.
2. The document generation method according to claim 1, wherein: The obtaining of knowledge base data information includes: S11, obtaining data information to be processed, data type information corresponding to the data information to be processed, and metadata information; S12, processing the data information to be processed and the data type information to obtain preprocessing model information corresponding to the data information to be processed; S13, using the preprocessing model information, processing the data information to be processed to obtain key data information; S14, integrating the data information to be processed, the metadata information and the key data information to obtain knowledge base data information.
3. The document generation method according to claim 1, wherein: The process of processing the demand information according to the template database information to obtain professional field information and target template information includes: S21, obtaining user historical behavior data information; S22, performing semantic recognition processing on the demand information to obtain professional field information; S23, screening the professional field information according to the template database information to obtain an initial template set; S24: Process the initial template set and the user historical behavior data information to obtain target template information.
4. The document generation method according to claim 3, wherein: The semantic recognition processing of the demand information to obtain professional field information includes: S221, obtaining a professional field text word vector set; the professional field text word vector set includes a plurality of professional field text word vectors; S222, performing word segmentation and part-of-speech tagging on the demand information to obtain a demand word segmentation vector set; S223, using a document generation similarity calculation model to calculate and process the demand word segmentation vector set and the professional field text word vector set to obtain demand similarity information; the demand similarity information includes a plurality of demand similarity values; Among them, the document generation similarity calculation model is: Where, XS is the demand similarity information, XS i,j is the similarity value between the i-th demand word segmentation vector in the demand word segmentation vector set and the j-th professional field text word vector in the professional field text word vector set, XQ i is the i-th demand segmentation vector in the demand segmentation vector set, ZY j is the jth professional field text word vector in the professional field text word vector set, N is the number of demand word vectors in the demand word vector set, M is the number of professional field text word vectors in the professional field text word vector set, δ1 is the first weight parameter, and |·| represents the modulus of the vector; S224, calculating the magnitude of all the demand similarity values in the demand similarity information to obtain a maximum demand similarity value; the maximum demand similarity value is the demand similarity value with the largest value in the demand similarity information; S225 , determining that the professional field text word vector in the professional field text word vector set corresponding to the maximum required similarity value is professional field information.
5. The document generation method according to claim 1, wherein: The processing of the target template information, the requirement information, and the text data information to obtain target document information includes: S41, processing the target template information and the requirement information to obtain semantic hierarchical structure information; S42, processing the semantic hierarchical structure information and the text data information to obtain a target text data set; S43: Integrate the target text dataset and the target template information to obtain target document information.
6. The document generation method according to claim 5, characterized in that: The processing of the target template information and the requirement information to obtain semantic hierarchical structure information includes: S411, processing the target template information and the requirement information to obtain first prompt word information; S412, obtaining a semantic hierarchical structure training set; S413, using the semantic hierarchical structure training set, training the first document generation initial model information to obtain the first document generation optimization model information; S414 : Generate optimization model information using the first document, process the first prompt word information, the target template information, and the demand information, and obtain semantic hierarchical structure information.
7. The document generation method according to claim 5, characterized in that: The processing of the semantic hierarchical structure information and the text data information to obtain a target text data set includes: S421, processing the semantic hierarchical structure information and the text data information to obtain second prompt word information; S422: Generate optimization model information using the second document, process the second prompt word information, the semantic hierarchical structure information, and the text data information to obtain a target text data set.
8. A document generation device, characterized in that: The device comprises: An acquisition module is used to acquire the demand information and knowledge base information input by the user; the knowledge base information includes a plurality of knowledge base data information; A first processing module is used to process the demand information according to the template database information to obtain professional field information and target template information; A second processing module is used to retrieve the knowledge base information using the demand information and the professional field information to obtain text data information matching the demand information; The third processing module is used to process the target template information, the requirement information and the text data information to obtain target document information.
9. An electronic device, characterized in that: The device comprises: processor; a memory coupled to the processor and storing executable program code; The processor calls the executable program code stored in the memory to execute the document generation method according to any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the document generation method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Text generation method and device and storage medium
CN110390086A
Image processing method for knowledge distillation based on feature pyramid and knowledge guidance
CN115631393A
Information retrieval method and device, electronic equipment and storage medium
CN118394916A
Unmanned aerial vehicle battery installation and management method and system of intelligent charging cabinet
CN119428327A
Document generation method and device, equipment and storage medium
CN119474363A
Cited By
Software process document generation method and electronic equipment
CN121455538A
Method for generating software process document and electronic device
CN121455538B
Manuscript generation method and device, equipment and storage medium
CN121960420A
