A document generation method, system and medium based on large language model
By analyzing document input, knowledge base query and interaction between large language models, detailed documents are generated, which solves the problem of insufficient detailed suggestions in the professional field and low document analysis efficiency, and achieves more efficient and accurate documents generate.
Patent Information
- Application Number
- CN202410079652.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-19
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-01-19
AI Technical Summary
When dealing with problems in highly professional and specialized fields, existing large language models are recommended to appear lengthy and general, lack deep professionalism, and it is difficult to provide sufficient detailed and specific professional insights; their efficiency and accuracy in document analysis are also Restricted and output is usually continuous text, making it difficult to generate standard documents.
By obtaining document input and parsing, extracting questions and knowledge points, conducting knowledge base query indexes, combining large language models for questioning and response processing, and finally generating detailed documents. The method includes feature extraction and text embedding, cosine similarity comparison, preset pending templates and scoring mechanisms to improve the accuracy and efficiency of information retrieval and document generation.
It realizes automatic processing of documents, improves the efficiency of information retrieval, can obtain information from different sources and conducts comprehensive analysis, generate more detailed and accurate documents, meet the needs of professional fields, and improves the efficiency of document generation.
Smart Images

Figure CN117951272B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and in particular to a document generation method, system and medium based on a large language model. Background Art
[0002] The Big Language Model is a method that uses deep learning technology to process natural language. It can be trained on large-scale text data to learn the statistical laws and semantic knowledge of language. The Big Language Model has a wide range of applications in document analysis, such as text summarization, information extraction, sentiment analysis, and question-answering systems.
[0003] The problems faced by existing large language model technologies are mainly reflected in three aspects. First, although these models can provide general information, when dealing with highly professional and specialized issues, their suggestions are often lengthy, general, lack substantive content, and their authenticity needs to be verified. They lack deep professionalism and are difficult to provide sufficiently detailed and specific professional insights to meet the needs of professional fields. Secondly, in terms of document analysis, existing large language models show room for improvement because they are usually presented in the form of conversations rather than effectively analyzing and synthesizing the information in the documents, which limits the efficiency and accuracy of these models when it is necessary to find and summarize large amounts of text information. Finally, the output of existing large language models is usually continuous text, which is still a certain distance away from generating standard documents and there is room for improvement. These problems affect the practical application of these models in highly professional and document processing fields. Summary of the invention
[0004] Embodiments of the present invention provide a document generation method, system and medium based on a large language model to improve document generation efficiency.
[0005] To achieve the above object, an embodiment of the present invention provides a document generation method based on a large language model, comprising:
[0006] Obtaining document input, parsing the document input, extracting a first question and a first knowledge, and obtaining first document data;
[0007] According to the first document data, a query index is performed in a knowledge base to obtain a number of information to be processed; wherein the knowledge base is an information resource base, and the knowledge base includes: historical documents and technical document knowledge;
[0008] According to the plurality of information to be processed, a question is asked to the large language model to obtain a first response;
[0009] A first document is generated according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0010] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0011] By obtaining document input and parsing it, automatic document processing is achieved, reducing the burden of manual document processing; by using the first document data to query and index in the knowledge base, information related to the document can be effectively screened out from a large amount of information, thereby improving the efficiency of information retrieval; by integrating the first document data, the information to be processed and the first response, unified processing of information obtained from different sources is achieved, which is conducive to comprehensive analysis and generation of new documents; through interaction with a large language model, questions can be asked about the information to be processed, thereby obtaining deeper and more complex responses, which is conducive to handling complex problems and providing more detailed information.
[0012] Optionally, the query index is performed in the knowledge base according to the first document data to obtain some information to be processed, specifically:
[0013] Performing feature extraction and text embedding on the first knowledge in the first document data to obtain a first vector;
[0014] A query index is performed in the knowledge base according to the first vector to obtain some information to be processed.
[0015] By implementing this option, document data can be represented as a vector with more semantic information through feature extraction and text embedding, which helps to improve the accuracy of queries and ensure that the information to be processed is more consistent with the content and context of the document.
[0016] Optionally, performing a query index in the knowledge base according to the first vector to obtain some information to be processed is specifically:
[0017] Compare the first vector with each piece of knowledge base information in the knowledge base, calculate the cosine value of the angle between the first vector and each piece of knowledge base information, and perform cosine similarity comparison to obtain a plurality of first scores;
[0018] The knowledge base information whose corresponding first score is greater than or equal to a preset first threshold is extracted to obtain some information to be processed.
[0019] By implementing this option, cosine similarity comparison allows for more sophisticated information filtering, ensuring that only knowledge base information that is relatively similar to the document data is extracted, helping to reduce false matches and improve the accuracy of information retrieval. By setting a preset threshold, personalized adjustment of the degree of matching can be achieved, and the threshold can be flexibly adjusted according to needs to balance the accuracy of the retrieval results.
[0020] Optionally, the step of asking a question to the large language model based on the plurality of information to be processed to obtain a first response is specifically:
[0021] According to the plurality of information to be processed and the first question in the first document data, a preset template to be processed is filled to obtain a first question template; wherein the template to be processed is a template framework for asking questions to a large language model;
[0022] A question is asked to the large language model according to the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
[0023] By implementing this option, the preset templates to be processed provide a structured method to generate questions, making the format of questions more standardized and easier to handle, helping to ensure consistency and explainability of questions.
[0024] Optionally, after asking the large language model a question and obtaining a first response, the method further includes:
[0025] Calculate a score of the first response according to the first response and the information of each knowledge base to obtain a second score;
[0026] updating the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response;
[0027] The updated first response is added into the knowledge base to update the knowledge base.
[0028] By implementing this option, the quality of the first response can be more accurately assessed by introducing the first evaluation criteria, which helps to filter out inaccurate or irrelevant information.
[0029] Optionally, after parsing the document input, extracting the first question and the first knowledge, and obtaining the first document data, the method further includes:
[0030] The knowledge base is updated according to the first document data.
[0031] Implementing this option enables real-time synchronization of the knowledge base by updating the knowledge base based on newly parsed document data, helping to ensure that the information in the knowledge base is always consistent with the latest document data.
[0032] Accordingly, an embodiment of the present invention further provides a document generation system based on a large language model, comprising: a parsing module, an indexing module, a questioning module and a writing module;
[0033] The parsing module is used to obtain document input, parse the document input, extract the first question and the first knowledge, and obtain the first document data;
[0034] The index module is used to query and index in the knowledge base according to the first document data to obtain a number of information to be processed; wherein the knowledge base is an information resource library, and the knowledge base includes: historical documents and technical document knowledge;
[0035] The questioning module is used to ask questions to the large language model based on the plurality of information to be processed to obtain a first response;
[0036] The document generation module is used to generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0037] Optionally, the index module further includes: a preprocessing unit and a query unit;
[0038] The preprocessing unit is used to perform feature extraction and text embedding on the first knowledge in the first document data to obtain a first vector;
[0039] The query unit is used to perform a query index in the knowledge base according to the first vector to obtain some information to be processed.
[0040] Optionally, the query unit further includes: a comparison subunit and an extraction subunit;
[0041] The comparison subunit is used to compare the first vector with each piece of knowledge base information in the knowledge base, calculate the cosine value of the angle between the first vector and each piece of knowledge base information, so as to perform cosine similarity comparison and obtain a plurality of first scores;
[0042] The extraction subunit is used to extract the knowledge base information whose corresponding first score is greater than or equal to a preset first threshold, and obtain some information to be processed.
[0043] Optionally, the questioning module further includes: a filling unit and a response unit;
[0044] The filling unit is used to fill the preset template to be processed according to the plurality of information to be processed and the first question in the first document data to obtain a first question template; wherein the template to be processed is a template framework for asking questions to the large language model;
[0045] The response unit is used to ask a question to the large language model according to the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
[0046] Optionally, the questioning module further includes: a scoring unit, a correction unit and an updating unit;
[0047] The scoring unit is used to calculate the score of the first response according to the first response and the information of each knowledge base to obtain a second score;
[0048] The correction unit is used to update the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response;
[0049] The updating unit is used to add the updated first response into the knowledge base to update the knowledge base.
[0050] Optionally, after the parsing module parses the document input, extracts the first question and the first knowledge, and obtains the first document data, the method further includes:
[0051] The knowledge base is updated according to the first document data.
[0052] Correspondingly, an embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned document generation methods based on a large language model. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the implementation mode will be briefly introduced below. Obviously, the drawings described below are only some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 is a flow chart of a document generation method based on a large language model provided by an embodiment of the present invention;
[0055] Figure 2 It is a specific structural diagram of a document generation system based on a large language model provided by an embodiment of the present invention;
[0056] Figure 3 is another specific structural diagram of a document generation system based on a large language model provided by an embodiment of the present invention;
[0057] Figure 4 It is a flowchart of specific implementation steps of a document generation method based on a large language model provided by an embodiment of the present invention;
[0058] Figure 5 It is a structural diagram of a document generation system based on a large language model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in 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 creative work are within the scope of protection of the present invention.
[0060] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.
[0061] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0062] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0063] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.
[0064] The embodiments of the present invention provide a document generation method, system and medium based on a large language model, and the application scenarios include but are not limited to: intelligent document generation: used for automatic document generation, generating corresponding documents using a large language model according to the input document content and related information, including querying the knowledge base and generating documents using the obtained information; applied to the management of the knowledge base, by parsing new document inputs and updating the knowledge base, so that the knowledge base can continuously learn and improve; used to build an automatic question-and-answer system, the user inputs questions, and generates corresponding answers using the knowledge base and language model; by performing feature extraction and text embedding on document data, and using cosine similarity comparison, it can be applied to text similarity matching scenarios to find knowledge base information related to the input document; by scoring the first response and updating it based on preset evaluation criteria, it can be used to build an automatic evaluation system to improve the quality of generated documents.
[0065] Embodiment 1:
[0066] See also Figure 1 , an embodiment of the present invention provides a document generation method based on a large language model, comprising:
[0067] S10. Obtain document input, parse the document input, extract the first question and the first knowledge, and obtain first document data.
[0068] In a specific implementation, after parsing the document input, extracting the first question and the first knowledge, and obtaining the first document data, it also includes: updating the knowledge base according to the first document data; the knowledge base is an information resource library, and the knowledge base includes: historical documents and technical document knowledge. By updating the knowledge base according to the newly parsed document data, real-time synchronization of the knowledge base can be achieved, which helps to ensure that the information in the knowledge base is always consistent with the latest document data.
[0069] S20. According to the first document data, query and index are performed in the knowledge base to obtain some information to be processed.
[0070] In a specific implementation, the query indexing is performed in the knowledge base according to the first document data to obtain a number of information to be processed, specifically: feature extraction and text embedding are performed on the first knowledge in the first document data to obtain a first vector; query indexing is performed in the knowledge base according to the first vector to obtain a number of information to be processed. Through feature extraction and text embedding, the document data can be represented as a vector with more semantic information, which helps to improve the accuracy of the query and ensure that the obtained information to be processed is more consistent with the content and context of the document.
[0071] In a specific implementation, the query index is performed in the knowledge base according to the first vector to obtain a number of information to be processed, specifically: the first vector is compared with each knowledge base information in the knowledge base, and the cosine value of the angle between the first vector and each knowledge base information is calculated to perform a cosine similarity comparison to obtain a number of first scores; the knowledge base information whose corresponding first score is greater than or equal to a preset first threshold is extracted to obtain a number of information to be processed. Cosine similarity comparison allows for more refined information filtering, ensuring that only knowledge base information that is relatively similar to the document data is extracted, which helps to reduce mismatches and improve the accuracy of information retrieval; by setting a preset threshold, personalized adjustment of the degree of matching can be achieved, and the threshold can be flexibly adjusted according to needs to balance the accuracy of the retrieval results.
[0072] S30. Ask a question to the large language model based on the plurality of information to be processed to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
[0073] In a specific implementation, the step of asking a question to the large language model based on the plurality of information to be processed and obtaining a first response is as follows: filling a preset template to be processed based on the plurality of information to be processed and the first question in the first document data to obtain a first question template; wherein the template to be processed is a template framework for asking a question to the large language model; asking a question to the large language model based on the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template. The preset template to be processed provides a structured method for generating questions, making the form of the questions more standardized and easier to handle, and helping to ensure the consistency and interpretability of the questions.
[0074] In a specific implementation, after the large language model is asked a question and a first response is obtained, the method further includes: calculating a score of the first response according to the first response and the information of each knowledge base to obtain a second score; updating the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response; and adding the updated first response to the knowledge base to update the knowledge base. By introducing the first evaluation criterion, the quality of the first response can be more accurately evaluated, which helps to filter out inaccurate or irrelevant information.
[0075] S40. Generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0076] A document generation method based on a large language model provided by an embodiment of the present invention obtains information to be processed by querying and indexing in a knowledge base, and can filter out relevant content from a large amount of information, thereby improving the accuracy and efficiency of document generation; obtains a first vector by performing feature extraction and text embedding on first document data, which can better represent the semantic information of the document and help improve the accuracy and relevance of the query; calculates the cosine value of the angle between the first vector and the information in the knowledge base to perform cosine similarity comparison, which can measure the similarity between them and effectively filter out relevant information, thereby further improving the quality of the generated document; The information and the first document data are filled in to generate a question template, which helps to ask questions to the large language model more accurately, so as to obtain more targeted responses; the introduction of a second scoring mechanism and a knowledge base update mechanism based on the scoring can enable continuous optimization and learning during operation; by updating the knowledge base based on the first document data after document input parsing, new information can be reflected to the knowledge base in a timely manner to maintain the timeliness and integrity of the knowledge base; by parsing the document input and performing query indexing in the knowledge base, combined with the questioning and generation capabilities of the large language model, intelligent document generation is achieved, which can make full use of the information in the knowledge base and the response capabilities of the large language model, make document generation more comprehensive and accurate, and improve the efficiency of document generation.
[0077] See also Figure 4 A specific implementation step of a document generation method based on a large language model provided by an embodiment of the present invention can be used to generate a PRS document and an SRS document, including:
[0078] S110, storing the first document data parsed from the PRS document or the SRS document into a knowledge base for use in URS generation and storage data;
[0079] S120, embedding the first document data, converting the first document data into a vector form, obtaining a first vector; embedding each document information in the knowledge base into text, obtaining a plurality of knowledge base information; comparing the first vector with the plurality of knowledge base information by cosine similarity comparison, obtaining a plurality of comparison results; the size interval of the comparison result is a closed interval from zero to one; if the comparison result is less than a set threshold, ignoring the knowledge base information in the knowledge base; otherwise, adding the knowledge base information to the list;
[0080] S130. After sorting the data in the list, select the first N most relevant knowledge base information as background knowledge according to a preset first parameter; combine the first document data and the template to be processed to obtain a question and answer template; input the question and answer template into the large language model to obtain a first response; calculate the score of the first response according to the first response and the knowledge base information to obtain a second score; update the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, and obtain an updated first response; update the knowledge base according to the updated first response; generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0081] A specific implementation step of a document generation method based on a large language model provided by an embodiment of the present invention utilizes a large language model to automatically generate product requirement documents and software requirement documents by parsing PRS documents and SRS documents, thereby reducing the workload of manual document writing; it can not only be used to generate product requirement documents and software requirement documents, but also can generate other types of documents according to actual needs, and has certain versatility and flexibility.
[0082] Embodiment 2:
[0083] See also Figure 5 , an embodiment of the present invention provides a document generation system based on a large language model, comprising: a parsing module 1, an indexing module 2, a questioning module 3 and a writing module 4;
[0084] The parsing module 1 is used to obtain document input, parse the document input, extract the first question and the first knowledge, and obtain the first document data.
[0085] In a specific implementation, after the parsing module 1 parses the document input, extracts the first question and the first knowledge, and obtains the first document data, it also includes: updating the knowledge base according to the first document data; the knowledge base is an information resource library, and the knowledge base includes: historical documents and technical document knowledge.
[0086] The index module 2 is used to perform query indexing in a knowledge base according to the first document data to obtain a number of information to be processed.
[0087] In a specific implementation, the index module also includes: a preprocessing unit 5 and a query unit 6; wherein the preprocessing unit 5 is used to perform feature extraction and text embedding on the first knowledge in the first document data to obtain a first vector; the query unit 6 is used to perform query indexing in the knowledge base according to the first vector to obtain some information to be processed.
[0088] In a specific implementation, the query unit 6 also includes: a comparison subunit 7 and an extraction subunit 8; wherein the comparison subunit 7 is used to compare the first vector with each knowledge base information in the knowledge base, calculate the cosine value of the angle between the first vector and each knowledge base information, so as to perform a cosine similarity comparison to obtain a number of first scores; the extraction subunit 8 is used to extract the knowledge base information whose corresponding first score is greater than or equal to a preset first threshold value to obtain a number of information to be processed.
[0089] The questioning module 3 is used to ask questions to the large language model according to the plurality of information to be processed, and obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
[0090] In a specific implementation, the questioning module 3 also includes: a filling unit 9 and a response unit 10; wherein the filling unit 9 is used to fill a preset template to be processed according to the plurality of information to be processed and the first question in the first document data to obtain a first question template; wherein the template to be processed is a template framework for asking questions to a large language model; the response unit 10 is used to ask questions to the large language model according to the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
[0091] In a specific implementation, the questioning module 3 also includes: a scoring unit 11, a correction unit 12 and an updating unit 13; wherein the scoring unit 11 is used to calculate the score of the first response according to the first response and the knowledge base information to obtain a second score; the correction unit 12 is used to update the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response; the updating unit 13 is used to add the updated first response into the knowledge base to update the knowledge base.
[0092] The documenting module 4 is used to generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0093] Please refer to Figure 2 FIG. Figure 2 , which is a specific structural diagram of a document generation system based on a large language model provided by an embodiment of the present invention. As a detailed description of the above-mentioned document generation system based on a large language model, it includes: a document parsing module 110, a knowledge base 120, a data processing module 130, a knowledge search module 140, a model output module 150, an engineer feedback module 160, and a document generation module 170;
[0094] Among them, the document parsing module 110 is used to parse a word file or a PRS file based on a web page upload, extract a first question and first knowledge, and obtain first document data; update the knowledge base 120 according to the first document data corresponding to the PRS file;
[0095] The knowledge base 120 is an information resource library, including historical documents and technical document knowledge;
[0096] The data processing module 130 is used to perform feature extraction and text embedding on the first document data to perform word segmentation, stop word removal, stemming, punctuation removal, entity recognition, and vectorization to obtain a first vector. In text processing, stop words refer to those words that frequently appear in the text but do not carry actual meanings, such as "of", "will", and the last three words. Excluding these words can reduce the noise level of the text; punctuation marks, such as full stops, commas, and exclamation marks, are removed in text processing because they have no clear semantics in text analysis; entity recognition is a technology used to identify named entities in the text, and these entities can include personal names, place names, dates, and organization names;
[0097] The knowledge search module 140 is used to perform text embedding on each document information in the knowledge base 120 to obtain several knowledge base 120 information; calculate the cosine value of the angle between the first vector and each knowledge base 120 information in the knowledge base 120 to perform cosine similarity comparison to obtain several first scores; extract the knowledge base 120 information whose corresponding first score is greater than or equal to a preset first threshold to obtain several pieces of information to be processed; among them, the knowledge base 120 is an information resource library, and the knowledge base 120 includes: historical documents and technical document knowledge;
[0098] The model output module 150 is used to fill a preset template to be processed according to the several pieces of information to be processed and the first question in the first document data to obtain a first question template; where the template to be processed is a template framework for asking questions to a large language model; ask questions to the large language model according to the first question template to obtain a first response;
[0099] The engineer feedback module 160 is used to calculate the score of the first response according to the first response and the information of each knowledge base 12 to obtain a second score; update the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response; and update the knowledge base 120 according to the updated first response;
[0100] The document generation module 170 is used to generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document.
[0101] See also Figure 3 , an embodiment of the present invention provides another specific structural diagram of a document generation system based on a large language model, including: a CPU, a GPU, a Main Memory, a Cache, and a Device Memory;
[0102] Among them, the CPU and GPU are connected through PCI Express; the CPU interacts with the Main Memory through the Cache; the GPU interacts with the Device Memory through another Cache; and the other specific structure is used to implement a document generation method based on a large language model as described in any of the above items.
[0103] For more detailed steps and working principles of this embodiment, please refer to, but not limited to, the relevant records of Embodiment 1.
[0104] A document generation system based on a large language model provided by an embodiment of the present invention obtains information to be processed by querying and indexing in a knowledge base, and can filter out relevant content from a large amount of information, thereby improving the accuracy and efficiency of document generation; obtains a first vector by performing feature extraction and text embedding on first document data, which can better represent the semantic information of the document and help improve the accuracy and relevance of the query; calculates the cosine value of the angle between the first vector and the information in the knowledge base to perform cosine similarity comparison, which can measure the similarity between them and effectively filter out relevant information, thereby further improving the quality of the generated document; The information and the first document data are filled in to generate a question template, which helps to ask questions to the large language model more accurately, so as to obtain more targeted responses; the introduction of a second scoring mechanism and a knowledge base update mechanism based on the scoring can enable continuous optimization and learning during operation; by updating the knowledge base based on the first document data after document input parsing, new information can be reflected to the knowledge base in a timely manner to maintain the timeliness and integrity of the knowledge base; by parsing the document input and performing query indexing in the knowledge base, combined with the questioning and generation capabilities of the large language model, intelligent document generation is achieved, which can make full use of the information in the knowledge base and the response capabilities of the large language model, make document generation more comprehensive and accurate, and improve the efficiency of document generation.
[0105] Embodiment three:
[0106] A computer-readable storage medium, the computer-readable storage medium comprising a stored computer program; wherein, when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned document generation methods based on a large language model.
[0107] A computer-readable storage medium provided by an embodiment of the present invention can obtain information to be processed by querying and indexing in a knowledge base, and can filter out relevant content from a large amount of information, thereby improving the accuracy and efficiency of document generation; by performing feature extraction and text embedding on first document data to obtain a first vector, it can better represent the semantic information of the document, which helps to improve the accuracy and relevance of the query; by calculating the cosine value of the angle between the first vector and the information in the knowledge base to perform cosine similarity comparison, it can measure the similarity between them, effectively filter out relevant information, thereby further improving the quality of generated documents; by The first document data is filled in to generate a question template, which helps to ask questions to the large language model more accurately, so as to obtain more targeted responses; the introduction of a second scoring mechanism and a knowledge base update mechanism based on the scoring can enable continuous optimization and learning during operation; by updating the knowledge base based on the first document data after document input parsing, new information can be reflected to the knowledge base in a timely manner to maintain the timeliness and integrity of the knowledge base; by parsing the document input and performing query indexing in the knowledge base, combined with the questioning and generation capabilities of the large language model, intelligent document generation is achieved, which can make full use of the information in the knowledge base and the response capabilities of the large language model, make document generation more comprehensive and accurate, and improve the efficiency of document generation.
[0108] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A document generation method based on a large language model, characterized in that: include: Obtaining document input, parsing the document input, extracting a first question and a first knowledge, and obtaining first document data; According to the first document data, a query index is performed in a knowledge base to obtain a number of information to be processed; wherein the knowledge base is an information resource base, and the knowledge base includes: historical documents and technical document knowledge; According to the plurality of information to be processed, a question is asked to the large language model to obtain a first response; Generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document; According to the first document data, a query index is performed in the knowledge base to obtain some information to be processed, specifically: Performing feature extraction and text embedding on the first knowledge in the first document data to obtain a first vector; A query index is performed in the knowledge base according to the first vector to obtain some information to be processed.
2. A document generation method based on a large language model as claimed in claim 1, characterized in that: The query index is performed in the knowledge base according to the first vector to obtain some information to be processed, specifically: Compare the first vector with each piece of knowledge base information in the knowledge base, calculate the cosine value of the angle between the first vector and each piece of knowledge base information, and perform cosine similarity comparison to obtain a plurality of first scores; The knowledge base information whose corresponding first score is greater than or equal to a preset first threshold is extracted to obtain some information to be processed.
3. The document generation method based on a large language model as claimed in claim 1, characterized in that: The step of asking a question to the large language model based on the plurality of information to be processed to obtain a first response is as follows: According to the plurality of information to be processed and the first question in the first document data, a preset template to be processed is filled to obtain a first question template; wherein the template to be processed is a template framework for asking questions to a large language model; A question is asked to the large language model according to the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
4. The document generation method based on a large language model as claimed in claim 2, characterized in that: After asking the large language model a question and obtaining a first response, the method further includes: Calculate a score of the first response according to the first response and the information of each knowledge base to obtain a second score; updating the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response; The updated first response is added into the knowledge base to update the knowledge base.
5. The document generation method based on a large language model as claimed in claim 1, characterized in that: After parsing the document input, extracting the first question and the first knowledge, and obtaining the first document data, the method further includes: The knowledge base is updated according to the first document data.
6. A document generation system based on a large language model, characterized in that: include: Parsing module, indexing module, questioning module and writing module; The parsing module is used to obtain document input, parse the document input, extract the first question and the first knowledge, and obtain the first document data; The index module is used to query and index in the knowledge base according to the first document data to obtain a number of information to be processed; wherein the knowledge base is an information resource library, and the knowledge base includes: historical documents and technical document knowledge; The questioning module is used to ask questions to the large language model based on the plurality of information to be processed to obtain a first response; The documenting module is used to generate a first document according to the first document data, the plurality of information to be processed and the first response; wherein the first document includes: a product requirement document and a software requirement document; The index module further includes: a preprocessing unit and a query unit; The preprocessing unit is used to perform feature extraction and text embedding on the first knowledge in the first document data to obtain a first vector; The query unit is used to perform a query index in the knowledge base according to the first vector to obtain some information to be processed.
7. A document generation system based on a large language model as claimed in claim 6, characterized in that: The query unit further includes: a comparison subunit and an extraction subunit; The comparison subunit is used to compare the first vector with each piece of knowledge base information in the knowledge base, calculate the cosine value of the angle between the first vector and each piece of knowledge base information, so as to perform cosine similarity comparison and obtain a plurality of first scores; The extraction subunit is used to extract the knowledge base information whose corresponding first score is greater than or equal to a preset first threshold, and obtain some information to be processed.
8. A document generation system based on a large language model as claimed in claim 6, characterized in that: The questioning module further includes: a filling unit and a response unit; The filling unit is used to fill the preset template to be processed according to the plurality of information to be processed and the first question in the first document data to obtain a first question template; wherein the template to be processed is a template framework for asking questions to the large language model; The response unit is used to ask a question to the large language model according to the first question template to obtain a first response; wherein the first response is an answer output by the large language model in response to the first question template.
9. A document generation system based on a large language model as claimed in claim 7, characterized in that: The questioning module further includes: a scoring unit, a correction unit and an updating unit; The scoring unit is used to calculate the score of the first response according to the first response and the information of each knowledge base to obtain a second score; The correction unit is used to update the first response according to the second score until the second score corresponding to the first response is greater than or equal to a preset second threshold, thereby obtaining an updated first response; The updating unit is used to add the updated first response into the knowledge base to update the knowledge base.
10. A document generation system based on a large language model as claimed in claim 6, characterized in that: After the parsing module parses the document input, extracts the first question and the first knowledge, and obtains the first document data, the method further includes: The knowledge base is updated according to the first document data.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program; wherein, when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute a document generation method based on a large language model as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Conversation generation method and device
CN116860930A
Question response method and device based on large language model
CN117235226A
Question and answer pair extraction method and device, electronic equipment and storage medium
CN117407502A
