Large language model system for document question and answer, generation and version comparison

By designing a large language model system for document question and answer, generation and version comparison, the problems of inefficient document generation and version comparison and high manual operation error rate in the existing technology are solved, and automated document generation and high precision version comparison are realized. Significantly improve work efficiency.

CN119415652APending Publication Date: 2025-02-11JIANGSU APON MEDICAL TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411481644.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The prior art has problems of inefficiency and high manual operation error rates in document generation and version comparison, especially when processing multiple documents, it is difficult to accurately extract the difference information and generate a comparison table.

Method used

A large language model system was designed, including document question and answer module, document generation module and document comparison module. Through natural language processing and deep learning technologies, the system can automatically generate template-compliant documents and identify and display differences between different versions of the document through high-precision semantic comparison algorithms.

Benefits of technology

Automatically generate template-compliant documents, significantly reducing errors in manual operations, and improving work efficiency through precise version comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005097552700000021
    Figure BDA0005097552700000021
  • Figure BDA0005097552700000031
    Figure BDA0005097552700000031
  • Figure BDA0005097552700000061
    Figure BDA0005097552700000061
Patent Text Reader

Abstract

The invention discloses a large language model system for document question and answer and generation and version comparison, which comprises a document question and answer module, a document generation module and a document comparison module which are connected in sequence. And the document question and answer module is used for performing content retrieval according to questions proposed by the user for the document after the user uploads the document, and providing direct answers or general answers. In this way, for a long document uploaded by a user, expected content can be quickly found, and corresponding content is provided for the page for checking. And the document generation module is used for calling a fixed template to automatically generate a document according with a specific structure according to user requirements. And the document comparison module is used for comparing different versions of the same document, accurately extracting a modified part, performing highlight display and displaying a comparison table through a chart. The method has the advantages that the document conforming to the template is automatically generated, the differences between different versions are accurately compared, errors in manual operation are reduced, and the working efficiency is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of natural language processing and machine learning, and in particular to a large language model system for document question answering, generation and version comparison. Background Art

[0002] With the growing demand for digital office and information processing, the automatic generation, version management and difference comparison of documents have become tasks that many companies need to complete. At present, most companies rely on fixed templates in the process of writing these documents, and manually fill and edit them step by step. However, this method is not only time-consuming, but also inefficient in extracting difference information and manually generating comparison tables when processing multiple documents, and it is easy to ignore subtle changes. Now, there is a Chinese invention patent document with patent number 20241007965.2, named a document generation method, system and medium based on a large language model, which discloses a document generation method, system and medium based on a large language model, including: 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, querying and indexing in a knowledge base 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; according to the several information to be processed, asking questions to the large language model to obtain a first response; according to the first document data, the several information to be processed and the first response, generating a first document to provide document generation efficiency. Based on the above public content, it can be seen that the document is first obtained, and then the query index and document generation are performed, but the generated document is not accurately compared to see whether there are differences between versions, which increases the error rate in manual operations and reduces work efficiency. Summary of the invention

[0003] In view of the above problems, the purpose of the present invention is to provide a large language model system for document question and answer, generation and version comparison, which can automatically generate documents that conform to templates and accurately compare the differences between different versions, so as to reduce errors in manual operations and significantly improve work efficiency.

[0004] To achieve the above-mentioned purpose, the present invention provides a large language model system for document question and answer, generation and version comparison, which includes a document question and answer module, a document generation module and a document comparison module connected in sequence. The document question and answer module performs content retrieval based on the questions raised by the user about the document after the user uploads the document, and provides direct answers or summary answers. In this way, for long documents uploaded by users, the expected content can be found quickly, and the corresponding content can be provided to the page for verification. The document generation module automatically generates documents that conform to a specific structure by calling a fixed template according to user needs. The document comparison module compares different versions of the same document, accurately extracts the changed parts, highlights them and displays the comparison table through charts.

[0005] In some implementations, the document of a specific structure may be an instruction manual, a risk document, or a document with a fixed template.

[0006] In some implementations, the document question and answer module is implemented as follows:

[0007] (1) Preprocess the file first

[0008] Obtain files from the user end and extract the contents in the files, and perform cleaning, word segmentation, and formatting operations on them. The above-mentioned file format obtained by the user end is text or PDF or scanned PDF or image.

[0009] (2) After completing the file preprocessing, enter the core question-and-answer session

[0010] First, the files uploaded by users are deeply analyzed through natural language processing technology to generate the semantic structure of the document. The analysis of the above files ensures that the content of the document can be represented in a structured form to facilitate subsequent question-answer matching. In particular, by constructing a vector representation of the document, each sentence or paragraph is mapped to a high-dimensional space, and each word is represented as a vector. This process captures the semantic and grammatical relationship between words, so that words with similar semantics or grammar are close in the vector space. The above process is completed using the nomic-embed-text model, and its core formula is:

[0011]

[0012] Among them, V d represents the document vector representation, T d Represents the text content of the document, E(t i ) represents the embedding vector of the i-th word, and f represents the generating function of document embedding;

[0013] The document structure represented by the vectorization above is combined with the model for contextual association analysis. When the user asks a question, the question is vectorized in the same way. Next, the most relevant document fragments are identified by calculating the similarity between the document content and the question, using cosine similarity as the measurement standard:

[0014]

[0015] Where: θ represents the angle between the two vectors, V d , V q Represent document vector and question vector respectively;

[0016] The cosine value of the angle between the document and question vector is calculated through the above core formula. The smaller the angle, the closer the semantics, and the more accurately the corresponding document location can be found.

[0017] Secondly, when the corresponding document location is found, the relevant document fragment is obtained, and the response is generated by matching the content location and combining the document structure information. While generating the answer, the specific location of the answer in the original document is returned to facilitate user positioning.

[0018] In some implementations, the above-mentioned question-and-answer session also supports question-and-answer processing for multiple documents. For multiple documents, each document will be pre-processed and vectorized, and then the similarity results of all documents will be combined to select the most relevant document fragment for answering.

[0019] In the case of multi-document question answering, the following formula is used for similarity aggregation:

[0020] S=max(cos(θ1),cos(θ2),cos(θ3)…cos(θ n ))

[0021] Where S represents the comprehensive similarity, cos(θ n ) represents the similarity of the nth document.

[0022] In some implementations, when the file obtained by the user terminal is in the form of an image or a scanned PDF, optical character recognition (OCR) technology is used to extract the text content therein, ensuring that all file formats can be uniformly processed and converted into text data for analysis.

[0023] In some embodiments, the document generation module completes the entire process from type identification to document generation through the collaboration of multiple models. The above-mentioned multiple models include a file type identification model and a file content filling model. The file type identification model identifies the type of document to be generated from user requirements, and then the fine-tuned large language model is used for the file content filling model. Each model implements its own functions based on clear algorithms and deep learning technologies to ensure that the generated documents meet user requirements and maintain high quality.

[0024] (1) File type recognition model

[0025] The core task of the file type recognition model is to determine the type of document that the user needs to generate based on the requirements put forward by the user. The user needs to include the keywords of the document type in the requirements, such as "instructions", "risk analysis report", and "technical requirements document". The file type recognition model then uses natural language processing technology to perform semantic analysis on the requirements input by the user, extract key terms and determine the corresponding document type. Among them, the file type recognition model automatically identifies the document type information implicit in the user's requirements.

[0026] The main process of the file type identification model includes receiving the requirements proposed by the user. The requirement description should contain keywords about the required document type, processing the requirement description, and performing preprocessing operations such as text cleaning, word segmentation, and part-of-speech tagging. Further semantic analysis is performed on the preprocessed requirement description to understand the semantic content in the requirement description and extract key words related to the document type.

[0027] In the file type identification model step, Word2Vec and TF-IDF technologies are used to construct a semantic vector representation of the requirement description, and then the classification model trained by the machine learning algorithm SVM support vector machine is used to analyze the document category corresponding to the requirement. Among them, Word2Vec converts text into vectors; TF-IDF calculates the importance score of each word in the requirement description:

[0028] w i =TF(w i ,D)×IDF(w i )

[0029] where w i is the importance score of the i-th word, TF(w i ,D) represents word w i The word frequency in document D; IDF(w i ) represents the inverse document frequency of the word;

[0030] The above algorithm SVM support vector machine training is to extract features and combine these features into a feature vector. Then the training data set is used to fit the selected model, and SVM minimizes the empirical error and maximizes the geometric interval. Based on the extracted keywords, the file type recognition model determines the document type corresponding to the demand description. Finally, after the above judgment process, the file type recognition model can accurately identify the required document type from the user's demand description.

[0031] (2) File content filling model

[0032] The document content filling model is obtained by fine-tuning the model combined with the document template provided by the user, wherein the content of the document template includes the basic structure of the document and the content area to be filled, and then the document content is automatically generated according to the document template as a prompt word. The above document model automatically fills different types of documents through natural language generation technology to ensure that the generated content is logically coherent and meets expectations.

[0033] The document template input and processing described above firstly receives the corresponding document template identified in the previous step, which contains the overall structure of the document and the parts to be filled in. Then the document template is parsed by the system into a set of predefined placeholders to identify the content area to be generated in the document.

[0034] The formula for parsing the above document template is:

[0035] T={P1,P2,…,P n}

[0036] Among them, T represents the template, P i It is the i-th part in the template that needs to be filled, that is, the content of different chapters; each P i Contains specific prompt words or descriptions, which will be used to guide the model to generate corresponding content. The above prompt word generation is in the fine-tuned large language model. The core of generating document content lies in constructing appropriate prompt words to guide the model to generate text content that meets the requirements. Each template part P i It is processed into a prompt word, which contains the context information of the document and the specific content that needs to be generated.

[0037] The formula for generating prompt words is as follows:

[0038] prompt i =f(P i ,C i-1 )

[0039] Among them, prompt i is the prompt word for generating content, P i is the i-th part in the template, C i-1represents the content generated in the previous part, and f is a function used to convert template information into prompt words. Through recursive calls in the generation process, the prompt words of each part will contain context information to ensure the logical coherence of the generated content.

[0040] The document content generation is to generate the document content based on the prompt words through a fine-tuned content model. The content is generated according to the prompt words. The model generates corresponding paragraphs, titles or table contents based on the input prompt words. The logical order of the generated content is constructed through the prompt words to ensure that each part of the content is closely related to the context of the document.

[0041] The acquisition of the content large model is to ensure that the generated document content meets user needs, and fine-tune when using a large language model. The above fine-tuning process uses a large amount of document data of a specific type for training to ensure that the model can generate high-quality content according to the structure of the document template.

[0042] The loss function used in the fine-tuning process is the cross-entropy loss, and the formula is as follows:

[0043]

[0044] Among them, y i is the correct document content, p(y i |x i ) is the model’s i Through fine-tuning, the model is able to better understand the structure of the document template and generate corresponding content.

[0045] The generated document is generated by generating the content of all template parts, combining the generated content with the template structure to form a final complete document; the generated document can be exported to different file formats such as PDF format or Word format to meet user needs.

[0046] In some embodiments, the document comparison module is to accurately extract the title, paragraph, picture, table and other information of the document according to the characteristics of different structures in the document by introducing a regularization method, and to identify and separate text blocks, image boundaries and table structures through pattern matching and machine learning algorithms. The main process of the document comparison module includes a document version import phase, allowing users to upload multiple versions of documents, and automatic parsing of multiple versions of documents. During the parsing process, the document is first standardized, including format conversion, noise removal and structured data extraction. Through regularization operations, all versions of the document are uniformly converted into a consistent internal representation to ensure accurate comparison between documents of different formats. In the difference detection phase, a text similarity algorithm based on edit distance is used to compare the same parts and detect changes between different versions. In particular, the Levenshtein distance is used to calculate the minimum number of edit operations between two text fragments. The algorithm measures the difference between two text sequences S1 and S2 by inserting, deleting or replacing characters in them, and the calculation formula is:

[0047] d(S1,S2)=min(d(S1-1,S2)+1,d(S1,S2-1)+1,d(S1-1,S2-1)+cost(S1,S2))

[0048] Among them, d(S1, S2) represents the edit distance between the two versions of the document at positions S1 and S2, and cost(S1, S2) is whether the compared characters are the same. If they are the same, it is 0, otherwise it is 1. Through this algorithm, the specific changes between different versions of the document can be identified, including text content, paragraph structure, images, and table elements. For the highlighted changes, the detected changes are highlighted and an intuitive visual chart display is provided. This process includes generating a difference report, clearly marking the changed parts, and highlighting them through color coding or borders, so that users can quickly identify the changes. In addition, an interactive comparison interface can be generated, allowing users to compare the differences between different versions line by line or paragraph by paragraph.

[0049] In some implementations, machine learning continuously optimizes the accuracy of question and answer and the matching degree of document content. Through the user feedback mechanism, the accuracy of the generated answers and the user's expectations is annotated, and the model parameters are further adjusted to ensure that future question and answer results are more accurate.

[0050] The beneficial effect of the present invention is that it can automatically generate documents that conform to the template and accurately compare the differences between different versions to reduce errors in manual operations and significantly improve work efficiency. A document question-answering, generation and comparison system based on a large model is proposed, which aims to automatically generate documents that conform to the template and accurately compare the differences between different versions to reduce errors in manual operations and significantly improve work efficiency. The core advantage of this system is that it automatically generates document content without the need for diversified or creative output. Many document types have fixed formats and writing requirements, and usually do not require complex personalized processing. By utilizing large models, the system can quickly generate documents based on fixed templates and then conduct manual verification. This method effectively reduces the time for document writing while reducing errors caused by manual processing. In addition, the system automatically identifies and highlights the changed parts by accurately comparing different versions of the document, making content review more intuitive and efficient. The details are as follows:

[0051] 1. Automatic document generation: Existing technologies mostly rely on manual editing or fixed templates to generate documents, which is difficult to adapt to the diverse needs of users. The present invention introduces an automatic document generation module based on a large model, which can intelligently call templates according to different input content and user needs to generate documents with structured and personalized content, significantly improving the efficiency and quality of document generation.

[0052] 2. High-precision version comparison: Traditional document version comparison mostly uses simple text matching or line-by-line comparison, which makes it difficult to accurately identify complex semantic changes in documents. In contrast, the present invention uses deep learning algorithms to calculate semantic similarity and detect differences, which can not only accurately capture subtle changes in documents, but also analyze and present semantic differences between versions, making the changes more intuitive and explainable.

[0053] 3. Efficiency of multi-task learning: The present invention adopts a multi-task learning method, which can handle document generation and version comparison tasks at the same time. By sharing the underlying model parameters, the system improves the generation capability while also optimizing the accuracy of the comparison. Compared with the model trained with a single task, the solution of the present invention significantly improves the efficiency of model training and system performance.

[0054] 4. Self-optimization capability of enhanced learning: The present invention combines supervised learning with reinforcement learning, so that the system has the ability to self-optimize. The user's feedback when using the document generation and comparison functions will serve as a reward signal for reinforcement learning, driving the system to continuously improve the generation effect and comparison accuracy in practical applications, thereby enhancing the intelligence and adaptability of the model.

[0055] 5. Wide applicability and scalability: The present invention supports the processing and generation of multiple types of documents and can be applied to a variety of industry needs, such as technical documents, legal documents, market reports, etc. The system design is highly scalable and can flexibly adapt to the input and output of different document formats to meet a wide range of application scenarios. DETAILED DESCRIPTION

[0056] The invention is further described in detail below.

[0057] A large language model system for document question answering, generation, and version comparison consists of three core modules:

[0058] Document Q&A module: After users upload documents, the system searches for content based on the questions they ask about the document and provides direct or summary answers. This allows users to quickly find the expected content for long documents and provide the corresponding content on the page for verification.

[0059] Document generation module: Based on user needs, it calls fixed templates to automatically generate documents that conform to specific structures, such as instructions, risk documents, etc.

[0060] Document comparison module: compare different versions of the same document, accurately extract the changed parts, highlight them and display the comparison table through charts.

[0061] Among them, the implementation process of the document question and answer module is as follows:

[0062] First, the system pre-processes the files (including but not limited to text, PDF, and images) from the user and extracts the file contents, performs operations such as cleaning, word segmentation, and formatting. In particular, for images or scanned PDF documents, the system uses optical character recognition technology to extract the text content, ensuring that all file formats can be uniformly processed and converted into text data for analysis.

[0063] After completing the document preprocessing, the system enters the core question-and-answer phase. First, the files uploaded by users are deeply analyzed through natural language processing technology to generate the semantic structure of the document. Document analysis ensures that the content of the document can be represented in a structured form, which facilitates the system to perform subsequent question-and-answer matching. In particular, the system maps each sentence or paragraph into a high-dimensional space by constructing a vector representation of the document, and each word is represented as a vector. This process captures the semantic and grammatical relationships between words, so that words with similar semantics or grammar are close in the vector space. This process is completed using the nomic-embed-text model. Core formula:

[0064]

[0065] Among them, Vd represents the document vector representation, T d Represents the text content of the document, E(t i ) represents the embedding vector of the i-th word, and f represents the generating function of document embedding;

[0066] The system uses vectorized document structures and combines them with models to perform contextual analysis. When users ask questions, the system performs the same vectorization on the questions.

[0067] Next, the system identifies the most relevant document fragments by calculating the similarity between the document content and the question, using cosine similarity as a metric:

[0068]

[0069] Where: θ represents the angle between the two vectors, V d , V q Represent the document vector and question vector respectively.

[0070] Through this formula, the system calculates the cosine value of the angle between the document and the question vector. The smaller the angle, the closer the semantics, and the system can find the corresponding document location more accurately.

[0071] After obtaining the relevant document fragments, the system generates a response by matching the content position and combining the document structure information. While generating the answer, the system also returns the specific location of the answer in the original document to facilitate user positioning.

[0072] The system also supports question-answering for multiple documents. For multiple documents, the system preprocesses and vectorizes each document separately, then combines the similarity results of all documents and selects the most relevant document fragments for answering. In the case of multiple documents, the system uses the following formula for similarity aggregation:

[0073] S=max(cos(θ1),cos(θ2),cos(θ3)…cos(θ n ))

[0074] Where S represents the comprehensive similarity, cos(θ n ) represents the similarity of the nth document.

[0075] In addition, the system continuously optimizes the accuracy of questions and answers and the matching degree of document content through machine learning models. Through the user feedback mechanism, the system marks the accuracy of the generated answers and the user's expectations, and further adjusts the model parameters to ensure that future question and answer results are more accurate.

[0076] Document generation module implementation process

[0077] In the document generation module, the system completes the entire process from type recognition to document generation through the collaboration of multiple models. These models include a type recognition model that identifies the document type to be generated from user requirements and a fine-tuned large language model for document filling. Each model implements its own functions based on clear algorithms and deep learning technology to ensure that the generated documents meet user requirements and maintain high quality.

[0078] File type recognition model

[0079] The core task of the file type recognition model is to determine the type of document that the user needs to generate based on the user's requirements. The user needs to include keywords of the document type in the requirements, such as "instructions", "risk analysis report", "technical requirements document", etc. The model uses natural language processing technology to perform semantic analysis on the requirements input by the user, extract key terms and determine the corresponding document type.

[0080] The file type recognition model automatically identifies the document type information implicit in user requirements. The main process of the model includes: the system receives the requirements proposed by the user, and the requirement description should contain keywords about the required document type. The system processes the requirement description: text cleaning, word segmentation, part-of-speech tagging and other preprocessing operations. Further semantic analysis is performed on the preprocessed requirement description to understand the semantic content in the requirement description and extract key words related to the document type. In this step, the model will use Word2Vec and TF-IDF (Term Frequency-Inverse Document Frequency) technology to construct a semantic vector representation of the requirement description, and then use the classification model trained by the machine learning algorithm (SVM support vector machine) to analyze the document category corresponding to the requirement.

[0081] Word2Vec: Convert text into vectors.

[0082] TF-IDF: Calculates the importance score of each word in the requirement description:

[0083] w i =TF(w i ,D)×IDF(w i )

[0084] where w i is the importance score of the i-th word, TF(w i ,D) represents word w i The word frequency in document D. IDF(w i) represents the inverse document frequency of the word. Model training: extract features and combine them into a feature vector. Then train the data set to fit the selected model, SVM minimizes the empirical error and maximizes the geometric interval. Based on the extracted keywords, the model determines the document type corresponding to the demand description. Through the above process, the file type recognition model can accurately identify the required document type from the user's demand description.

[0085] Fill the model with file content

[0086] The document content filling model is a fine-tuned model combined with the document template provided by the user. The template content contains the basic structure of the document and the content area that needs to be filled. The system can automatically generate document content based on these templates as prompts. The model automatically fills different types of documents through natural language generation technology to ensure that the generated content is logically coherent and meets expectations.

[0087] Template input and processing: First, the system receives the corresponding template identified in the previous step. The template contains the overall structure of the document and the parts that need to be filled. The template is parsed by the system as a set of predefined placeholders that identify the content area to be generated in the document. The parsing of the template can be expressed by the following formula:

[0088] T={P1,P2,…,P n}

[0089] Among them, T represents the template, P i It is the i-th part in the template that needs to be filled, that is, the content of different chapters. i Contains specific prompt words or descriptions, which the system will use to guide the model to generate corresponding content.

[0090] Prompt word generation: In the fine-tuned large language model, the core of generating document content lies in constructing appropriate prompt words to guide the model to generate text content that meets the requirements. i It is processed into a prompt word, which contains the context information of the document and the specific content to be generated. The formula for generating prompt words is as follows:

[0091] prompt i =f(P i ,C i-1 )

[0092] Among them, prompt i is the prompt word for generating content, P i is the i-th part in the template, C i-1represents the content generated in the previous part, and f is a function used to convert template information into prompt words. Through recursive calls in the generation process, the prompt words of each part will contain context information to ensure the logical coherence of the generated content.

[0093] Document content generation: Document content generation is done based on prompt words through a fine-tuned content model. Generate content based on prompt words. The model generates corresponding paragraphs, titles, or table content based on the input prompt words. The logical order of generated content is constructed through prompt words to ensure that each part of the content is closely related to the context of the document.

[0094] Content Large Model Acquisition: In order to ensure that the generated document content meets user needs, the system performs fine-tuning when using a large language model. The fine-tuning process uses a large amount of document data of a specific type for training to ensure that the model can generate high-quality content based on the structure of the document template.

[0095] The loss function used in the fine-tuning process is the cross-entropy loss, and the formula is as follows:

[0096]

[0097] Among them, y i is the correct document content, p(y i |x i ) is the model’s i Through fine-tuning, the model is able to better understand the structure of the document template and generate corresponding content.

[0098] Document generation: By generating content for all template parts, the system combines the generated content with the template structure to form the final complete document. The generated document can be exported to different file formats (such as PDF, Word, etc.) to meet user needs.

[0099] Document comparison module

[0100] The document comparison module introduces a regularization method. The system can accurately extract the title, paragraph, picture, table and other information of the document according to the characteristics of different structures in the document, and identify and separate text blocks, image boundaries and table structures through pattern matching and machine learning algorithms. The main process of the document comparison module includes: in the document version import stage, the system allows users to upload multiple versions of documents and automatically parse them. During the parsing process, the system first standardizes the documents, including format conversion, noise removal and structured data extraction. Through regularization operations, all versions of documents are uniformly converted into a consistent internal representation to ensure accurate comparison between documents in different formats. In the difference detection stage, the system uses a text similarity algorithm based on edit distance to compare the same parts and detect changes between different versions. In particular, the Levenshtein distance is used to calculate the minimum number of edit operations between two text fragments. The algorithm measures the difference between two text sequences S1 and S2 by inserting, deleting or replacing characters in them. The calculation formula is:

[0101] d(S1,S2)=min(d(S1-1,S2)+1,d(S1,S2-1)+1,d(S1-1,S2-1)+cost(S1,S2))

[0102] Among them, d(S1, S2) represents the edit distance between the two versions of the document at positions S1 and S2, and cost(S1, S2) is whether the compared characters are the same, if they are the same, it is 0, otherwise it is 1. Through this algorithm, the system can identify the specific changes between different versions of the document, including text content, paragraph structure, images and table elements.

[0103] Highlight changes: The system highlights the detected changes and provides an intuitive visual chart display. This process includes generating a difference report, clearly marking the changed parts and highlighting them through color coding or borders, so that users can quickly identify the changes. In addition, the system can also generate an interactive comparison interface that allows users to compare the differences between different versions line by line or paragraph by paragraph.

[0104] The protection of the present invention lies in the use of large models to achieve automated document generation, which can generate structured documents according to user needs, and identify the differences between different versions of documents through a high-precision semantic comparison algorithm and present them intuitively. In addition, the system combines multi-task learning and reinforcement learning techniques to make document generation and version comparison more efficient and intelligent, and can be continuously optimized based on user feedback. The system has a wide range of applicability, can process multiple types of document data, and significantly improves the accuracy and efficiency of document generation and comparison.

[0105] The above are only some embodiments of the present invention. For those skilled in the art, several modifications and improvements can be made without departing from the inventive concept of the present invention, which all belong to the protection scope of the invention.

Claims

1. A large language model system for document question answering, generation and version comparison, characterized by ,including a document question and answer module, a document generation module and a document comparison module that are connected in sequence; The document question and answer module searches for content based on the questions raised by the user after the user uploads the document, and provides direct answers or summary answers; in this way, for long documents uploaded by users, the expected content can be found quickly, and the corresponding content can be provided for the page for verification; The document generation module calls a fixed template to automatically generate a document that conforms to a specific structure according to user needs; The document comparison module compares different versions of the same document, accurately extracts the modified parts, highlights them and displays the comparison table through charts.

2. A large language model system for document question answering, generation and version comparison according to claim 1, characterized in that ,The document of the specific structure is an instruction document or a risk document or a document with a fixed template.

3. A large language model system for document question answering, generation and version comparison according to claim 1 or 2, characterized in that ,The implementation process of the document question and answer module is as follows: (1) Preprocess the file first Obtain a file from a user terminal and extract the content in the file, and perform cleaning, word segmentation, and formatting operations on the file; the file obtained by the user terminal is in the format of text or PDF or scanned PDF or image; (2) After completing the file preprocessing, enter the core question-and-answer session First, the files uploaded by users are deeply analyzed through natural language processing technology to generate the semantic structure of the documents. The analysis of the above files ensures that the document content can be represented in a structured form to facilitate subsequent question-answer matching. In particular, by constructing a vector representation of the document, each sentence or paragraph is mapped to a high-dimensional space, and each word is represented as a vector. This process captures the semantic and grammatical relationship between words, so that words with similar semantics or grammar are close in the vector space. The above process is completed using the nomic-embed-text model, and its core formula is: Among them, V d represents the document vector representation, T d Represents the text content of the document, E(t i ) represents the embedding vector of the i-th word, and f represents the generating function of document embedding; The document structure represented by the vectorization above is combined with the model for contextual association analysis. When the user asks a question, the question is vectorized in the same way. Next, the most relevant document fragments are identified by calculating the similarity between the document content and the question, using cosine similarity as the measurement standard: Where: θ represents the angle between the two vectors, V d , V q Represent document vector and question vector respectively; The cosine value of the angle between the document and question vector is calculated through the above core formula. The smaller the angle, the closer the semantics are, and the corresponding document position can be found more accurately. Secondly, when the corresponding document location is found, the relevant document fragment is obtained, and a response is generated by matching the content location and combining the document structure information. While generating the answer, the specific location of the answer in the original document is returned to facilitate user positioning.

4. A large language model system for document question answering, generation and version comparison according to claim 3, characterized in that ,The above question and answer session also supports question and answer processing for ,multiple documents; for multiple documents, each document will be preprocessed and vectorized ,represented separately, and then the similarity results of all documents will be ,combined to select the most relevant document fragment for answering; In the case of multi-document question answering, the following formula is used for similarity aggregation: S=max(cos(θ1),cos(θ2),cos(θ3)…cos(θ n )) Where S represents the comprehensive similarity, cos(θ n ) represents the similarity of the nth document.

5. A large language model system for document question answering, generation and version comparison according to claim 3, characterized in that ,When the format of the file obtained by the above user end is a picture or a scanned PDF, the optical character recognition (OCR) ,technology is used to extract the text content therein, ensuring that all file formats can be ,uniformly processed and converted into text data that can be analyzed.

6. A large language model system for document question answering, generation and version comparison according to claim 1 or 2, characterized in that ,The document generation module completes the whole process from type recognition to ,document generation through the collaboration of multiple models; The above-mentioned multiple models include a file type recognition model and a file content filling model; The file type recognition model identifies the type of document to be generated based on user requirements, and then the fine-tuned large language model is used to fill the model with file content; each model implements its own function based on clear algorithms and deep learning technology to ensure that the generated documents meet user requirements and maintain high quality; (1) File type recognition model The core task of the file type recognition model is to determine the document type that the user needs to generate based on the requirements put forward by the user; the user needs to include the keywords of the document type, such as instructions, risk analysis reports, and technical requirements documents in the requirements; the file type recognition model then uses natural language processing technology to perform semantic analysis on the requirements input by the user, extract key terms and determine the corresponding document type; wherein the file type recognition model automatically recognizes the document type information implicit in the user's requirements; The main process of the file type identification model includes receiving the requirements proposed by the user, the requirement description should contain keywords about the required document type, processing the requirement description, and performing preprocessing operations such as text cleaning, word segmentation, and part-of-speech tagging; further performing semantic analysis on the preprocessed requirement description to understand the semantic content in the requirement description and extract key words related to the document type; In the file type identification model step, Word2Vec and TF-IDF technologies are used to construct a semantic vector representation of the requirement description, and then the classification model trained by the machine learning algorithm SVM support vector machine is used to analyze the document category corresponding to the requirement; Word2Vec converts text into vectors; TF-IDF calculates the importance score of each word in the requirement description: w i =TF(w i ,D)×IDF(w i ) where w i is the importance score of the i-th word, TF(w i ,D) represents word w i The word frequency in document D. IDF(w i ) represents the inverse document frequency of a word. The above algorithm SVM support vector machine training is to extract features and combine these features into a feature vector; then the training data set is used to fit the selected model, SVM minimizes the empirical error and maximizes the geometric interval; based on the extracted keywords, the file type recognition model determines the document type corresponding to the demand description; finally, after the above judgment process, the file type recognition model can accurately identify the required document type from the user's demand description; (2) File content filling model The document content filling model is obtained by fine-tuning the model combined with the document template provided by the user, wherein the content of the document template includes the basic structure of the document and the content area to be filled, and then the document content is automatically generated according to the document template as a prompt word; the above-mentioned document model automatically fills different types of documents through natural language generation technology to ensure that the generated content is logically coherent and meets expectations; The document template input and processing described above firstly receives the corresponding document template identified in the previous step, which contains the overall structure of the document and the parts to be filled; then the document template is parsed by the system into a set of predefined placeholders to identify the content area to be generated in the document; The formula for parsing the above document template is: T={P1,P2,…,P n } Among them, T represents the template, P i It is the i-th part in the template that needs to be filled, that is, the content of different chapters; each P i Contains specific prompt words or descriptions, which will be used to guide the model to generate corresponding content; the above prompt word generation is in the fine-tuned large language model. The core of generating document content lies in constructing appropriate prompt words to guide the model to generate text content that meets the requirements; each template part P i It is processed into prompt words, which contain the context information of the document and the specific content to be generated; The formula for generating prompt words is as follows: prompt i =f(P i ,C i-1 ) Among them, prompt i is the prompt word for generating content, P i is the i-th part in the template, C i-1 represents the content generated in the previous part, and f is a function used to convert template information into prompt words. Through recursive calls in the generation process, the prompt words of each part will contain context information to ensure the logical coherence of the generated content. The document content is generated by using a fine-tuned content model based on the prompt words; the content is generated according to the prompt words; the model generates corresponding paragraphs, titles or table contents based on the input prompt words; the logical order of the generated content is constructed by the prompt words to ensure that each part of the content is closely related to the context of the document; The acquisition of the large content model is to ensure that the generated document content meets user needs and to perform fine-tuning when using a large language model; the fine-tuning process uses a large amount of document data of a specific type for training to ensure that the model can generate high-quality content based on the structure of the document template; The loss function used in the fine-tuning process is the cross entropy loss, and the formula is as follows: Among them, y i is the correct document content, p(y i |x i ) is the model’s i The probability of prediction under certain conditions; through fine-tuning, the model can better understand the structure of the document template and generate corresponding content; The generated document is generated by generating the content of all template parts, combining the generated content with the template structure to form a final complete document; the generated document can be exported to different file formats such as PDF format or Word format to meet user needs.

7. A large language model system for document question answering, generation and version comparison according to claim 1 or 2, characterized in that ,The document comparison module introduces regularization methods to ,accurately extract various information of the document such as title, paragraph, picture, and table according to the ,features of different structures in the document, and recognizes and ,separates text blocks, image boundaries and table structures through pattern ,matching and machine learning algorithms; The main process of the document comparison module includes the document version import stage, allowing users to upload multiple versions of documents, and automatic parsing of multiple versions of documents; In the parsing process, the document is first standardized, including format conversion, noise removal and structured data extraction; through regularization operations, all versions of the document are uniformly converted into a consistent internal representation to ensure accurate comparison between documents in different formats; in the difference detection stage, a text similarity algorithm based on edit distance is used to compare the same parts and detect changes between different versions; in particular, the Levenshtein distance is used to calculate the minimum number of edit operations between two text fragments; the algorithm measures the difference between two text sequences S1 and S2 by inserting, deleting or replacing characters in them, and the calculation formula is: d(S1,S2)=min(d(S1-1,S2)+1,d(S1,S2-1)+1,d(S1-1,S2-1)+cost(S1,S2)) Among them, d(S1, S2) represents the edit distance between the two versions of the document at positions S1 and S2, and cost(S1, S2) is whether the compared characters are the same, if they are the same, it is 0, otherwise it is 1; through this algorithm, the specific changes between different versions of the document can be identified, including text content, paragraph structure, image and table elements; for the highlighted changes, the detected changes are highlighted and an intuitive visual chart display is provided; this process includes generating a difference report, clearly marking the changed parts, and highlighting them through color coding or borders, so that users can quickly identify the changes; In addition, an interactive comparison interface can be generated, allowing users to compare the differences between different versions line by line or paragraph by paragraph.

8. A large language model system for document question answering, generation and version comparison according to claim 6, characterized in that ,The described machine learning continuously optimizes the accuracy of questions and answers and the matching of document content; through the user feedback mechanism, the accuracy of the generated answers and the user’s expectations are annotated, and the model parameters are further adjusted to ensure that future question and answer results are more accurate.

Citation Information

Cited By

  • Long document rapid summarization system and method based on semantic extraction

    CN121658645A