Document question and answer method and device, equipment and storage medium

By receiving the question entries and document identification information entered by the user, obtaining the document segments of the target document, calculating the semantic correlation degree and selecting the document segments with the correlation degree reaching the preset, the answers are solved in the prior art that the input document is too large in the previous technology, resulting in the answers Poorly generated questions achieve efficient and accurate answer generation and improve user experience.

CN119474289APending Publication Date: 2025-02-18BEIJING QIHOOD TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310988858.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, if the input document is too large, it will not be able to accurately and efficiently generate the answers that the user wants to know, resulting in poor user experience.

Method used

By receiving the question entries and document identification information entered by the user, obtain the document segments of the target document, calculate the semantic correlation between the question entries and each document segment, and select the document to be entered with the semantic correlation reaching the preset correlation degree. Segmentation, and segmentation of the question entries and documents to be entered into the pre-trained language model to generate answers.

Benefits of technology

It realizes the accurate and efficient generation of answers to the question entries without entering the entire document, improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474289A_ABST
    Figure CN119474289A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of document search, and discloses a document question and answer method, device and equipment and a storage medium, the method comprises the following steps: receiving a question entry and document identification information input by a user, and obtaining document segments of a target document corresponding to the document identification information; calculating semantic relevancy between the question entry and each document segment, and selecting a to-be-input document segment of which the semantic relevancy reaches a preset relevancy from each document segment; and inputting the question entry and the to-be-input document segment into a pre-training language model, so that the pre-training language model generates an answer of the question entry based on the target document segment. According to the method, the question entries and the to-be-input document with the semantic relevancy reaching the preset relevancy are input into the pre-trained language model in a segmented mode, and compared with the situation that answers cannot be efficiently generated when the whole document is input in the prior art, the answers of the question entries are accurately and efficiently generated, and the user experience is improved. And the user experience is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of document search technology, and in particular to a document question and answer method, device, equipment and storage medium. Background Art

[0002] With the development of artificial intelligence, more and more language models are used by users, and the most commonly used one is the pre-trained language model (Generative Pre-trained Transformer, GPT).

[0003] Currently, users ask questions about documents, and then input the documents and questions into GPT, which will generate answers to the questions from the documents. However, if the input document is too long, the above method cannot accurately and efficiently generate the answers that users want to know, resulting in a poor user experience.

[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of the present invention is to provide a document question and answer method, device, equipment and storage medium, aiming to solve the technical problem in the prior art that if the input document is too long, it is impossible to accurately and efficiently generate the answers the user wants to know, resulting in a poor user experience.

[0006] To achieve the above object, the present invention provides a document question-answering method, which comprises the following steps:

[0007] Receiving a question term and document identification information input by a user, and obtaining a document segment of a target document corresponding to the document identification information;

[0008] Calculating the semantic relevance between the question terms and each of the document segments, and selecting a document segment to be input whose semantic relevance reaches a preset relevance from each of the document segments;

[0009] The question terms and the to-be-input document segment are input into a pre-trained language model, so that the pre-trained language model generates an answer to the question terms based on the target document segment.

[0010] Optionally, the step of calculating the semantic relevance between the question terms and each of the document segments comprises:

[0011] Obtaining the segment word vectors of each of the document segments and the question word vectors of the question terms through a preset vector model;

[0012] Calculating the vector distance between the question word vector and the segment word vector;

[0013] The semantic relevance between the question term and each of the document segments is determined according to the vector distance.

[0014] Optionally, the step of selecting, from each of the document segments, a document segment to be input whose semantic relevance reaches a preset relevance includes:

[0015] Sorting the document segments from high to low according to the semantic relevance to obtain a sorting result;

[0016] Determining a cutoff ranking in the sorting results whose semantic relevance reaches a preset relevance;

[0017] Selecting document segments from the ranking results in descending order of semantic relevance until the ranking of the selected document segments is as low as the cutoff ranking;

[0018] The selected document segment is used as the document segment to be input.

[0019] Optionally, the step of obtaining the document segment of the target document corresponding to the document identification information includes:

[0020] Determine whether the document identification information exists in the preset inverted list;

[0021] If the document identification information exists, determining a target index matching the document identification information from the preset inverted list;

[0022] A document segment of a target document corresponding to the document identification information is extracted from the preset inverted list according to the target index.

[0023] Optionally, after the step of determining whether the document identification information exists in the preset inverted list, the method further includes:

[0024] If the document identification information does not exist, obtaining the target document corresponding to the document identification information;

[0025] Determine the target document segmentation position according to a preset document segmentation strategy;

[0026] The document content of the target document is segmented according to the target document segmentation positions to obtain the document segments of the target document.

[0027] Optionally, before the step of determining whether the document identification information exists in the preset inverted list, the method further includes:

[0028] Acquire a local document and determine local document identification information of the local document;

[0029] Determine the document segmentation position of the local document according to a preset document segmentation strategy;

[0030] Segmenting the document content of the local document according to the document segmentation positions to obtain local document segments of the local document;

[0031] A preset inverted list is constructed based on the local document identification information and the local document segment.

[0032] Optionally, the step of determining the document segmentation position according to a preset document segmentation strategy includes:

[0033] Determining a first segmentation position for segmenting the local document based on a preset word count;

[0034] Adjust the first segment position according to the punctuation mark at the first segment position to obtain a second segment position;

[0035] The second segment position is adjusted based on the semantic relevance between the natural paragraph and the document contents on both sides of the second segment position to obtain the document segment position of the local document.

[0036] Optionally, the step of adjusting the first segment position according to the punctuation mark at the first segment position to obtain the second segment position includes:

[0037] Determining whether the punctuation mark at the first segment position is a preset mark;

[0038] If it is not the preset symbol, adjusting the first segment position to the preset symbol based on a preset word number range;

[0039] The adjusted first segment position is used as the second segment position.

[0040] Optionally, the step of adjusting the second segment position based on the semantic relevance between the natural paragraph and the document contents on both sides of the second segment position to obtain the document segment position of the local document includes:

[0041] Determine whether the second segmentation position splits a single natural paragraph;

[0042] If a single natural paragraph is split, the second segment position is adjusted to the end of the single natural paragraph to obtain a third segment position;

[0043] The third segment position is adjusted according to the semantic relevance between the document contents on both sides of the third segment position to obtain the document segment position of the local document.

[0044] Optionally, the step of adjusting the third segment position according to the semantic relevance between the document contents on both sides of the third segment position to obtain the document segment position of the local document includes:

[0045] Determine whether the semantic relevance between the document contents on both sides of the third segment position reaches a preset threshold;

[0046] If the preset threshold is reached, adjusting the position of the third segment so that the document contents on both sides are divided into the same document segment;

[0047] The adjusted third segment position is used as the segment position of the local document.

[0048] Optionally, the two-side document contents include the front-side document contents and the back-side document contents, and before the step of determining whether the semantic relevance between the two-side document contents of the third segment position reaches a preset threshold, the step further includes:

[0049] Calculate the first segment word vector of the previous side document content by using a preset vector model;

[0050] Calculate the second segment word vector of the second side document content by using a preset vector model;

[0051] Calculating the distance between the first segmented word vector and the second segmented word vector;

[0052] The semantic relevance between the first-side document content and the second-side document content is determined according to the two-side vector distance.

[0053] Optionally, after the step of determining whether the semantic relevance between the document contents on both sides of the third segment position reaches a preset threshold, the method further includes:

[0054] If the preset threshold is not reached, the third segment position is used as the segment position of the local document.

[0055] Optionally, after the step of determining whether the second segmentation position splits a single natural paragraph, the method further includes:

[0056] If the single natural paragraph is not split, the second segmentation position is adjusted according to the semantic relevance between the document contents on both sides of the second segmentation position to obtain the document segmentation position of the local document.

[0057] Optionally, after the step of segmenting the document content of the local document according to the document segmentation positions to obtain local document segments of the local document, the step further includes:

[0058] Detecting whether there are multiple document segments in which the target content is split into a single sentence in each of the local document segments;

[0059] If there are multiple document segments in which the target content is divided into a single sentence, the target content is divided into the same local document, and the target content is combined into the single sentence in the same local document.

[0060] Optionally, before the step of obtaining the segment word vectors of each of the document segments and the question word vectors of the question terms through a preset vector model, the step further includes:

[0061] Obtaining a number of training documents in a preset field, and constructing training sentence samples based on the training documents;

[0062] Calculating word vectors between sentences in the training sentence sample;

[0063] The initial open source vector model is trained using the training sentence samples and the word vectors to obtain a preset vector model.

[0064] Optionally, after the step of inputting the question terms and the to-be-input document segments into the pre-trained language model, the step further includes:

[0065] Receive the answer fed back by the pre-trained language model, and determine whether the error between the answer and the answer required by the user meets the preset error condition;

[0066] If the preset error condition is not met, obtaining an optimized document whose document type is related to the question term, and optimizing and training the preset vector model according to the optimized document;

[0067] When the error between the answer obtained by the preset vector model after optimization and the answer required by the user meets the preset error condition, the optimization is determined to be completed.

[0068] Optionally, after the step of performing optimization training on the preset vector model according to the optimization document, the step further includes:

[0069] When the error between the answer obtained by the optimized pre-trained language model and the answer required by the user does not meet the preset error condition, obtaining a new optimized document;

[0070] The preset vector model is optimized and trained by using the new optimization document until the error between the answer obtained by the optimized preset vector model and the answer required by the user meets the preset error condition.

[0071] In addition, to achieve the above-mentioned purpose, the present invention also proposes a document question-and-answer device, which includes:

[0072] The term receiving module is used to receive the question term and document identification information input by the user, and obtain the document segment of the target document corresponding to the document identification information;

[0073] A semantic calculation module, used for calculating the semantic relevance between the question terms and each of the document segments, and selecting a document segment to be input whose semantic relevance reaches a preset relevance from each of the document segments;

[0074] The data feedback module is used to input the question terms and the document segment to be input into the pre-trained language model, so that the pre-trained language model obtains the answer to the question terms from the target document segment.

[0075] In addition, to achieve the above-mentioned purpose, the present invention also proposes a document question and answer device, which includes: a memory, a processor, and a document question and answer program stored in the memory and executable on the processor, and the document question and answer program is configured to implement the steps of the document question and answer method described above.

[0076] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a document question and answer program is stored, and when the document question and answer program is executed by a processor, the steps of the document question and answer method described above are implemented.

[0077] The present invention receives the question terms and document identification information input by the user, and obtains the document segmentation of the target document corresponding to the document identification information; then calculates the semantic relevance between the question terms and each document segmentation, and selects the document segmentation to be input whose semantic relevance reaches the preset relevance from each document segmentation; finally, inputs the question terms and the document segmentation to be input into the pre-trained language model, so that the pre-trained language model generates the answer to the question terms based on the target document segmentation. The present invention calculates the semantic relevance between the question terms and the document segmentation, and then inputs the question terms and the document segmentation to be input whose semantic relevance reaches the preset relevance into the pre-trained language model. The semantic relevance can reflect the closeness between the question terms and the document segmentation. Compared with the prior art of inputting the entire document into the pre-trained language model, there is a situation where the answer cannot be accurately and efficiently generated. The above method of the present invention realizes accurate and efficient generation of the answer to the question terms by inputting the document segmentation whose semantic relevance of the question terms reaches the preset relevance into the pre-trained language model instead of inputting the entire document, and effectively improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] Figure 1 A schematic diagram of the structure of a document question-and-answer device in a hardware operating environment according to an embodiment of the present invention;

[0079] Figure 2It is a flowchart of the first embodiment of the document question-and-answer method of the present invention;

[0080] Figure 3 It is a flowchart of the second embodiment of the document question-and-answer method of the present invention;

[0081] Figure 4 It is a flowchart of the third embodiment of the document question-and-answer method of the present invention;

[0082] Figure 5 It is a structural block diagram of the first embodiment of the document question and answer device of the present invention.

[0083] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0084] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0085] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a document question-and-answer device in a hardware operating environment according to an embodiment of the present invention.

[0086] like Figure 1 As shown, the document question-and-answer device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0087] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the document question-and-answer device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.

[0088] like Figure 1As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a document question and answer program.

[0089] exist Figure 1 In the document question and answer device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the document question and answer device of the present invention can be set in the document question and answer device, and the document question and answer device calls the document question and answer program stored in the memory 1005 through the processor 1001, and executes the document question and answer method provided by the embodiment of the present invention.

[0090] The embodiment of the present invention provides a document question-answering method, referring to Figure 2 , Figure 2 Schematic diagram of the process of the first embodiment of the document question and answer method of the present invention.

[0091] In this embodiment, the document question-answering method includes the following steps:

[0092] Step S10: receiving the question terms and document identification information input by the user, and obtaining the document segment of the target document corresponding to the document identification information.

[0093] It should be noted that the execution subject of the method of this embodiment can be a computing service device with document question and answer, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., and can also be other electronic devices that realize the same or similar functions. The following describes this embodiment and the following embodiments using the above-mentioned document question and answer device.

[0094] It is understandable that the above-mentioned question terms may be terms proposed by the user based on the selected document, such as what is the main idea of ​​a certain paragraph in the document, what is the central idea, and where a certain content is in the document.

[0095] It should be noted that the above-mentioned document identification information may be the document identification of the above-mentioned user-selected location document, and the document selected by the user may be determined through the document identification information.

[0096] It is understandable that the target document may be a document selected by the user corresponding to the document identification information.

[0097] It should be noted that the above document segments may be all segmented contents of the above target document.

[0098] In a specific implementation, the document question-and-answer device may store a document database constructed of several documents. A user may select a target document from the document database, ask questions based on the target document, generate question terms, and input the question terms and the document identification information of the target document into the document question-and-answer device. The document question-and-answer device may determine the user's target document based on the document identification information, without the user having to input the target document again, thereby improving the user's experience. After determining the target document based on the document identification information, the document question-and-answer device may obtain all document segments corresponding to the target document.

[0099] It should be understood that the document question-answering device can pre-segment each document in the document database to form document segments, and then associate the document segments with the document identification information to construct a reversed list. After receiving the document identification information input by the user, all document segments corresponding to the document identification information can be obtained.

[0100] Step S20: Calculate the semantic relevance between the question terms and each of the document segments, and select from each of the document segments a document segment to be input whose semantic relevance reaches a preset relevance.

[0101] It should be noted that the above semantic relevance can be used to reflect the degree of relevance between the question terms and the document segments. The higher the semantic relevance, the more relevant the question terms are to the document segments, and correspondingly, the less relevant the question terms are to the document segments.

[0102] It is understandable that the above-mentioned preset relevance may be a semantic relevance for determining whether the question terms and the document segments are highly correlated. That is, if the semantic relevance between the question terms and the document segments reaches the preset relevance, it can be determined that the relevance between the question terms and the document segments is high. On the contrary, if the semantic relevance between the question terms and the document segments is lower than the preset relevance, it can be determined that the relevance between the question terms and the document segments is low.

[0103] It should be noted that the above-mentioned document segments to be input may be document segments that are highly relevant to the question terms.

[0104] In a specific implementation, the document question and answer device can map the question terms and each document segment to a vector space, calculate the semantic relevance between the question terms and each document segment through the vector space, and then extract the document segments whose semantic relevance reaches a preset relevance as the document segments to be input, thereby obtaining document segments that are highly relevant to the question terms.

[0105] Furthermore, in this embodiment, the step of calculating the semantic relevance between the question terms and each of the document segments includes:

[0106] Step S201: obtaining the segment word vectors of each of the document segments and the question word vectors of the question terms through a preset vector model.

[0107] It should be noted that the above-mentioned preset vector model can be a model for mapping the input text into a vector space to generate a word vector of the input text. The preset vector model can be obtained based on word vector training of several documents and sentences in each document.

[0108] In a specific implementation, the above-mentioned document question and answer device can input each document segment and question term of the target document into the above-mentioned preset vector model, and the preset vector model will respectively calculate the word vectors of each document segment and question term to obtain the segment word vectors of the document segment and the question word vectors of the question term.

[0109] Step S202: Calculate the vector distance between the question word vector and the segment word vector.

[0110] It should be noted that the document question-answering device may calculate the vector distance between the question word vector and each segment word vector in sequence, so as to determine the semantic relevance between the question word and each of the document segments according to the vector distance.

[0111] Step S203: determining the semantic relevance between the question term and each of the document segments according to the vector distance.

[0112] In a specific implementation, the vector distance is negatively correlated with the semantic relevance, that is, the larger the vector distance, the higher the semantic relevance, and correspondingly, the smaller the vector distance, the lower the semantic relevance. Therefore, the document question-answering device can determine the semantic relevance between the question word and each document segment according to the vector distance between the question word vector and each segment word vector.

[0113] Furthermore, in this embodiment, before step S201, the following steps are further included:

[0114] Step S21: Acquire a number of training documents in a preset field, and construct training sentence samples according to the training documents.

[0115] It should be noted that the above-mentioned preset fields cover various industry fields that cover the scope of user questions, such as Chinese encyclopedia, finance, medical care, law, news, and academia.

[0116] In a specific implementation, the document question-and-answer device may select a number of documents from the preset fields as training documents, extract sentences from the training document content, and construct training sentence samples based on the sentences.

[0117] Step S22: Calculate the word vectors between the sentences in the training sentence samples.

[0118] In a specific implementation, the document question-and-answer device may calculate the word vector of each sentence in the training sentence sample through relevant software.

[0119] Step S23: training the initial open source vector model using the training sentence samples and the word vectors to obtain a preset vector model.

[0120] It should be noted that the above-mentioned initial open source training model can be an open source model for generating sentence word vectors, such as M3E.

[0121] In a specific implementation, the document question-and-answer device may use each sentence in the training sentence sample as training input and the word vector of each sentence as training output to iteratively train the initial open source training model to obtain the preset vector model.

[0122] Furthermore, in this embodiment, the step of selecting from each of the document segments a document segment to be input whose semantic relevance reaches a preset relevance includes:

[0123] Step S201 ′: sorting the document segments from high to low according to the semantic relevance to obtain a sorting result.

[0124] In a specific implementation, after calculating the semantic relevance between each document segment and the question term, the above-mentioned document question and answer device can sort the document segments in order of semantic relevance from high to low. In the obtained sorting results, the document segments with high semantic relevance are ranked first, and the document segments with low semantic relevance are ranked last.

[0125] Step S202': determining a cutoff ranking in the sorting results whose semantic relevance reaches a preset relevance.

[0126] In a specific implementation, the document question-and-answer device may use the ranking of the document segment whose semantic relevance reaches the preset relevance and is closest to the preset relevance in the sorting result as the cutoff ranking.

[0127] Step S203 ′: selecting document segments from the ranking results in descending order of semantic relevance, until the ranking of the selected document segments is as low as the cutoff ranking.

[0128] In a specific implementation, the document question-and-answer device may start selecting from the document segment with the highest semantic relevance, that is, start selecting from the document segment ranked first, and select document segments in sequence until the ranking of the document segment is equal to or lower than the cutoff ranking.

[0129] Step S204 ′: taking the selected document segment as the document segment to be input.

[0130] In a specific implementation, the document question-and-answer device may not select document segments whose ranking is equal to or lower than the cutoff ranking, but may select document segments whose ranking is higher than the cutoff ranking, and use the selected document segments as the document segments to be input whose semantic relevance reaches the preset relevance.

[0131] Step S30: inputting the question terms and the document segment to be input into a pre-trained language model, so that the pre-trained language model generates an answer to the question terms based on the target document segment.

[0132] In a specific implementation, the document question-answering device may input the question terms and the selected document segments to be input into the pre-trained language model, and the pre-trained language model answers the question terms from each document segment to be input, and generates answers to the question terms. Since the document segments to be input are segments in the target document and are highly relevant to the question terms, the answers obtained are more accurate and easier to meet user needs. At the same time, the input is a document segment, not the entire document, which effectively improves the efficiency of generating answers.

[0133] This embodiment receives the question terms and document identification information input by the user, and obtains the document segmentation of the target document corresponding to the document identification information; then calculates the semantic relevance between the question terms and each document segment, and selects the document segment to be input whose semantic relevance reaches the preset relevance from each document segment; finally, inputs the question terms and the document segment to be input into the pre-trained language model, so that the pre-trained language model generates the answer to the question terms based on the target document segmentation. This embodiment calculates the semantic relevance between the question terms and the document segment, and then inputs the question terms and the document segment to be input whose semantic relevance reaches the preset relevance into the pre-trained language model. The semantic relevance can reflect the degree of proximity between the question terms and the document segment. Compared with the prior art of inputting the entire document into the pre-trained language model, there is a situation where the answer cannot be generated accurately and efficiently. The above method of this embodiment achieves accurate and efficient generation of the answer to the question terms by inputting the document segment whose semantic relevance of the question terms reaches the preset relevance into the pre-trained language model instead of inputting the entire document, and effectively improves the user experience.

[0134] Furthermore, in this embodiment, after the step of inputting the question terms and the document to be input into the pre-trained language model in segments, the step further includes:

[0135] Step S40: receiving the answer fed back by the pre-trained language model, and determining whether the error between the answer and the answer required by the user meets a preset error condition.

[0136] It should be noted that the above-mentioned preset error condition can be used to determine whether the error between the answer generated by the pre-trained language model and the answer required by the user meets the required conditions.

[0137] It is understandable that the answer generated by the above-mentioned pre-trained language model is not necessarily the answer required by the user. Therefore, it is necessary to determine whether the accuracy between the answer generated by the pre-trained language model and the answer required by the user meets the above-mentioned preset error conditions to determine whether the accuracy of the pre-trained language model meets the requirements.

[0138] In a specific implementation, after receiving the answer generated by the pre-trained language model, the user can input the answer the user requires into the document question and answer device. The document question and answer device can calculate the error between the answer generated by the pre-trained language model and the answer the user requires through a vector space, and then determine whether the error meets the above-mentioned preset error condition.

[0139] Step S50: If the preset error condition is not met, an optimized document whose document type is related to the question term is obtained, and the preset vector model is optimized and trained according to the optimized document.

[0140] In a specific implementation, when the document question and answer device detects that the error between the generated answer and the answer required by the user does not meet the preset error condition, it can determine the type of the question term, use the type as the document type, and then obtain a document that meets the document type, use the document that meets the document type as an optimized document, and optimize the preset vector model based on the optimized document to improve the accuracy of the word vector output by the preset vector model, thereby improving the accuracy of the screening of the document segments to be input, and further improving the accuracy of the answer generated by the pre-trained language model.

[0141] Step S60: When the error between the answer obtained by the preset vector model after optimization and the answer required by the user meets the preset error condition, the optimization is determined to be completed.

[0142] In a specific implementation, the document question-and-answer device can output new question word vectors and segmented word vectors through an optimized preset vector model, and then determine a new document segment to be input based on the question word vectors and segmented word vectors, and generate an answer to the question entry based on the new document segment to be input through a pre-trained language model. When the error between the answer and the answer required by the user meets the preset error condition, it can be determined that the optimization of the preset vector model is completed.

[0143] Furthermore, in this embodiment, after step S50, the following steps are further included:

[0144] Step S60': when the error between the answer obtained by the optimized pre-trained language model and the answer required by the user does not meet the preset error condition, a new optimized document is obtained.

[0145] In a specific implementation, when the above-mentioned document question and answer device detects that the error between the answer obtained by the optimized pre-trained language model and the answer required by the user does not meet the preset error condition, it determines that the preset vector model after this optimization still does not meet the accuracy requirements and needs to be re-optimized, so a new optimized document can be obtained.

[0146] Step S70": Optimize and train the preset vector model using the new optimization document until the error between the answer obtained by the optimized preset vector model and the answer required by the user meets the preset error condition.

[0147] In a specific implementation, the document question and answer device can optimize and train the preset vector model again through the new optimized document. If the generated answer still does not meet the preset error condition, a new optimized document is generated for optimization until the error between the answer obtained by the optimized preset training model and the answer required for optimization meets the preset error condition.

[0148] It should be understood that when the error between the answer generated by the pre-trained language model and the answer required by the user does not meet the above-mentioned preset error conditions, the above-mentioned preset vector model can be optimized so that the error between the generated answer and the answer required by the user meets the above-mentioned preset error conditions, thereby improving the accuracy of the preset vector model, thereby improving the accuracy of the segmentation of the document to be input, and then improving the accuracy of the answer generated by the pre-trained language model, effectively improving the user experience.

[0149] refer to Figure 3 , Figure 3 Schematic diagram of the flow chart of the second embodiment of the document question and answer method of the present invention.

[0150] Based on the above first embodiment, in this embodiment, the step of obtaining the document segment of the target document corresponding to the document identification information includes:

[0151] Step S101: Determine whether the document identification information exists in the preset inverted list.

[0152] It should be noted that the above-mentioned preset inverted list is a list storing the document identification information of each document and the document segment of each document, wherein the document identification information can be used as an index to associate with the document segment of the document corresponding to the document identification information.

[0153] In a specific implementation, the document question and answer device may traverse each document identification information in the preset inverted list to determine whether the identification information of each document matches the document identification information.

[0154] It should be understood that the document question-and-answer device may segment each document in the document database in advance to obtain each document segment, and then associate each document segment with the document identification information of each document, thereby forming the preset inverted list.

[0155] Step S102: If the document identification information exists, determining a target index matching the document identification information from the preset inverted list.

[0156] In a specific implementation, when the document question and answer device detects that the document identification information exists in the preset inverted list, it can determine that the target document corresponding to the document identification information is a document stored locally, such as a document purchased locally instead of being uploaded by the user, and then obtain identification information matching the document identification information from the preset inverted list, and use the matching identification information as the target index.

[0157] Step S103: extracting the document segment of the target document corresponding to the document identification information from the preset inverted list according to the target index.

[0158] In a specific implementation, the document question-and-answer device may perform inverted indexing according to the target index, thereby recalling all document segments corresponding to the target index in a preset inverted list, that is, the document segments of the target document corresponding to the document identification information.

[0159] Furthermore, in this embodiment, after step S101, the following steps are further included:

[0160] Step S102': if the document identification information does not exist, then obtaining the target document corresponding to the document identification information.

[0161] In a specific implementation, when the document question-and-answer device detects that the document identification information does not exist in the preset inverted list, it can determine that the target document selected by the user has not been recorded locally and is a document uploaded by the user. The user can upload the target document while inputting the question term, so that the document question-and-answer device can obtain the target document corresponding to the document identification information.

[0162] Step S103 ′: determining the target document segmentation position according to a preset document segmentation strategy.

[0163] It should be noted that the above-mentioned preset document segmentation strategy may be a strategy for segmenting the target document based on word count, paragraphs, semantic relevance, etc.

[0164] In a specific implementation, since the target document is stored locally, that is, the target document is not segmented locally in advance, the document question and answer device can determine the target document segmentation position for the target document segment based on the preset document segmentation strategy.

[0165] Step S104 ′: segmenting the document content of the target document according to the target document segmentation positions to obtain document segments of the target document.

[0166] In a specific implementation, the document question-and-answer device may segment the document content of the target document according to the determined target document segment positions, thereby obtaining document segments of the target document.

[0167] This embodiment determines whether there is document identification information in a preset inverted list; when document identification information exists, determines a target index matching the document identification information from the preset inverted list, and extracts a document segment of the target document corresponding to the document identification information from the preset inverted list according to the target index; when document identification information does not exist, determines the target document segmentation position according to a preset document segmentation strategy; segments the document content of the target document according to the target document segmentation position to obtain the document segment of the target document, thereby achieving the goal of obtaining the document segment of the target document both when the target document exists locally and when the target document does not exist, thereby effectively improving the accuracy of obtaining the document segmentation.

[0168] refer to Figure 4 , Figure 4 Schematic diagram of the process of the third embodiment of the document question and answer method of the present invention.

[0169] Based on the above second embodiment, in this embodiment, before step S101, the method further includes:

[0170] Step S01: Acquire a local document and determine local document identification information of the local document.

[0171] It should be noted that the above-mentioned local document may be a document stored locally, and the local document may be a document uploaded by a user or a document sold externally.

[0172] In a specific implementation, the document question and answer device may obtain local documents from a document database and determine local document identification information of each local document.

[0173] Step S02: Determine the document segmentation position of the local document according to a preset document segmentation strategy.

[0174] In a specific implementation, the preset document segmentation strategy may be a strategy for segmenting the local document content based on the number of words, punctuation marks, paragraphs, and semantics. Accordingly, the document question-and-answer device may determine the document segmentation position for segmenting the document content of the local document through the preset document segmentation strategy, and the document segmentation position may make the content of the local document segment meet the user's needs.

[0175] Furthermore, in this embodiment, step S02 includes:

[0176] Step S021: determining a first segmentation position for segmenting the local document based on a preset word count.

[0177] It should be noted that the above-mentioned preset number of words may be a pre-set number of words, by which the number of words in the divided local document segments is limited so that the number of words in the divided local document segments is neither too long nor too short, meeting user needs.

[0178] In a specific implementation, the document question-and-answer device may start from the first word of the local document content and determine a first segment position every preset number of words, thereby limiting the number of words in the document segment, wherein punctuation marks are also counted as words.

[0179] Step S022: adjusting the first segment position according to the punctuation mark at the first segment position to obtain a second segment position.

[0180] In a specific implementation, since punctuation marks are also counted as words, there may be a situation where the first segment position when the preset word count is reached is a punctuation mark such as a comma or a semicolon when a sentence has not yet ended, so that another part of the sentence in the same local document segment is in the next document segment, resulting in an incomplete sentence that affects the semantics. Therefore, the document question-and-answer device also needs to adjust the first segment position according to the punctuation mark at the first segment position, so that the obtained second segment position can ensure the integrity of the content sentence in the same local document segment.

[0181] Furthermore, in this embodiment, step S022 includes:

[0182] Step S0221: Determine whether the punctuation mark at the first segment position is a preset mark.

[0183] It should be noted that the above-mentioned preset symbol may be a symbol at the end of a complete sentence, such as a period or an exclamation mark.

[0184] In a specific implementation, the document question-and-answer device may determine whether the punctuation mark at the first segment position is the preset mark, so as to determine whether the first segment position splits a complete sentence.

[0185] Step S0222: If it is not the preset symbol, adjusting the first segment position to the preset symbol based on a preset word number range.

[0186] In a specific implementation, when the document question-and-answer device detects that the punctuation mark at the first segment position is not the preset mark, the first segment position may be adjusted backward until the segment position is at the preset mark.

[0187] Step S0223: using the adjusted first segment position as the second segment position.

[0188] In a specific implementation, the document question-and-answer device may use the adjusted first segmentation position at the preset symbol as the second segmentation position to avoid sentence splitting.

[0189] It should be understood that when the document question-and-answer device detects that the punctuation mark at the first segment position is the preset mark, the document question-and-answer device may use the first segment position as the second segment position.

[0190] Step S023: adjusting the second segmentation position based on the semantic relevance between the natural paragraph and the document contents on both sides of the second segmentation position to obtain the document segmentation position of the local document.

[0191] In a specific implementation, the document question and answer device can adjust the second segmentation position to the end of a single natural paragraph when splitting a single natural paragraph at the second segmentation position to avoid splitting the single natural paragraph. At the same time, the semantic relevance between the document contents on both sides of the adjusted second segmentation position can also be used to judge whether the sentences on both sides are highly correlated. If they are highly correlated, the adjustment will continue so that the final document segmentation position will divide the sentences with highly semantic correlation into the same document segment.

[0192] Furthermore, in this embodiment, step S023 includes:

[0193] Step S0231: Determine whether the second segmentation position splits a single natural paragraph.

[0194] In a specific implementation, the document segmentation device can determine whether the second segmentation position splits a single natural paragraph by determining whether the preset symbol at each second segmentation position is not the end of the natural paragraph of the content.

[0195] Step S0232: If a single natural paragraph is to be split, the second segment position is adjusted to the end of the single natural paragraph to obtain a third segment position.

[0196] In a specific implementation, when the document question-and-answer device detects that the second segmentation position splits a single natural paragraph, it can adjust the second segmentation position to a preset symbol position at the end of the single natural paragraph to obtain a third segmentation position.

[0197] Step S0233: adjusting the third segment position according to the semantic relevance between the document contents on both sides of the third segment position to obtain the document segment position of the local document.

[0198] In a specific implementation, the above-mentioned document question and answer device can determine the semantic correlation between the document contents on both sides of the third segmentation position to determine the degree of correlation between the document contents on both sides. When the degree of correlation between the document contents on both sides is high, the third segmentation position can be adjusted so that the obtained document segmentation position divides the document contents with higher correlation into the same document segment.

[0199] Furthermore, in this embodiment, step S0233 includes:

[0200] It is determined whether the semantic relevance between the document contents on both sides of the third segment position reaches a preset threshold.

[0201] It should be noted that the above-mentioned preset threshold may be a threshold for judging whether the semantic relevance reaches a threshold that makes the contents of the documents on both sides highly close.

[0202] In a specific implementation, the document question-and-answer device can determine whether the document contents on both sides are highly similar by determining whether the semantic relevance between the document contents on both sides of each third segment position, such as between the sentences on both sides or between the paragraphs on both sides, reaches a preset threshold.

[0203] If the preset threshold is reached, the position of the third segment is adjusted so that the document contents on both sides are divided into the same document segment.

[0204] In a specific implementation, when the document question and answer device detects that the semantic relevance between the document contents on both sides of the third segment position reaches the preset threshold, it determines that the document contents on both sides are highly close. At this time, the third segment position can be adjusted so that the highly close document contents on both sides are in the same document segment.

[0205] The adjusted third segment position is used as the segment position of the local document.

[0206] In a specific implementation, the document question and answer device may use the third segmentation position as the segmentation position of the local question and answer, so that the document segment contents on both sides with a high degree of proximity are on the same side, thereby improving the accuracy of document segmentation.

[0207] Furthermore, in this embodiment, the two-side document content includes the front-side document content and the back-side document content, and before the step of determining whether the semantic relevance between the two-side document content of the third segment position reaches a preset threshold, it also includes:

[0208] The first segmented word vector of the previous side document content is calculated using a preset vector model.

[0209] In a specific implementation, the document question-and-answer device may input the document content on the previous side of the third segment position into the preset vector model, and calculate the first segment word vector of the document content on the previous side by the preset vector model.

[0210] The second segmented word vector of the latter side document content is calculated by a preset vector model.

[0211] In a specific implementation, the document question-and-answer device may input the document content on the rear side of the third segment position into the preset vector model, and calculate the second segment word vector of the document content on the rear side by the preset vector model.

[0212] Calculate the bilateral vector distance between the first segmented word vector and the second segmented word vector.

[0213] In a specific implementation, the document question-answering device may calculate the two-sided vector distance between the first segmented word vector and the second segmented word vector to calculate the semantic relevance based on the two-sided vector distance.

[0214] The semantic relevance between the first-side document content and the second-side document content is determined according to the two-side vector distance.

[0215] In a specific implementation, since the lower the vector distance, the higher the semantic relevance, the above-mentioned document question and answer device can determine the semantic relevance between the content of the document on the front side and the document on the back side according to the vector distance on both sides.

[0216] Accordingly, in this embodiment, after the step of determining whether the semantic relevance between the document contents on both sides of the third segment position reaches a preset threshold, the method further includes:

[0217] If the preset threshold is not reached, the third segment position is used as the segment position of the local document.

[0218] In a specific implementation, when the document question and answer device detects that the semantic relevance between the document contents on both sides of the third segmentation position does not reach the preset threshold, it can determine that the relevance of the document contents on both sides of the third segmentation position is not high, and the third segmentation position can be used as the segmentation position of the local document.

[0219] Furthermore, in this embodiment, after step S0231, the following steps are further included:

[0220] If the single natural paragraph is not split, the second segmentation position is adjusted according to the semantic relevance between the document contents on both sides of the second segmentation position to obtain the document segmentation position of the local document.

[0221] In a specific implementation, when the document question-and-answer device detects that the second segmentation position does not split a single natural paragraph, it can adjust the second segmentation position according to the semantic relevance between the document contents on both sides of the second segmentation position. The adjustment process can refer to the above-mentioned description of the document contents on both sides of the third segmentation position, which will not be repeated here. Then, the adjusted segmentation position is used as the document segmentation position of the local document.

[0222] Step S03: segmenting the document content of the local document according to the document segmentation positions to obtain local document segments of the local document.

[0223] In a specific implementation, the above-mentioned document question and answer device can segment the document content of the local document according to the determined document segmentation position, so that the obtained local document segmentation is based on a preset number of words, the same sentence is in the same segment, the document segment ends at a preset symbol, the same document segment does not span natural paragraphs, and the content in the same document segment is not related to the content in another document segment, thereby making the obtained local document segmentation more accurate.

[0224] Furthermore, in this embodiment, after step S03, the following steps are further included:

[0225] Step S031: Detecting whether there are multiple document segments in which the target content is split into a single sentence in each of the local document segments.

[0226] In a specific implementation, in order to avoid the content of a sentence in the same document segment being split into multiple document segments, the above-mentioned document question and answer device may split the target content in multiple document segments into a single sentence based on whether there are target content in multiple document segments in each local document segment. The target content may be the same sentence but is split into different document segments.

[0227] Step S032: If there are multiple document segments in which the target content is divided into a single sentence, the target content is divided into the same local document, and the target content is combined into the single sentence in the same local document.

[0228] In a specific implementation, the document question-and-answer device may, when detecting that there is target content in different segments divided into a single sentence, re-divide the target content in different segments into the same local document, and combine the target content into a complete sentence in the same local document, so as to avoid the content of a sentence in the same document segment being divided into multiple document segments, thereby improving the accuracy of document segmentation.

[0229] Step S04: constructing a preset inverted list based on the local document identification information and the local document segments.

[0230] In a specific implementation, the document question and answer device may associate the local document identification information of each local document with the local document segment of each local document, and use the local document identification information as an index to construct a preset inverted list.

[0231] This embodiment obtains a local document and determines the local document identification information of the local document; determines the document segmentation position of the local document according to a preset document segmentation strategy; segments the document content of the local document according to the document segmentation position to obtain the local document local document segmentation; and constructs a preset inverted list based on the local document identification information and the local document segmentation. This embodiment determines the first segmentation position for segmenting the local document based on a preset word count; adjusts the first segmentation position according to punctuation marks at the first segmentation position to obtain the second segmentation position; adjusts the second segmentation position based on the semantic relevance between the natural paragraph and the document content on both sides of the second segmentation position to obtain the document segmentation position of the local document, thereby achieving the division of the local document in combination with the preset word count, punctuation marks, paragraph position, and semantic relevance, and effectively improving the accuracy of document segmentation.

[0232] In addition, an embodiment of the present invention further proposes a storage medium, on which a document question and answer program is stored. When the document question and answer program is executed by a processor, the steps of the document question and answer method described above are implemented.

[0233] Reference Figure 5 , Figure 5 It is a structural block diagram of the first embodiment of the document question and answer device of the present invention.

[0234] like Figure 5 As shown, the document question-and-answer device proposed in the embodiment of the present invention includes:

[0235] The term receiving module 501 is used to receive the question term and document identification information input by the user, and obtain the document segment of the target document corresponding to the document identification information.

[0236] The semantic calculation module 502 is used to calculate the semantic relevance between the question terms and each of the document segments, and select the document segments to be input whose semantic relevance reaches a preset relevance from each of the document segments.

[0237] The data feedback module 503 is used to input the question terms and the document segment to be input into the pre-trained language model, so that the pre-trained language model obtains the answer to the question terms from the target document segment.

[0238] This embodiment receives the question terms and document identification information input by the user, and obtains the document segmentation of the target document corresponding to the document identification information; then calculates the semantic relevance between the question terms and each document segment, and selects the document segment to be input whose semantic relevance reaches the preset relevance from each document segment; finally, inputs the question terms and the document segment to be input into the pre-trained language model, so that the pre-trained language model generates the answer to the question terms based on the target document segmentation. This embodiment calculates the semantic relevance between the question terms and the document segment, and then inputs the question terms and the document segment to be input whose semantic relevance reaches the preset relevance into the pre-trained language model. The semantic relevance can reflect the degree of proximity between the question terms and the document segment. Compared with the prior art of inputting the entire document into the pre-trained language model, there is a situation where the answer cannot be generated accurately and efficiently. The above-mentioned device of this embodiment realizes accurate and efficient generation of the answer to the question terms by inputting the document segment whose semantic relevance of the question terms reaches the preset relevance into the pre-trained language model instead of inputting the entire document, and effectively improves the user experience.

[0239] As an implementation mode, the semantic calculation module 502 is also used to obtain the segmented word vector of each of the document segments and the question word vector of the question term through a preset vector model; calculate the vector distance between the question word vector and the segmented word vector; and determine the semantic relevance between the question term and each of the document segments based on the vector distance.

[0240] As an implementation mode, the semantic calculation module 502 is also used to sort each of the document segments according to the semantic relevance from high to low to obtain a sorting result; determine a cutoff ranking in the sorting result in which the semantic relevance reaches a preset relevance; select document segments from the sorting result in order of semantic relevance from high to low until the ranking of the selected document segment is as low as the cutoff ranking; and use the selected document segment as the document segment to be input.

[0241] As an implementation mode, the semantic computing module 502 is also used to obtain a number of training documents in a preset field, and construct training sentence samples based on the training documents; calculate the word vectors between each sentence in the training sentence samples; train the initial open source vector model through the training sentence samples and the word vectors to obtain a preset vector model.

[0242] As an implementation mode, the data feedback module 503 is also used to receive the answer fed back by the pre-trained language model, and determine whether the error between the answer and the answer required by the user meets the preset error condition; if the preset error condition is not met, an optimized document whose document type is related to the question term is obtained, and the preset vector model is optimized and trained according to the optimized document; when the error between the answer obtained by the preset vector model after optimization and the answer required by the user meets the preset error condition, the optimization is determined to be completed.

[0243] As an implementation mode, the data feedback module 503 is also used to obtain a new optimization document when the error between the answer obtained by the optimized pre-trained language model and the answer required by the user does not meet the preset error condition; and optimize the preset vector model through the new optimization document until the error between the answer obtained by the optimized preset vector model and the answer required by the user meets the preset error condition.

[0244] Based on the first embodiment of the document question and answer device of the present invention, a second embodiment of the document question and answer device of the present invention is proposed.

[0245] In this embodiment, the entry receiving module 501 is also used to determine whether the document identification information exists in a preset inverted list; if the document identification information exists, determine a target index matching the document identification information from the preset inverted list; and extract a document segment of the target document corresponding to the document identification information from the preset inverted list according to the target index.

[0246] As an implementation mode, the entry receiving module 501 is also used to obtain the target document corresponding to the document identification information if the document identification information does not exist; determine the target document segmentation position according to a preset document segmentation strategy; segment the document content of the target document according to the target document segmentation position to obtain the document segmentation of the target document.

[0247] Based on the above-mentioned second embodiment of the document question and answer device of the present invention, a third embodiment of the document question and answer device of the present invention is proposed.

[0248] In this embodiment, the entry receiving module 501 is also used to obtain a local document and determine the local document identification information of the local document; determine the document segmentation position of the local document according to a preset document segmentation strategy; segment the document content of the local document according to the document segmentation position to obtain the local document segment of the local document; and construct a preset inverted list based on the local document identification information and the local document segment.

[0249] As an embodiment, the entry receiving module 501 is also used to determine the first segmentation position for segmenting the local document based on a preset number of words; adjust the first segmentation position according to the punctuation marks at the first segmentation position to obtain the second segmentation position; adjust the second segmentation position based on the semantic relevance between the natural paragraph and the document content on both sides of the second segmentation position to obtain the document segmentation position of the local document.

[0250] As an implementation mode, the entry receiving module 501 is also used to determine whether the punctuation mark at the first segment position is a preset symbol; if it is not the preset symbol, the first segment position is adjusted to the preset symbol based on a preset word number range; and the adjusted first segment position is used as the second segment position.

[0251] As an implementation mode, the entry receiving module 501 is also used to determine whether the second segmentation position splits a single natural paragraph; if the single natural paragraph is split, the second segmentation position is adjusted to the end of the single natural paragraph to obtain a third segmentation position; the third segmentation position is adjusted according to the semantic relevance between the document contents on both sides of the third segmentation position to obtain the document segmentation position of the local document.

[0252] As an implementation mode, the entry receiving module 501 is also used to determine whether the semantic relevance between the document contents on both sides of the third segmentation position reaches a preset threshold; if the preset threshold is reached, the third segmentation position is adjusted so that the document contents on both sides are divided into the same document segment; and the adjusted third segmentation position is used as the segmentation position of the local document.

[0253] As an implementation mode, the two-side document content includes the front-side document content and the back-side document content, and the entry receiving module 501 is also used to calculate the first segmented word vector of the front-side document content through a preset vector model; calculate the second segmented word vector of the back-side document content through a preset vector model; calculate the two-side vector distance between the first segmented word vector and the second segmented word vector; and determine the semantic relevance between the front-side document content and the back-side document content based on the two-side vector distance.

[0254] As an implementation manner, the entry receiving module 501 is further configured to use the third segmentation position as the segmentation position of the local document if the preset threshold is not reached.

[0255] As an implementation mode, the entry receiving module 501 is further used to adjust the second segmentation position according to the semantic relevance between the document contents on both sides of the second segmentation position if the single natural paragraph is not split, so as to obtain the document segmentation position of the local document.

[0256] As an implementation mode, the entry receiving module 501 is also used to detect whether there are multiple document segments in each of the local document segments in which the target content is split into a single sentence; if there are multiple document segments in which the target content is split into a single sentence, the target content is divided into the same local document, and the target content is combined into the single sentence in the same local document.

[0257] The specific implementation of the document question-and-answer device of the present invention can refer to the above-mentioned method embodiments, which will not be described in detail here.

[0258] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0259] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0260] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0261] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A document question-answering method, characterized in that: The document question-answering method comprises the following steps: Receive the question terms and document identification information input by the user, and obtain the document segment of the target document corresponding to the document identification information; Calculating the semantic relevance between the question terms and each of the document segments, and selecting a document segment to be input whose semantic relevance reaches a preset relevance from each of the document segments; The question terms and the document segment to be input are input into a pre-trained language model, so that the pre-trained language model generates an answer to the question terms based on the target document segment.

2. The document question-answering method according to claim 1, characterized in that: The step of calculating the semantic relevance between the question terms and each of the document segments comprises: Obtaining the segment word vectors of each of the document segments and the question word vectors of the question terms through a preset vector model; Calculating the vector distance between the question word vector and the segment word vector; The semantic relevance between the question term and each of the document segments is determined according to the vector distance.

3. The document question-answering method according to claim 1, wherein: The step of obtaining the document segment corresponding to the target document of the document identification information comprises: Determine whether the document identification information exists in the preset inverted list; If the document identification information exists, determining a target index matching the document identification information from the preset inverted list; A document segment of a target document corresponding to the document identification information is extracted from the preset inverted list according to the target index.

4. The document question-answering method according to claim 3, characterized in that: After the step of determining whether the document identification information exists in the preset inverted list, the method further includes: If the document identification information does not exist, obtaining the target document corresponding to the document identification information; Determine the target document segmentation position according to a preset document segmentation strategy; The document content of the target document is segmented according to the target document segmentation positions to obtain the document segments of the target document.

5. The document question-answering method according to claim 3, characterized in that: Before the step of determining whether the document identification information exists in the preset inverted list, the method further includes: Acquire a local document and determine local document identification information of the local document; Determine the document segmentation position of the local document according to a preset document segmentation strategy; Segmenting the document content of the local document according to the document segmentation positions to obtain local document segments of the local document; A preset inverted list is constructed based on the local document identification information and the local document segment.

6. The document question-answering method according to claim 5, characterized in that: The step of determining the document segmentation position according to the preset document segmentation strategy includes: Determining a first segmentation position for segmenting the local document based on a preset word count; Adjust the first segment position according to the punctuation mark at the first segment position to obtain a second segment position; The second segment position is adjusted based on the semantic relevance between the natural paragraph and the document contents on both sides of the second segment position to obtain the document segment position of the local document.

7. The document question-and-answer method according to any one of claims 1 to 6, characterized in that: Before the step of obtaining the segment word vectors of each of the document segments and the question word vectors of the question terms through a preset vector model, the step further includes: Obtaining a number of training documents in a preset field, and constructing training sentence samples based on the training documents; Calculating word vectors between sentences in the training sentence sample; The initial open source vector model is trained using the training sentence samples and the word vectors to obtain a preset vector model.

8. A document question-and-answer device, characterized in that: The device comprises: The term receiving module is used to receive the question term and document identification information input by the user, and obtain the document segment of the target document corresponding to the document identification information; A semantic calculation module, used for calculating the semantic relevance between the question terms and each of the document segments, and selecting a document segment to be input whose semantic relevance reaches a preset relevance from each of the document segments; The data feedback module is used to input the question terms and the document segment to be input into the pre-trained language model, so that the pre-trained language model obtains the answer to the question terms from the target document segment.

9. A document question-and-answer device, characterized in that: The device comprises: a memory, a processor, and a document question and answer program stored in the memory and executable on the processor, wherein the document question and answer program is configured to implement the steps of the document question and answer method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores a document question and answer program, which, when executed by a processor, implements the steps of the document question and answer method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Document question and answer method and device, electronic equipment and computer storage medium

    CN120821819A

  • Question and answer method and related equipment

    CN121561026A