A question and answer method based on file version relationship meta information
By segmenting files and extracting metadata, constructing file relationships and storing them quantitatively, and combining this with a large model to filter answers, the problem of accurate recall of multiple versions of files is solved, thus improving the accuracy of the question-answering system.
Patent Information
- Application Number
- CN202411401585.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Existing technologies struggle to accurately recall relevant content when processing versioned documents such as policies, leading to confusing answers or responses that do not meet user needs.
By acquiring and segmenting files, extracting key metadata, constructing relationships between files, and vectorizing and storing them in a database, answers are filtered using vector matching and large models, and accurate responses are provided based on context, time, and metadata.
It enables accurate recall and response for multiple versions of files, solves the problem of answer confusion, and improves the accuracy of the question-and-answer system.
Smart Images

Figure CN119248920B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of text question answering, and particularly relates to a question answering method based on file version relationship meta information. BACKGROUND
[0002] With the development of pre-training language model technology, large language models such as chatglm, Tongyi Qianwen and baichuan large model have appeared. In order to solve the vertical domain knowledge missing and illusion problem of large models, a series of question answering systems based on large language models and text form knowledge bases have emerged. The main way of question answering is to recall multiple file blocks related to the question from the knowledge base according to the question provided by the user. Then the recalled file blocks and the question provided by the user are taken as the input of the large language model to obtain the answer content.
[0003] However, in the actual use process, this kind of recall mode will have various problems, especially when answering questions about various files with version relationship such as policies. For some files with versions such as policies, there are the following problems: 1. There are different version problems. For example, policies and laws have different versions at different times, and users need to query the corresponding law based on the case according to the case judgment time; 2. The file has an explanation and supplementary explanation, which is also helpful for knowledge base question answering, and should be recalled according to the corresponding situation; 3. Part of the file is still in revision, and the revision statement only changes the content description, and there is no new file. This kind of file needs to be modified to the specific file content by operation; 4. The file has a valid period, and some files will be replaced by other new policies, so when recalling, two parts of the content block may be recalled at the same time, and there will be confusing information in the answer reference content. SUMMARY
[0004] In order to solve the above problems existing in the prior art, the application provides a question answering method based on file version relationship meta information, which comprises the following steps: acquiring a file, and performing segmentation processing on the file; extracting key meta information from the segmented file; constructing the relationship between each file according to the key meta information of each file; storing the relationship between the files in a knowledge base; vectorizing the segmented file, and storing the vectorized data in a vector database; acquiring a to-be-answered sentence, extracting the context time of the user question according to the context environment of the to-be-answered sentence; matching the corresponding vector block from the vector database in a vector matching mode, and recalling the matched vector block from the vector database; traversing the original file information in the recalled vector block, and obtaining the upper and lower relationships of the file according to the context time and the original file information; screening the upper and lower relationships of the file by using the trained large model according to the context time, and answering the question of the user according to the screening result.
[0005] Advantages of the present application:
[0006] The present application introduces a file relationship construction process for versioned file types on the basis of the original knowledge base question answering method, and constructs a basic file relationship meta information. When performing knowledge base question answering, the meta information screening and matching method is added in the previous recall process to make it more suitable for question answering in this scenario. The present application solves the problem of incorrect recall when answering multiple version files, and can answer questions more accurately. BRIEF DESCRIPTION OF DRAWINGS
[0007] Figure 1 The overall flowchart of the present application;
[0008] Figure 2 The text relationship construction flowchart of the present application;
[0009] Figure 3 The flowchart of storing the vectorized data in the vector database of the present application;
[0010] Figure 4 The user question reply flowchart of the present application. DETAILED DESCRIPTION
[0011] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0012] A question answering method based on file version relationship meta information, as shown in Figure 1 The method comprises: acquiring files, and performing segmentation processing on the files; extracting key meta information from the segmented files; constructing the relationship between each file according to the key meta information of each file; storing the relationship between the files in a knowledge base; vectorizing the segmented files, and storing the vectorized data in a vector database; acquiring a to-be-answered sentence, extracting the context time of the user question according to the context environment of the to-be-answered sentence; matching the corresponding vector block from the vector database in a vector matching manner, and recalling the matched vector block from the vector database; traversing the original file information in the recalled vector block, obtaining the upper and lower relationships of the file according to the context time and the original file information; screening the upper and lower relationships of the file according to the context time by using a trained large model, and answering the user's question according to the screening result.
[0013] In this embodiment, the key meta information of the file is extracted after the file is segmented, such as the policy name, the policy issuing agency, the policy effective time, the superior law, the policy replaced and abandoned law, and the like. The basic information of the explanation and revision is also extracted. After the key meta information of the file is extracted, the relationship between the corresponding files can be constructed according to the meta information.
[0014] Specifically, the file is segmented mainly according to the different file types, and the text content of the file is divided into multiple blocks to meet the length limit in the subsequent Embedding and recall. The following steps are adopted in the segmentation: 1) the file is first identified to generate a continuous text string stream and a corresponding title relationship. Different methods are adopted for identification according to the different original files. The formatted text (such as word, text, etc.) is directly parsed and read, and the non-formatted file (such as pdf, etc.) is identified based on the OCR model; 2) the text string is identified at the semantic level. The text is divided according to whether it is a title and the hierarchical relationship between the titles based on the title hierarchical relationship identified in the previous step. In addition to the title relationship identified in the first step, the hierarchical division is also processed according to specific rules (the specific rules are mainly for processing special file formats, such as chapters and sections in laws, etc.). The final generated result is a document tree (the internal node is a hierarchical title, and the leaf node is the main text); 3) the subsequent main text is divided according to whether its length is greater than a specific maximum parameter value. The division boundary is the natural division character of the paragraph or sentence, and the two segments can be optionally crossed.
[0015] The key meta information in the processed document tree is obtained by semantic analysis, such as the law or policy name, the superior law, and the abandoned law relationship. The model is required to process the text. The model can be a professional task group trained based on the training corpus, or a large semantic model with strong general ability. Each block of the document tree is processed by the model to identify the key information, such as the law name, the document number, the issuing agency, the issuing date, the effective date, the superior law, and the abandoned law.
[0016] As shown in Figure 2 , the relationship between the files is constructed according to the meta information of the files, and the relationship is stored. The version relationship, the superior relationship, and the replacement relationship between the files are mainly established, and the explanation file is also associated with the original file. For the revision statement file, a new file version is directly generated according to the revision statement in the revision statement file, and is added to the knowledge base.
[0017] As shown in Figure 3As shown, the file is chunked, vectorized and stored in the vector database based on the same way before. Specifically, it includes: chunking according to system configuration for each file; calling Embedding interface to generate vector for each chunk, and storing the vector into vector database.
[0018] As Figure 4 shown, when answering the user's question, first determine the time point required by the user's question through the context of the question, and the default is the current time. Then match the corresponding vector block through vector matching. According to the normal way, the top-k or fixed total file block length should be returned. Traverse the file meta information of the file block in turn, find out the corresponding original file, and find out the upper and lower relationship files of the file according to the previous relationship. According to the time point of the question, filter the meta files, select the files that meet the conditions (according to the performance requirements, you can directly use the time or use the large model to judge). According to the filtered file block, combine the question and answer prompt to give the large model an answer.
[0019] In this embodiment, in the knowledge base-based multi-round question and answer system, the input of the question and answer module is the first to N-1 round of dialogue text records, the question raised by the user in the Nth round, and K pieces of knowledge retrieved from the knowledge base. The output is the reply to the question raised by the user in the Nth round. Some of the user's intentions are very clear and complete, and the description is clear and complete. In this case, the probability that the knowledge retrieved from the knowledge base can answer the user's question is very high.
[0020] Large language model: Large language model (Large Language Models, LLMs) is an artificial intelligence technology that is trained on a large amount of text data to learn to understand and generate natural language. These models have strong expressive power and can understand and generate various types of text, such as questions, answers, articles, comments, etc.
[0021] Large language models are built based on deep learning technology, especially neural networks. They can capture semantic, syntactic and contextual information in text, and thus perform well in various natural language processing tasks.
[0022] Prompt: The prompt of a large model (such as a large-scale pre-training model, LLM) is a guiding text that instructs the model to generate a specific type of output. The prompt can be in the form of a question, instruction, example, etc., providing context and direction for the model.
[0023] Vector retrieval knowledge base: The enterprise knowledge base is usually a collection of all the knowledge, information and resources accumulated, organized and managed within an enterprise. It includes the enterprise's professional knowledge, experience, best practices, management systems, corporate culture and other aspects. Vector retrieval knowledge base refers to extracting text information from various formats of knowledge files in the enterprise knowledge base, and then performing data preprocessing such as merging, splitting and remerging to obtain a series of text segments. Then use the pre-trained vector model to get the fixed length vector corresponding to the text segment.
[0024] Knowledge base: The knowledge base is constructed from the source data of the knowledge base, usually implemented by a vector database, composed of vector indexes and multiple pieces of knowledge. Knowledge refers to the string of natural language strings from the source data of the knowledge base after data preprocessing.
[0025] Category structure information of knowledge base: refers to the way and method of classifying, organizing and displaying various knowledge contents in the knowledge base. Category and structure information helps enterprises effectively manage the knowledge base and improve the efficiency of employees in finding and obtaining knowledge. Category, structure information usually includes category division: logically divides the contents in the knowledge base to form categories of different themes and fields. Category division should be systematic, complete and practical to facilitate quick positioning of the required knowledge. Hierarchical structure: the hierarchical structure of the knowledge base refers to the organizational relationship between categories. The hierarchical structure can be tree-shaped, menu-style or other forms. Tag system: tags are a summary of knowledge base content that is representative, intuitive and easy to understand. Classification system: the classification system makes the knowledge base content have good distinguishability and correlation between categories.
[0026] Source data of knowledge base: The source data of the knowledge base refers to the enterprise's own structured, easy-to-operate, easy-to-use, easy-to-store, and inheritable knowledge cluster. These knowledge includes the enterprise's macro development plan, corporate culture, and micro knowledge content of each department, such as training materials, learning materials, customer materials, market materials, and other aspects. At the same time, the enterprise knowledge base also contains theoretical knowledge and factual data related to the field. These data are stored in formats such as word, excel, text documents, pictures, or saved on cloud servers.
[0027] Intelligent customer service system: The intelligent customer service system is a system developed on the basis of large-scale knowledge processing, which is suitable for large-scale knowledge processing, natural language understanding, knowledge management, automatic question and answer system and other technical industries. It can establish a fast and effective technical means based on natural language for communication between users and staff.
[0028] In the embodiment, the matching of the corresponding vector block from the vector database in the manner of vector matching includes: after the text is segmented into single blocks, the title information and the file name information are combined; a 1024-dimensional vector is generated by calling a text embedding model; a corresponding vector is generated by using a large model for the user's question; the vector database is queried according to the vector, and the corresponding Top-K document blocks with the highest similarity are returned.
[0029] In the embodiment, the filtering of the upper and lower relationships of the files includes: the corresponding meta information is found according to the recalled content; whether the block meets the relevant relationship is judged by using a large model for each text block according to the question and the context time of the question, and the block is directly filtered if it does not meet the relevant relationship; if the context time does not meet the condition, the real legal policy file existing in the context is introduced through the version relationship; finally, the remaining text blocks and the corresponding meta information are rearranged again, and Top-N is selected to provide the large model with the user's question and the user's question and answer history, and the large model generates an answer to the question.
[0030] The above embodiments further illustrate the purpose, technical solutions and advantages of the present application. It should be understood that the above embodiments are only preferred embodiments of the present application and are not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made to the present application within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A question and answer method based on file version relationship meta information, characterized by, The application relates to a method for answering a user question based on a large model, and relates to a method for answering a user question based on a large model. The method comprises the following steps: acquiring a file, performing segmentation processing on the file; extracting key meta information from the segmented file; constructing the relationship between the files according to the key meta information of each file; storing the relationship between the files in a knowledge base; vectorizing the segmented file and storing the vectorized data in a vector database; acquiring a to-be-answered question, extracting the context time of the user question according to the context environment of the to-be-answered question; matching the corresponding vector block from the vector database in a vector matching mode, and recalling the matched vector block from the vector database; traversing the original file information in the recalled vector block, obtaining the upper and lower relationships of the file according to the context time and the original file information; screening the upper and lower relationships of the file according to the context time by using the trained large model, and answering the question of the user according to the screening result. The segmentation processing on the file comprises the following steps: setting a text length threshold; identifying the file content to obtain continuous text strings and corresponding title relationships; performing semantic level identification on the text strings, and performing hierarchical division on the hierarchical relationships of the identified text according to the corresponding title relationships to generate a document tree, wherein the internal nodes of the document tree are hierarchical titles, and the leaf nodes are texts; acquiring the length of the leaf nodes, comparing the length of the leaf nodes with the text length threshold, if the length of the leaf nodes is greater than the set text length threshold, the leaf nodes are divided by using natural delimiting characters, otherwise, no processing is performed. The screening of the upper and lower relationships of the file comprises the following steps: finding the corresponding meta information according to the recalled content; judging whether the block meets the relevant relationship by using the large model according to the question and the context time of the question for each text block, and directly filtering the block which does not meet the relevant relationship; when the context time does not meet the condition, introducing the real legal policy file existing in the context through a version relationship; finally, rearranging the remaining text blocks and the corresponding meta information, selecting Top-N, combining the question of the user and the question answering history of the user to provide the large model, and generating an answer to the question by the large model. The extraction of the key meta information from the segmented file comprises the following steps: constructing a large language model, and training the large language model; extracting the key information of each node of the document tree by using the trained large language model to obtain the key information. The construction of the relationship between the files comprises the following steps: judging the hierarchical relationship of each file according to the extracted key information of each file, and obtaining the relationship between the files according to the hierarchical relationship. 2.The method of claim 1, wherein, The extraction of the context time of the user question comprises the following steps: acquiring the question time of the user, and comprehensively judging the context time of the question of the user according to the question time of the user and the question history of the user. 3.The method of claim 1, wherein, The matching of the corresponding vector block from the vector database in the vector matching mode comprises the following steps: merging the title information and the file name information after the text is segmented into single blocks; calling a text embedding model to generate a 1024-dimensional vector; generating a corresponding vector for the question of the user by using the large model; performing a vector database query according to the vector, and returning the corresponding Top-K document blocks with the highest similarity. 4.The method of claim 1, wherein, 5. The method of claim 1, wherein the method further comprises:
Citation Information
Patent Citations
Question and answer method and device, electronic equipment and storage medium
CN117708290A