A document-oriented knowledge question answering method, device, equipment and medium

Combining slicing processing and vectorization processing with text generation models solves the shortcomings of traditional knowledge question and answer systems in semantic similarity measurement and document structure retention, achieving more accurate and efficient information acquisition, and improving user satisfaction and information reliability. sex.

CN117786066BActive Publication Date: 2024-09-06DARK MATTER ARTIFICIAL INTELLIGENT (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311709799.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-13
Publication Date
2024-09-06
Estimated Expiration
2043-12-13

AI Technical Summary

Technical Problem

Traditional document-oriented knowledge question and answer systems have deficiencies in semantic similarity measurement and document structure retention, resulting in low accuracy and affected information recall precision, especially when there are a large number of official documents and high content similarity.

Method used

Divide the document into smaller segments through slicing and vectorization, perform vectorization on each segment, calculate the similarity between the query statement and the target vector, extract the relevance information and input it into the text generation model to generate answers. Make sure to provide precise and relevant answers within the length limit.

Benefits of technology

It improves the accuracy and efficiency of the question and answer system, provides more accurate information acquisition and user satisfaction, saves users time in filtering information, and enhances the reliability and simplicity of information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117786066B
    Figure CN117786066B
Patent Text Reader

Abstract

The present application provides a document-oriented knowledge question-answering method, apparatus, device and medium, the method comprising: first, slicing the target document according to preset rules to obtain a paragraph and vectorizing it into a first vector. Then, vectorizing the query statement to obtain a second vector. The system selects a target vector with a high similarity to the second vector from the first vector, extracts the target features therein, and these features carry the correlation information with the query. Finally, the target features are input into a text generation model to generate answers related to the query. The present application can capture and utilize semantic relationship information more deeply, and improve the accuracy and efficiency of the question-answering system under length constraints.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a document-oriented knowledge question answering method, device, equipment and medium. Background Art

[0002] Intelligent question answering system is an important research direction in the field of artificial intelligence and natural language processing. Among them, the retrieval-based question answering system for frequently asked questions (FAQ) is the most widely used type. The core task of this type of system is to match the semantics of similar questions, that is, to measure the semantic similarity between the questions submitted by users and the standard questions in the FAQ library.

[0003] Traditional text matching methods, such as BM25 and vector space model VSM, mainly solve the problem of literal similarity, but due to the richness of Chinese meaning, these methods often have difficulty in accurately measuring the semantic similarity between sentences. Therefore, the basis for measuring the semantic similarity of sentences is to generate effective sentence vectors, map similar problems into a high-dimensional semantic space, and then define their similarity through measurement methods such as cosine similarity.

[0004] In document-oriented knowledge question-answering applications, question-answering systems that perform semantic retrieval based on vector similarity calculations and then combine them with generative large models generally have the following problems: due to the large number of official documents and the high similarity of their contents, the accuracy of similarity calculations is not high; official documents are sliced ​​by word count, and vector embedding will destroy the document structure, thus affecting the subsequent knowledge recall accuracy; although the text generation large model has outstanding semantic understanding and flexible response capabilities, for scenarios that require domain knowledge, the responses are unstable and have a high error rate, and are also subject to length (token) restrictions. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a document-oriented knowledge question answering method, apparatus, device and medium, which can improve the accuracy and efficiency of the question answering system under length constraints by more deeply capturing and utilizing semantic relationship information.

[0006] The technical solution of the embodiment of the present application is implemented as follows:

[0007] In a first aspect, an embodiment of the present application provides a document-oriented knowledge question answering method, the method comprising:

[0008] In response to an input operation on a target document, slicing the target document based on a preset slicing rule to obtain at least one segment, and performing a first vectorization process on each segment in the at least one segment to obtain at least one first vector;

[0009] In response to a query operation for the target document, performing a second vectorization process on the query statement to obtain a second vector corresponding to the query statement;

[0010] At least one target vector whose similarity with the second vector is greater than a similarity threshold is obtained from the at least one first vector, a target feature is extracted from the at least one target vector based on the second vector, and the target feature is input into a text generation model so that the text generation model answers the query statement, wherein the target feature carries relevance information, and the relevance information represents the relevance between the target feature and the query statement.

[0011] In a second aspect, an embodiment of the present application further provides a document-oriented knowledge question-answering device, the device comprising:

[0012] A slicing module, configured to respond to an input operation on a target document, slice the target document based on a preset slicing rule to obtain at least one segment, and perform a first vectorization process on each segment in the at least one segment to obtain at least one first vector;

[0013] A processing module, configured to respond to a query operation on the target document, perform a second vectorization process on the query statement, and obtain a second vector corresponding to the query statement;

[0014] An answer module is used to obtain at least one target vector whose similarity with the second vector is greater than a similarity threshold from the at least one first vector, extract a target feature from the at least one target vector based on the second vector, and input the target feature into a text generation model so that the text generation model answers the query statement, wherein the target feature carries relevance information, and the relevance information represents the relevance between the target feature and the query statement.

[0015] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to execute the document-oriented knowledge question and answer method described in any one of the first aspects.

[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the document-oriented knowledge question and answer method described in any one of the first aspects is executed.

[0017] The embodiments of the present application have the following beneficial effects:

[0018] Through the use of slicing and vectorization processing, the system can understand the content of the document more precisely and extract key information. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users time in screening information, but also improves the accuracy and reliability of information acquisition. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 is a flowchart of steps S101-S103 provided in an embodiment of the present application;

[0021] Figure 2 It is a flowchart of steps S201-S202 provided in an embodiment of the present application;

[0022] Figure 3 It is a flowchart of steps S301-S303 provided in an embodiment of the present application;

[0023] Figure 4 It is a flowchart of steps S401-S403 provided in an embodiment of the present application;

[0024] Figure 5 It is a structural diagram of a document-oriented knowledge question-answering device provided in an embodiment of the present application;

[0025] Figure 6 It is a schematic diagram of the composition structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0026] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of order, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0027] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0028] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0029] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0030] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0032] This patent specifically targets documents with the following format specifications. First, the document consists of elements such as serial number, confidentiality level and confidentiality period, urgency level, document issuing agency logo, document number, issuer, title, main recipient, body text, annex description, document issuing agency signature, date of issue, seal, notes, annexes, carbon copy recipients, document printing agency and printing date, page number, etc. Second, according to their positions, these elements can be further divided into the header (document head) part (the first 6 elements), the main body part (the middle 9 elements), and the footer (document tail) part (the last 3 elements). The header part is located at the upper part of the first page of the official document, generally occupying about 1 / 3 of the entire page. The main body part is located below the header part and above the footer part. The footer part is located at the lower end of the last page of the official document. Among them, the printing footer includes two elements: the document printing agency and the printing time.

[0033] In terms of format, the body text of the document is generally written horizontally, using the No. 3 Fangsong font, with 28 characters per line, 22 lines per page, a line spacing of 28.9 points, the first line of each paragraph indented by 2 characters, and each natural paragraph indented 2 characters to the left and aligned at the top when returning. The title of the body text is centered, generally in the form of "Letter from XX Unit on XXX" or "Letter on XXX", etc., using the No. 2 Xiaobiao Song font. The structure level ordinal numbers of the body text can be marked successively with "I.", "(I)", "1.", "(1)". Generally, the first layer is marked with boldface, the second layer with italics, and the third and fourth layers with Fangsong font.

[0034] Finally, the document includes 15 types of official documents, such as resolutions, decisions, orders, communiqués, announcements, notices, opinions, notifications, circulars, reports, requests for instructions, replies, motions, letters, and minutes, and each type of official document has specific writing specifications.

[0035] See Figure 1 , Figure 1 is a schematic flowchart of the steps S101 - S103 of the document-oriented knowledge Q&A method provided by the embodiment of the present application, and will be described in combination with Figure 1 the steps S101 - S103 shown.

[0036] Step S101, in response to an input operation for a target document, perform slicing processing on the target document based on a preset slicing rule to obtain at least one text segment, and perform first vectorization processing on each text segment in the at least one text segment to obtain at least one first vector;

[0037] Step S102, in response to a query operation for the target document, perform second vectorization processing on the query statement to obtain a second vector corresponding to the query statement;

[0038] Step S103, obtaining at least one target vector from the at least one first vector whose similarity with the second vector is greater than a similarity threshold, extracting a target feature from the at least one target vector based on the second vector, and inputting the target feature into a text generation model so that the text generation model answers the query statement, wherein the target feature carries correlation information, and the correlation information represents the correlation between the target feature and the query statement.

[0039] The above-mentioned document-oriented knowledge question-answering method, through the use of slicing processing and vectorization processing, enables the system to understand the document content more finely and extract key information at the same time. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users' time in screening information, but also improves the accuracy and reliability of information acquisition.

[0040] The above exemplary steps of the embodiments of the present application are described below respectively.

[0041] In step S101, in response to an input operation on a target document, the target document is sliced ​​based on a preset slicing rule to obtain at least one segment, and each segment in the at least one segment is first vectorized to obtain at least one first vector.

[0042] First, according to the preset slicing rules, the system slices the target document. This slicing process can be based on sentences, paragraphs, chapters or other preset document structure rules. The purpose of slicing is to divide the document into smaller and easier-to-process segments. After slicing, the system obtains at least one segment. Next, the system performs the first vectorization process on these segments. Vectorization is the process of converting non-numerical text data into numerical data, which makes the text data suitable for mathematical operations and model processing. In the first vectorization stage, each segment is converted into a vector, which is called the first vector. There are many vectorization methods, such as bag of words model, TF-IDF, word2vec, etc. These methods can encode vocabulary, semantics and other information in the text into numerical values ​​in the vector. After completing the first vectorization process, the system obtains at least one first vector, which represents the numerical representation of each segment in the target document. These vectors can be used for subsequent tasks such as text similarity calculation and information retrieval, so as to achieve more in-depth processing and utilization of the target document.

[0043] In step S102, in response to a query operation on the target document, a second vectorization process is performed on the query statement to obtain a second vector corresponding to the query statement.

[0044] When a user initiates a query operation for a target document, the system performs specific processing on the query statement. One of the key steps is the second vectorization process. Similar to the previous first vectorization process, the second vectorization process here also converts text data (this time the query statement) into a numerical form, that is, a vector. The purpose of this conversion is to enable the computer to understand and process the query for subsequent operations. Importantly, the second vectorization process mentioned here uses the same semantic model as the previous first vectorization process. This means that both the paragraphs in the target document and the user's query statements are vectorized through the same semantic model. The benefit of this is that it ensures that the document and the query statement are represented in the same semantic space, thereby improving the accuracy of subsequent similarity calculations and matching. After the second vectorization process, the query statement is converted into a vector, which is called the second vector. This vector can now be compared and matched with the first vector of the paragraph in the target document to find the content most relevant to the query.

[0045] In step S103, at least one target vector whose similarity with the second vector is greater than a similarity threshold is obtained from the at least one first vector, a target feature is extracted from the at least one target vector based on the second vector, and the target feature is input into a text generation model so that the text generation model answers the query statement, wherein the target feature carries relevance information, and the relevance information represents the relevance between the target feature and the query statement.

[0046] After completing the vectorization of the target document and query, the system begins to calculate the similarity of the vectors and extract features to find the most relevant content to the query and generate an answer. First, the system calculates the similarity between the second vector (the vector representation of the query) and all the first vectors (the vector representation of the paragraphs in the target document). The similarity calculation can be completed by methods such as cosine similarity, Euclidean distance, and Manhattan distance.

[0047] Among all the calculated similarities, the system will find the first vectors that are greater than the preset similarity threshold. These first vectors that have a sufficiently high similarity to the query are called target vectors. They represent the most relevant paragraphs in the target document to the query.

[0048] Next, based on the second vector (the vector representation of the query), the system extracts specific information or features from these target vectors, which are called "target features." These target features are not just simple representations of the documents, but contain some kind of relationship or correlation between them and the query.

[0049] Importantly, these target features carry relevance information. The relevance information describes the degree of relevance between the target feature and the query statement. This relevance can be based on semantics, context, or other specific rules.

[0050] Finally, these target features are input into a text generation model. The task of this model is to generate an answer based on these features and the query. The text generation model can be a pre-trained model, such as a Transformer-based model or other deep learning model, which can generate natural language text as an answer based on the input features and context.

[0051] The above method enables the system to understand and process text query requests, extract features that are highly correlated with the query statements, and generate answers in the text generation model, thereby realizing intelligent query answering functions.

[0052] In some embodiments, the semantic model used by the first vectorization process and the second vectorization process is the same.

[0053] Here, the semantic model used in the first vectorization process and the second vectorization process is the same, which means that the same semantic model is used for vectorization processing whether processing a segment in a target document or processing a query statement.

[0054] Using the same semantic model for both the first and second vectorizations can bring some advantages. First, it ensures that documents and queries are represented in the same semantic space. This means that they are mapped to the same vector space, enabling more accurate similarity calculations and matching.

[0055] Second, using the same semantic model can maintain consistency. Since both documents and query statements go through the same processing, they are semantically represented in a consistent way. This helps ensure that the relevance information used when extracting target features and generating answers is accurate and consistent.

[0056] Finally, this approach also helps to simplify the complexity of the system and improve efficiency. By using the same semantic model, the system can avoid using multiple different models at different stages, thereby reducing the switching and conversion overhead between models. This helps to speed up the response time of the system and reduce resource usage.

[0057] In the above manner, the first vectorization process and the second vectorization process use the same semantic model to bring more accurate, consistent and efficient text processing and query performance. This is a common practice in the field of text processing and natural language processing, which helps to improve the overall performance of the system and user experience.

[0058] In some embodiments, inputting the target feature into a text generation model so that the text generation model answers the query statement includes:

[0059] Based on the length restriction rule of the text generation model, answer features of a specified length are selected from the target features in the order of the relevance from high to low, and the answer features are input into the text generation model, so that the text generation model answers the query statement based on the answer features within the length restriction rule.

[0060] Existing text generation models are usually limited by length (token), which means that they can only handle a limited number of words or tokens when generating text.

[0061] This application uses length limits to encourage the model to generate more concise and accurate responses. Since the model can only use a limited number of words, it will learn to select the most important information and highlight the key points in the response. This helps avoid generating long, wordy, or irrelevant text, thereby improving the accuracy and readability of the response.

[0062] Secondly, the length limit can speed up the inference and generation of the model. Processing fewer words can reduce the computational burden of the model, thereby speeding up the time to generate answers. This is especially important for application scenarios that require fast responses, such as in real-time chat or online question-answering systems.

[0063] In addition, length limits also help the model better control the complexity and consistency of the generated answers. By limiting the number of words, the model can more easily maintain the topic and semantic consistency of the answers and avoid generating too much irrelevant information or noise. This helps ensure that the answers are more relevant to the query and provide more meaningful and coherent answers.

[0064] The above approach enables the model to generate more refined, accurate, and consistent answers, and improves the speed of inference and generation. Of course, in actual applications, it may be necessary to balance the relationship between length limit and answer quality according to specific needs and scenarios to obtain the best performance and user experience.

[0065] In some embodiments, see Figure 2 , Figure 2 It is a flowchart of steps S201-S202 provided in an embodiment of the present application. The slicing process of the target document based on preset slicing rules to obtain at least one paragraph can be achieved through steps S201-S202, which will be explained in combination with each step.

[0066] In step S201, a first type, a second type, a third type and a fourth type are preset, wherein the first type represents a declarative text segment, the second type represents a reference to external document content, the third type represents that there is a sequential logical relationship or a conditional logical relationship between the segments, and the fourth type represents that there is an ordered or unordered list between the segments.

[0067] In step S202, the target document is sliced ​​based on the first type, the second type, the third type and the fourth type to obtain at least one segment corresponding to the first type or the second type or the third type or the fourth type.

[0068] First, the system presets four types, namely Type 1, Type 2, Type 3 and Type 4. These four types represent different paragraphs or contents that may appear in the document.

[0069] The first type (string) represents declarative text segments, that is, those descriptive, narrative or explanatory text segments in the document.

[0070] The second type (link) represents a reference to external document content, that is, the content of other external documents referenced in the document.

[0071] The third type (block) indicates that there is a sequential logical relationship or a conditional logical relationship between the segments. There is a clear logical or conditional relationship between these segments.

[0072] The fourth type (slice) indicates that there is an ordered or unordered list in the paragraph, that is, a list content containing bullet points or numbers.

[0073] Then, the system slices the target document based on these four types. This process can be understood as the system traversing the target document, determining which type each part belongs to based on the document content, and then cutting it according to these types, and finally obtaining at least one segment corresponding to these types.

[0074] This slicing processing method can understand and process the different parts of the document more finely. Whether it is declarative text, external references, logical relationships or lists, they can all be accurately identified and cut out, providing a better foundation for subsequent processing.

[0075] In some embodiments, performing a first vectorization process on each of the at least one segment to obtain at least one first vector includes:

[0076] When the type of the paragraph is the first type, the second type, or the third type, the paragraph is subjected to a first vectorization process as a whole to obtain a first vector corresponding to the paragraph.

[0077] When the type of the segment is the fourth type, the segment is sliced ​​twice to obtain at least one slice segment, and a first vectorization process is performed on the at least one slice segment to obtain a first vector corresponding to each slice segment in the at least one slice segment.

[0078] The process differs as follows:

[0079] When the segment type is the first type (declarative text segment), the second type (external document content reference) or the third type (segments have sequential logical relationships or conditional logical relationships), the system will perform first vectorization on the entire segment. This process will convert the entire segment into a numerical vector, namely the first vector. This first vector can represent the semantics and information of the segment.

[0080] When the segment type is the fourth type (the segment contains an ordered or unordered list), the system will perform secondary slicing on the segment. This process can be understood as the system further cutting the segment containing the list into smaller slice segments. Then, the system will perform the first vectorization on these slice segments to obtain the first vector corresponding to each slice segment.

[0081] This first vectorization process, which is performed in different ways according to different types of paragraphs, can more accurately grasp the information in the document. For paragraphs of declarative text, external references, and logical relationships, overall vectorization can retain their complete semantics. For paragraphs containing lists, secondary slicing helps to grasp the information in them more carefully. These first vectors will provide an important data foundation for subsequent processing and querying.

[0082] In some embodiments, extracting a target feature from the at least one target vector based on the second vector comprises:

[0083] When the target vector is of the first type or the fourth type, directly using the target vector as the target feature;

[0084] When the target vector is of the second type, extract the corresponding document name in the target vector, and calculate the similarity between the document name and the second vector, and when the similarity meets the preset requirements, use the document name as the target feature;

[0085] When the target vector is of the third type, determine whether the target vector contains logical judgment. If it contains logical judgment, determine the corresponding logical content through the query parameters in the second vector, and use the logical content as the target feature; if it does not contain logical judgment or the corresponding logical content cannot be determined based on the query parameters, use the target vector as the target feature.

[0086] Here, when the target vector is of the first type (a declarative text paragraph) or the fourth type (a paragraph has an ordered or unordered list), the processing is relatively simple, and the target vector is directly used as the target feature.

[0087] When the target vector is of the second type (external document content reference), the system will perform more detailed processing. First, the corresponding document name in the target vector is extracted. Then, the system will calculate the similarity between the document name and the second vector. If the similarity meets the preset requirements, the document name will be used as the target feature.

[0088] When the target vector is of the third type (there is a sequential logical relationship or a conditional logical relationship between the paragraphs), the processing is more complicated. First, the system determines whether the target vector contains logical judgments. If it contains logical judgments, the system determines the corresponding logical content through the query parameters in the second vector and uses this logical content as the target feature. If it does not contain logical judgments, or the corresponding logical content cannot be determined based on the query parameters, the system directly uses the target vector as the target feature.

[0089] The above method enables the system to flexibly deal with different types of target vectors and accurately extract the required target features. For different types of target vectors, the system adopts different processing strategies to ensure that the information related to the query statement can be obtained to the greatest extent, improving the accuracy and efficiency of the query.

[0090] In some embodiments, see Figure 3 , Figure 3 It is a flowchart of steps S301-S303 provided in an embodiment of the present application. The method also includes steps S301-S303, which will be described in combination with each step.

[0091] In step S301, the target document is stored in a document library, in which other documents are also stored.

[0092] In step S302, in response to the knowledge question and answer request, at least one answer document is determined based on all documents in the document library.

[0093] In step S303, the matching degree between each answer document in the at least one answer document and the query statement is determined, and the query statement is answered based on the answer document with the highest matching degree.

[0094] Here, the target document is stored in a document library. This document library is a database or data warehouse for storing multiple documents, which also stores other documents. This design enables the system to accumulate and manage a large amount of document data, providing a data basis for subsequent knowledge question and answer functions. Secondly, when the system responds to a knowledge question and answer request, it will determine at least one answer document based on all the documents in the document library. This process can be understood as the system searching the document library for documents related to the query statement, which contain information that may contain answers.

[0095] Next, the system determines the degree of match between each of these answer documents and the query statement. The degree of match can be calculated based on semantic similarity, keyword matching, etc., to measure the relevance of the answer document to the query statement.

[0096] Finally, the system will answer the query based on the answer document with the highest matching degree. This process can be to extract key information from the answer document, or to generate the final answer based on the content of the answer document. In this way, the system can provide users with the most relevant and accurate answer to the query.

[0097] The above method has high efficiency and accuracy in document management and knowledge question answering, and can provide users with high-quality document storage and query answering services.

[0098] In some embodiments, see Figure 4 , Figure 4 It is a flowchart of steps S401-S403 provided in an embodiment of the present application. Each document in the document library includes a field tag. The method also includes steps S401-S403, which will be described in combination with each step.

[0099] In step S401, the question and answer data of the target user within a specified time period is obtained, and a preference tag of the target user is generated based on the question and answer data, wherein the preference tag represents the field of the question and answer of the target user.

[0100] In step S402, at least one domain tag corresponding to the target user within the specified time period is determined based on the preference tag, and frequently used documents of the target user are determined according to the at least one domain tag, wherein the frequently used documents are documents in the document library.

[0101] In step S403, the at least one answer document is determined from the common documents.

[0102] Here, each document in the document library not only includes content, but also has a domain tag attached. This domain tag is used to identify the professional field or subject to which the document belongs, such as medicine, technology, history, etc. This design helps to classify and manage documents more finely.

[0103] In order to provide a more personalized question-and-answer service, the method also involves the generation of user preference tags and the determination of frequently used documents. First, the system obtains the question-and-answer data of the target user within a specified time period. This data includes the questions asked by the user, the content of the answers, etc. Then, based on this data, the system generates the target user's preference tags. This preference tag is actually a summary of the areas that the user is concerned about and asks questions about.

[0104] Next, based on this preference tag, the system will determine at least one field tag corresponding to the target user within the specified time period. This process can be understood as the system inferring the fields that the user may be interested in based on the user's preferences. Then, based on these field tags, the system determines the target user's frequently used documents from the document library. These frequently used documents are documents that the user may frequently visit and refer to. Finally, when answering the user's question, the system will determine at least one answer document from these frequently used documents instead of searching from the entire document library. Doing so can not only improve query efficiency, but also provide more accurate answers that meet the user's interests and needs.

[0105] The above method combines the domain tags of the document library and the user's personalized preference tags to provide users with a more accurate and efficient knowledge question-and-answer service. This not only improves user satisfaction, but also helps improve the overall performance of the system.

[0106] In some embodiments, the method further comprises:

[0107] When a document in the document library has not been used within a preset time period, the document is determined as an expired document and the expired document is deleted;

[0108] Alternatively, when there are documents of the same type but of different versions in the document library, documents of the same type with lower versions are determined as expired documents, and the expired documents are deleted.

[0109] Here, when a document in the document library has not been used within a preset period of time, the system will identify the document as an expired document and delete it. This design helps reduce redundant and outdated documents in the document library, save storage space, and ensure that the content in the document library remains dynamic and updated. The preset period of time can be set according to actual needs, such as a few months or a few years.

[0110] Secondly, when there are different versions of the same document in the document library, the system will perform version management. Specifically, the system will identify the same documents with lower versions as expired documents and delete these expired documents. The purpose of this is to retain the latest and most relevant document versions to ensure that users can obtain the latest and most accurate information when querying and using. At the same time, version management also helps to reduce confusion and storage waste caused by redundant versions.

[0111] The above method can improve the management efficiency of the document library, ensure that the document content stored in the document library remains updated and valid, and thus improve the user experience when querying and using documents. Through expiration processing and version management, the system can continuously optimize the quality of the document library and provide users with more reliable and efficient services.

[0112] In summary, the embodiments of the present application have the following beneficial effects:

[0113] Through the use of slicing and vectorization processing, the system can understand the content of the document more precisely and extract key information. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users time in screening information, but also improves the accuracy and reliability of information acquisition.

[0114] Based on the same inventive concept, the embodiment of the present application also provides a document-oriented knowledge question and answer device corresponding to the document-oriented knowledge question and answer method in the first embodiment. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned document-oriented knowledge question and answer method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0115] like Figure 5 As shown, Figure 5 : is a schematic diagram of the structure of a document-oriented knowledge question answering device 500 provided in an embodiment of the present application. The document-oriented knowledge question answering device 500 includes:

[0116] The slicing module 501 is used to respond to an input operation on a target document, slice the target document based on a preset slicing rule to obtain at least one segment, and perform a first vectorization process on each segment in the at least one segment to obtain at least one first vector;

[0117] A processing module 502 is used to respond to the query operation for the target document, perform a second vectorization process on the query statement, and obtain a second vector corresponding to the query statement;

[0118] The answer module 503 is used to obtain at least one target vector from the at least one first vector whose similarity with the second vector is greater than a similarity threshold, extract a target feature from the at least one target vector based on the second vector, and input the target feature into a text generation model so that the text generation model answers the query statement, wherein the target feature carries correlation information, and the correlation information represents the correlation between the target feature and the query statement.

[0119] Those skilled in the art should understand that Figure 5The implementation functions of each unit in the document-oriented knowledge question answering device 500 shown can be understood by referring to the relevant description of the aforementioned document-oriented knowledge question answering method. Figure 5 The functions of each unit in the document-oriented knowledge question answering device 500 shown can be implemented by a program running on a processor, or by a specific logic circuit.

[0120] In a possible implementation, the device further includes:

[0121] A length restriction module is used to select answer features of a specified length from the target features in the order of the relevance from high to low based on the length restriction rule of the text generation model, and input the answer features into the text generation model, so that the text generation model answers the query statement based on the answer features within the length restriction rule.

[0122] In a possible implementation, the slicing module 501 includes:

[0123] A type determination module, used to preset a first type, a second type, a third type and a fourth type, wherein the first type represents a declarative text segment, the second type represents a reference to external document content, the third type represents that the segments have a sequential logical relationship or a conditional logical relationship, and the fourth type represents that the segments have an ordered or unordered list;

[0124] The type slicing module slices the target document based on the first type, the second type, the third type and the fourth type to obtain at least one segment corresponding to the first type or the second type or the third type or the fourth type.

[0125] In a possible implementation, the processing module 502 includes:

[0126] A first judgment module is used for, when the type of the segment is the first type, the second type, or the third type, performing a first vectorization process on the entire segment to obtain a first vector corresponding to the segment;

[0127] The second judgment module is used to, when the type of the segment is the fourth type, perform secondary slicing on the segment to obtain at least one sliced ​​segment, and perform a first vectorization process on the at least one sliced ​​segment to obtain a first vector corresponding to each sliced ​​segment in the at least one sliced ​​segment.

[0128] In a possible implementation, the answer module 503 extracts a target feature from the at least one target vector based on the second vector, including:

[0129] When the target vector is of the first type or the fourth type, directly using the target vector as the target feature;

[0130] When the target vector is of the second type, extract the corresponding document name in the target vector, and calculate the similarity between the document name and the second vector, and when the similarity meets the preset requirements, use the document name as the target feature;

[0131] When the target vector is of the third type, determine whether the target vector contains logical judgment. If it contains logical judgment, determine the corresponding logical content through the query parameters in the second vector, and use the logical content as the target feature; if it does not contain logical judgment or the corresponding logical content cannot be determined based on the query parameters, use the target vector as the target feature.

[0132] In a possible implementation, the answer module 503 further includes:

[0133] Storing the target document in a document library, where other documents are also stored;

[0134] In response to a knowledge question and answer request, determining at least one answer document based on all documents in the document library;

[0135] The matching degree between each answer document in the at least one answer document and the query statement is determined, and the query statement is answered based on the answer document with the highest matching degree.

[0136] In a possible implementation, each document in the document library includes a domain tag, and the answer module 503 further includes:

[0137] Acquire the question and answer data of the target user within a specified time period, and generate a preference tag of the target user according to the question and answer data, wherein the preference tag represents the field of the question and answer of the target user;

[0138] Determine at least one domain tag corresponding to the target user within the specified time period based on the favorite tag, and determine the target user's frequently used documents according to the at least one domain tag, wherein the frequently used documents are documents in the document library;

[0139] The at least one answer document is determined from the common documents.

[0140] In a possible implementation, the answer module 503 further includes:

[0141] When a document in the document library has not been used within a preset time period, the document is determined as an expired document and the expired document is deleted;

[0142] Alternatively, when there are documents of the same type but of different versions in the document library, documents of the same type with lower versions are determined as expired documents, and the expired documents are deleted.

[0143] The document-oriented knowledge question-answering device uses slicing and vectorization processing to enable the system to understand the document content more precisely and extract key information. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users time in screening information, but also improves the accuracy and reliability of information acquisition.

[0144] like Figure 6 As shown, Figure 6 The present invention provides a schematic diagram of the structure of an electronic device 600, wherein the electronic device 600 includes:

[0145] A processor 601, a storage medium 602 and a bus 603, wherein the storage medium 602 stores machine-readable instructions executable by the processor 601. When the electronic device 600 is running, the processor 601 communicates with the storage medium 602 via the bus 603, and the processor 601 executes the machine-readable instructions to perform the steps of the document-oriented knowledge question-answering method described in the embodiment of the present application.

[0146] In actual application, the components in the electronic device 600 are coupled together via the bus 603. It is understood that the bus 603 is used to realize the connection and communication between these components. In addition to the data bus, the bus 603 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as bus 603.

[0147] The above-mentioned electronic device uses slicing processing and vectorization processing to enable the system to understand the document content more finely and extract key information. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users time in screening information, but also improves the accuracy and reliability of information acquisition.

[0148] The embodiment of the present application also provides a computer-readable storage medium, which stores executable instructions. When the executable instructions are executed by at least one processor 601, the document-oriented knowledge question and answer method described in the embodiment of the present application is implemented.

[0149] In some embodiments, the storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface storage, an optical disk, or a compact disc read-only memory (CD-ROM); it can also be various devices including one or any combination of the above memories.

[0150] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0151] As an example, executable instructions may, but do not necessarily, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (for example, files storing one or more modules, subroutines, or code portions).

[0152] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.

[0153] The above-mentioned computer-readable storage medium uses slicing processing and vectorization processing to enable the system to understand the document content more finely and extract key information. In the query operation, through similarity calculation and feature extraction, the system can accurately find information that is highly relevant to the query statement, thereby providing users with more accurate answers. Finally, based on the length limit rule of the text generation model, the answer features are selected and the query statement is answered. Within the limited text length, highly relevant and accurate answers can be provided to users, ensuring the simplicity and effectiveness of the query answers, and improving the user's satisfaction and efficiency when using the query system. This targeted answer generation method not only saves users time in screening information, but also improves the accuracy and reliability of information acquisition.

[0154] In the several embodiments provided in the present application, it should be understood that the disclosed methods and electronic devices can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0155] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0156] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0157] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a platform server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0158] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A document-oriented knowledge question answering method, characterized in that: The method comprises: In response to an input operation on a target document, slicing the target document based on a preset slicing rule to obtain at least one segment, and performing a first vectorization process on each segment in the at least one segment to obtain at least one first vector; In response to a query operation for the target document, performing a second vectorization process on the query statement to obtain a second vector corresponding to the query statement; Acquire at least one target vector whose similarity with the second vector is greater than a similarity threshold from the at least one first vector, extract a target feature from the at least one target vector based on the second vector, and input the target feature into a text generation model so that the text generation model answers the query statement, wherein the target feature carries relevance information, and the relevance information represents the relevance between the target feature and the query statement; The slicing process of the target document based on a preset slicing rule to obtain at least one segment includes: The first type, the second type, the third type and the fourth type are preset, wherein the first type represents a declarative text segment, the second type represents a reference to external document content, the third type represents a sequential logical relationship or a conditional logical relationship between the segments, and the fourth type represents an ordered or unordered list between the segments; The target document is sliced ​​based on the first type, the second type, the third type and the fourth type to obtain at least one segment corresponding to the first type or the second type or the third type or the fourth type.

2. The method according to claim 1, characterized in that The semantic model used by the first vectorization process and the second vectorization process is the same.

3. The method according to claim 1, characterized in that The step of inputting the target feature into a text generation model so that the text generation model answers the query statement includes: Based on the length restriction rule of the text generation model, answer features of a specified length are selected from the target features in the order of the relevance from high to low, and the answer features are input into the text generation model, so that the text generation model answers the query statement based on the answer features within the length restriction rule.

4. The method according to claim 1, characterized in that The performing first vectorization processing on each of the at least one segment to obtain at least one first vector includes: When the type of the segment is the first type, the second type, or the third type, performing a first vectorization process on the entire segment to obtain a first vector corresponding to the segment; When the type of the segment is the fourth type, the segment is sliced ​​twice to obtain at least one slice segment, and a first vectorization process is performed on the at least one slice segment to obtain a first vector corresponding to each slice segment in the at least one slice segment.

5. The method according to claim 1, characterized in that The extracting a target feature from the at least one target vector based on the second vector comprises: When the target vector is of the first type or the fourth type, directly using the target vector as the target feature; When the target vector is of the second type, extract the corresponding document name in the target vector, and calculate the similarity between the document name and the second vector, and when the similarity meets the preset requirements, use the document name as the target feature; When the target vector is of the third type, determine whether the target vector contains logical judgment. If it contains logical judgment, determine the corresponding logical content through the query parameters in the second vector, and use the logical content as the target feature; if it does not contain logical judgment or the corresponding logical content cannot be determined based on the query parameters, use the target vector as the target feature.

6. The method according to claim 1, characterized in that The method further comprises: Storing the target document in a document library, where other documents are also stored; In response to a knowledge question and answer request, determining at least one answer document based on all documents in the document library; The matching degree between each answer document in the at least one answer document and the query statement is determined, and the query statement is answered based on the answer document with the highest matching degree.

7. The method according to claim 6, characterized in that Each document in the document library includes a domain tag, and the method further includes: Acquire the question and answer data of the target user within a specified time period, and generate a preference tag of the target user according to the question and answer data, wherein the preference tag represents the field of the question and answer of the target user; Determine at least one domain tag corresponding to the target user within the specified time period based on the favorite tag, and determine the target user's frequently used documents according to the at least one domain tag, wherein the frequently used documents are documents in the document library; The at least one answer document is determined from the common documents.

8. The method according to claim 1, characterized in that The method further comprises: When a document in the document library has not been used within a preset time period, the document is determined as an expired document and the expired document is deleted; Alternatively, when there are documents of the same type but of different versions in the document library, documents of the same type with lower versions are determined as expired documents, and the expired documents are deleted.

9. A document-oriented knowledge question-answering device, characterized in that: The device comprises: a slicing module, configured to respond to an input operation on a target document, slice the target document based on a preset slicing rule to obtain at least one segment, and perform a first vectorization process on each segment in the at least one segment to obtain at least one first vector; A processing module, configured to respond to a query operation on the target document, perform a second vectorization process on the query statement, and obtain a second vector corresponding to the query statement; an answering module, configured to obtain at least one target vector whose similarity with the second vector is greater than a similarity threshold from the at least one first vector, extract a target feature from the at least one target vector based on the second vector, and input the target feature into a text generation model so that the text generation model answers the query statement, wherein the target feature carries relevance information, and the relevance information represents the relevance between the target feature and the query statement; The slicing module includes: A type determination module, used to preset a first type, a second type, a third type and a fourth type, wherein the first type represents a declarative text segment, the second type represents a reference to external document content, the third type represents that the segments have a sequential logical relationship or a conditional logical relationship, and the fourth type represents that the segments have an ordered or unordered list; The type slicing module slices the target document based on the first type, the second type, the third type and the fourth type to obtain at least one segment corresponding to the first type or the second type or the third type or the fourth type.

10. The device according to claim 9, characterized in that The device also includes: A length restriction module is used to select answer features of a specified length from the target features in the order of the relevance from high to low based on the length restriction rule of the text generation model, and input the answer features into the text generation model, so that the text generation model answers the query statement based on the answer features within the length restriction rule.

11. The device according to claim 9, characterized in that The processing module comprises: A first judgment module is used for, when the type of the segment is the first type, the second type, or the third type, performing a first vectorization process on the entire segment to obtain a first vector corresponding to the segment; The second judgment module is used to, when the type of the segment is the fourth type, perform secondary slicing on the segment to obtain at least one sliced ​​segment, and perform a first vectorization process on the at least one sliced ​​segment to obtain a first vector corresponding to each sliced ​​segment in the at least one sliced ​​segment.

12. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate via the bus, and the processor executes the machine-readable instructions to execute the document-oriented knowledge question-answering method as described in any one of claims 1 to 8.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the document-oriented knowledge question answering method according to any one of claims 1 to 8 is executed.