Model knowledge base-based question and answer method and device, storage medium and electronic equipment

By using single-channel algorithm and k-means clustering algorithm in the intelligent question-ans system for document chunking, and combining the multi-channel recall mechanism, the accuracy of the intelligent question-and-answer system when complex questions and insufficient knowledge in specific fields is solved, which significantly improves the accuracy and efficiency of the question-and-answer system.

CN119719276AActive Publication Date: 2025-03-28SHAANXI YOUBAI INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411705779.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-28
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

The existing intelligent question-and-answer system has low feedback accuracy when dealing with complex and diverse questions, especially when there is little knowledge in a specific field, and pre-trained models are difficult to provide accurate answers. At the same time, the document chunking method is inefficient and has low accuracy, which affects the accuracy and efficiency of the Q&A system.

Method used

The question-and-answer method based on the model knowledge base is used to block the document through a single-channel algorithm and a k-means clustering algorithm, a semantic chunking list is constructed, and relevant content is obtained through a multiple recall mechanism, and input a generative intelligent question-and-answer system to generate answers.

Benefits of technology

It effectively solves the chunking problems of complex documents and the limitations of information recall, and improves the accuracy and efficiency of the generative intelligent question-and-answer system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719276A_ABST
    Figure CN119719276A_ABST
Patent Text Reader

Abstract

The invention relates to a question and answer method and device based on a model knowledge base, a storage medium and electronic equipment, and the method comprises the steps: constructing a block list of a sample document for each sample document based on the similarity of a read content and a block to which a previous content belongs; for each block list, traversing each block in the block list, using a k-means clustering algorithm to obtain clustering blocks according to the similarity between the content and the blocks not containing the content, and storing the clustering blocks in a knowledge base of a model knowledge base; the method comprises the following steps: receiving a question statement, and respectively obtaining keywords, semantics and a topic recall clustering block set matched with the question statement from a knowledge base; for each candidate content of the recall clustering block set, obtaining fusion correlation based on the frequency of the candidate content appearing in each recall clustering block set; and obtaining a spliced paragraph according to the candidate contents sorted according to the fusion correlation, inputting the spliced paragraph into the model knowledge base, and obtaining an answer. Question and answer accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a question-answering method, device, storage medium and electronic device based on a model knowledge base. Background Art

[0002] With the rapid development of artificial intelligence technology, intelligent question-answering systems have been widely used in various fields. Traditional intelligent question-answering systems mainly rely on predefined rules or retrieval methods to provide feedback on questions in order to improve the accuracy of feedback when dealing with complex and diverse questions. In recent years, generative question-answering systems based on pre-trained models, such as the Generative Pre-Trained Transformer (GPT) model and the Bidirectional Encoder Representations from Transformers (BERT) model, have shown stronger language understanding and generation capabilities, which significantly improves the accuracy of intelligent question-answering. However, for the generative intelligent question-answering system based on the pre-trained model, since the pre-trained model needs to be trained based on large-scale existing data (training data), for a specific field with less training data, the pre-trained model will be unable to provide accurate answers for the specific field based on the less training data in the specific field. Therefore, in the related art, a knowledge base of a specific field is introduced into the generative intelligent question-answering system to form a model knowledge base, thereby reducing the risk of incorrect answers in the generative question-answering system and improving the accuracy of the question-answering.

[0003] In a generative intelligent question-answering system (model knowledge base) that introduces a knowledge base, uploading documents to the knowledge base for processing is a key link. Especially when the document contains a large amount of complex information, how to effectively semantically segment the content in the document and accurately determine the boundaries of the semantic segments will directly affect the accuracy and efficiency of the question-answering system. The segmentation method of related technologies is usually based on fixed paragraph or sentence lengths or predefined rules. When processing documents with poor semantic coherence or frequent topic changes, it often fails to achieve ideal results, resulting in low accuracy of question-answering based on the model knowledge base based on segmented content. Summary of the invention

[0004] In view of this, the present invention provides a question-answering method, device, storage medium and electronic device based on a model knowledge base.

[0005] Specifically, the present invention is achieved through the following technical solutions:

[0006] According to a first aspect of the present invention, a question-answering method based on a model knowledge base is provided. The question-answering method based on a model knowledge base comprises:

[0007] For each sample document in the sample document set, read the content of the sample document in sequence according to a preset reading strategy, build a block list of the sample document, and in the block list, build a first block containing the first content read according to the preset reading strategy;

[0008] Based on a single-channel algorithm, the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs is sequentially calculated; if the similarity is greater than or equal to a preset first similarity threshold, the currently read content is placed in the block to which the previously read content belongs; if the similarity is less than the first similarity threshold, a new block is created, and the currently read content is placed in the newly created block;

[0009] For each block list, traverse the content in each block in the block list, use the k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content, and when the calculated similarity is greater than or equal to a preset second similarity threshold, assign the content again to the block corresponding to the calculated similarity to obtain clustered blocks, which are stored in the knowledge base of the model knowledge base;

[0010] Receive a question statement input by a user, and based on the question statement, obtain a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question statement from the knowledge base of the model knowledge base;

[0011] Obtain candidate content included in the keyword recall cluster block set, the semantic recall cluster block set, and the topic recall cluster block set, and for each candidate content, obtain the fusion relevance of the candidate content based on the frequency of occurrence of the candidate content in each recall cluster block set;

[0012] The candidate contents are sorted according to their fusion relevance, and the sorted candidate contents are spliced ​​to obtain a spliced ​​paragraph. The spliced ​​paragraph is input into the generative intelligent question-answering system in the model knowledge base to obtain an answer corresponding to the question statement.

[0013] The model knowledge base-based question-answering method in this technical solution constructs a block list of adjacent paragraph semantics through the similarity based on the single-channel algorithm, and then uses the k-means clustering algorithm to calculate the similarity of the block list, constructs clustered blocks of separated paragraph semantics, and then recalls them based on the multi-way recall mechanism and inputs them into the generative intelligent question-answering system. It can effectively solve the block problem of complex documents and the limitations of information recall, and improve the accuracy of the generative intelligent question-answering system.

[0014] According to a second aspect of the present invention, a question-answering device based on a model knowledge base is provided. The question-answering device based on the model knowledge base comprises:

[0015] A block list building module is used to read the content of each sample document in the sample document set in sequence according to a preset reading strategy, build a block list of the sample document, and build a first block containing the first content read according to the preset reading strategy in the block list;

[0016] A block processing module, for sequentially calculating the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs based on a single-channel algorithm, and if the similarity is greater than or equal to a preset first similarity threshold, placing the currently read content in the block to which the previously read content belongs; if the similarity is less than the first similarity threshold, creating a new block and placing the currently read content in the newly created block;

[0017] A block clustering module is used to traverse the content of each block in each block list, and use a k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content. When the calculated similarity is greater than or equal to a preset second similarity threshold, the content is again assigned to the block corresponding to the calculated similarity to obtain clustered blocks, which are stored in the knowledge base of the model knowledge base;

[0018] A block recall module is used to receive a question statement input by a user, and based on the question statement, obtain a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question statement from the knowledge base of the model knowledge base;

[0019] A fusion processing module is used to obtain candidate content included in the keyword recall cluster block set, the semantic recall cluster block set and the theme recall cluster block set, and for each candidate content, based on the frequency of occurrence of the candidate content in each recall cluster block set, obtain the fusion relevance of the candidate content;

[0020] The answer acquisition module is used to sort the candidate contents according to their fusion relevance, splice the sorted candidate contents to obtain a spliced ​​paragraph, input the spliced ​​paragraph into the generative intelligent question-answering system in the model knowledge base, and obtain the answer corresponding to the question statement.

[0021] According to a third aspect of the present invention, there is provided a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the question-answering method based on a model knowledge base in any possible implementation of the first aspect.

[0022] According to a fourth aspect of the present invention, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the question-answering method based on the model knowledge base in any possible implementation of the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0025] Figure 1 A schematic diagram of a flow chart of a question-answering method based on a model knowledge base provided in an embodiment of the present invention;

[0026] Figure 2 Another schematic diagram of a process for obtaining a semantic recall clustering block set in a question-answering method based on a model knowledge base provided in an embodiment of the present invention;

[0027] Figure 3 A schematic diagram of a question-answering device based on a model knowledge base provided by an embodiment of the present invention;

[0028] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] In the related art, the generative intelligent question answering system (model knowledge base) based on the pre-trained model and knowledge base has the following two problems:

[0031] 1. When uploading segmented documents, the segmentation efficiency of the document content is low and the segmentation accuracy is not high. Before updating the document content in the knowledge base, the uploaded document needs to be parsed, and then the content of the parsed document is segmented according to the pre-set rule logic, and the obtained segments are converted into vectors and stored in the vector database in the knowledge base. Among them, the segment size, that is, the accuracy of the segmentation, has a significant impact on the accuracy of the question and answer of the generative intelligent question and answer system. Reasonable segmentation can ensure that the generative intelligent question and answer system maintains efficient semantic understanding and accurate answers when processing complex documents, while unreasonable segmentation may lead to semantic loss or semantic confusion. For example, if the segment is too large, a single segment may contain multiple topics or complex semantic structures, making it difficult for the generative intelligent question and answer system to extract the most relevant part of the question when answering questions, resulting in vague or inaccurate answers. If the segment is too small, the semantic context may be destroyed and scattered in multiple segments, so that the generative intelligent question and answer system may not be able to obtain sufficient semantic information when answering questions, thereby affecting the accuracy and coherence of the answer. Therefore, how to aggregate semantically coherent and similar paragraphs into one chunk is the key to processing document chunking.

[0032] 2. Contextual block recall is inaccurate and incomplete. Generative intelligent question-answering systems have been widely used in information retrieval, knowledge question-answering and other fields. However, when dealing with diverse and complex problems, traditional single recall strategies often fail to fully utilize the rich information in the knowledge base, resulting in low accuracy of question-answering results. In the prior art, single recall strategies rely only on keyword matching or semantic similarity to recall text blocks, and therefore, are difficult to meet the needs of different users and multi-level information needs in complex contexts. Among them, the recall calculated by the correlation between the question and the text block has a great impact on the final answer. A single path may not be able to accurately and comprehensively capture all relevant information in the question and document, resulting in some valid information being omitted. Different recall paths have different definitions of relevance, and a single path may not be able to fully meet the user's intent, resulting in inaccurate retrieval results.

[0033] In this embodiment, it is proposed to combine the Single-Pass algorithm with the K-means clustering algorithm. After the document is initially divided into blocks using the Single-Pass algorithm, the K-means clustering algorithm is used to perform fine-grained semantic matching and clustering on the block content obtained after each initial block. Therefore, on the basis of the initial block, the content of each block is updated, and the semantically similar but non-continuous and cross-document paragraphs in the content of each block are aggregated into one block, so as to obtain more accurate semantic block content.

[0034] See also Figure 1The embodiment of the present invention provides a question-answering method based on a model knowledge base, which may include the following steps:

[0035] S101, for each sample document in the sample document set, read the content of the sample document in sequence according to a preset reading strategy, build a block list of the sample document, and in the block list, build a first block containing the first content read according to the preset reading strategy;

[0036] In this embodiment, as an optional embodiment, the pre-set reading strategy includes but is not limited to: reading by sentence, reading by paragraph, reading by chapter, etc. Taking the pre-set reading strategy of reading by paragraph as an example, for each sample document, starting from the beginning of the document, the document is read sequentially in units of paragraphs, that is, starting from the beginning of the document, the content in the document is read paragraph by paragraph.

[0037] In this embodiment, as an optional embodiment, an empty block list is created, that is, an empty list (blocks) is initialized to store each block of the document. Each sample document (document) corresponds to a block list.

[0038] In this embodiment, as an optional embodiment, if the sample document contains non-text content, such as a picture or a video, the method further includes:

[0039] For the pictures in the sample documents, the cogvlm2-llama3-chinese-chat-19B model is used to generate picture-based text descriptions. Each picture name contains a paragraph of picture text descriptions corresponding to each picture.

[0040] S102, based on a single-channel algorithm, sequentially calculating the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs, if the similarity is greater than or equal to a preset first similarity threshold, placing the currently read content in the block to which the previously read content belongs, if the similarity is less than the first similarity threshold, creating a new block, and placing the currently read content in the newly created block;

[0041] In this embodiment, a similarity threshold is set. The similarity threshold is used to determine whether two paragraphs should be classified into the same block or different blocks. By adjusting the size of the similarity threshold, the size of the block can be adjusted.

[0042] In this embodiment, taking the pre-set reading strategy of reading by paragraph as an example, the Single-Pass algorithm is used to perform preliminary block division of the document, and the paragraphs in the document are processed sequentially, so as to distribute the paragraphs in the document to different blocks. Specifically, based on the Single-Pass algorithm of similarity, the paragraphs in the document are sequentially scanned, and the similarity between the scanned paragraphs and each block in the block list is calculated, and according to the preset first similarity threshold, if the similarity is greater than or equal to the first similarity threshold, the scanned paragraph is classified into the block corresponding to the similarity, that is, the scanned content is classified into the existing block, and if the similarity is less than the first similarity threshold, a new block is dynamically created, and the scanned paragraph is classified into the dynamically created block. As another optional embodiment, the document can also be divided into blocks based on sentences, which is not limited in this embodiment.

[0043] In this embodiment, assuming that the sample document set contains 2 sample documents, 2 corresponding block lists are constructed. The first sample document uses the Single-Pass algorithm and is divided into 2 blocks through the similarity algorithm and is placed in the first block list. The second document uses the Single-Pass algorithm and is divided into 3 blocks through the similarity algorithm and is placed in the second block list.

[0044] In this embodiment, as an optional embodiment, based on a single-channel algorithm, the similarity between the content currently read according to the reading strategy and the blocks to which the content previously read according to the reading strategy belongs is sequentially calculated, including:

[0045] Input the currently read content into the text vector representation model to obtain the text vector corresponding to the currently read content;

[0046] Extracting each read content in the block to which the previously read content belongs, inputting the content into the text vector representation model, and obtaining the block vector of the block to which the previously read content belongs;

[0047] Using a single-pass algorithm, the cosine similarity between the text vector and the block vector is calculated.

[0048] In this embodiment, a paragraph is taken as an example to calculate the similarity of paragraphs in a document. As an optional embodiment, based on the paragraphs read sequentially, the similarity between the paragraph and the block to which the previous paragraph belongs in the block list is calculated.

[0049] In this embodiment, as an optional embodiment, for the currently read paragraph, record it as paragraph S, and calculate the similarity between paragraph S and the block to which the previous paragraph of the current paragraph in the block list belongs.

[0050] In this embodiment, as an optional embodiment, the text vector representation model includes but is not limited to: a large Chinese corpus (text2vec-large-chinese) model.

[0051] In this embodiment, the blocks are divided based on the cosine similarity and the first similarity threshold. As an optional embodiment, the cosine similarity between the current paragraph S and the block B to which the previous paragraph belongs is calculated. If the cosine similarity is greater than or equal to the first similarity threshold, the current paragraph S is classified into the block B. If the cosine similarity is less than the first similarity threshold, a new block C is created in the block list, and the current paragraph S is placed in the block C.

[0052] In this embodiment, as an optional embodiment, the method further includes:

[0053] After placing the currently read content in the block to which the previously read content belongs, updating the block vector of the block based on the text vector representation model;

[0054] After the currently read content is placed in the newly created block, the text vector of the currently read content is written into the newly created block as a block vector.

[0055] In this embodiment, taking a paragraph as an example, the content stored in the block is updated according to the inserted paragraph: if paragraph S is included in the existing block B, the vector representation (vector) of the block is updated according to the text vector representation model to reflect the newly added paragraph content. If paragraph S is included in a new block, for example, in a newly created new block C, the new block C is added to the block list blocks, and the vector representation of the new block C is obtained.

[0056] In this embodiment, after the current paragraph is processed, the next paragraph of the document is processed, and similarity calculation and paragraph classification into blocks are repeated until all paragraphs in the document are processed. After all paragraphs in the document are processed, the block list blocks corresponding to the document contains the blocks of the document, and each block represents the paragraph content in the document that has a certain consistency in semantics or subject.

[0057] In this embodiment, after the document is initially divided into blocks using the Single-Pass algorithm, each block includes a number of adjacent paragraphs. These paragraphs are considered to be semantically related and are therefore classified into the same block. Each block represents a semantic unit or topic fragment in the document.

[0058] S103, for each block list, traverse the content in each block in the block list, use the k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content, and when the calculated similarity is greater than or equal to a preset second similarity threshold, assign the content again to the block corresponding to the calculated similarity to obtain clustered blocks, and store them in the knowledge base of the model knowledge base;

[0059] In this embodiment, each content included in the block is a content unit read according to the content of the reading strategy. After the preliminary block division using the Single-Pass algorithm, adjacent semantically similar paragraphs can be grouped into one block, but non-adjacent but semantically related paragraphs cannot be placed in one block. Therefore, in this embodiment, after the document is preliminarily divided into blocks using the Single-Pass algorithm, on the basis of these blocks, the k-means algorithm is used to fine-tune the clustering of the above blocks for the sentences or paragraphs in the preliminary blocks, so that non-adjacent semantically related paragraphs can be clustered in one block.

[0060] In this embodiment, as an optional embodiment, the content in each block in the block list is traversed, and the similarity between the content and all blocks that do not contain the content is calculated using the k-means clustering algorithm, including:

[0061] A11, determining the number of clusters according to the number of blocks included in the block list;

[0062] In this embodiment, the number of clusters K is selected, where the value of K is the number of blocks (number of blocks) obtained based on the Single-Pass algorithm.

[0063] A12, construct several initial clusters for clustering, each block corresponds to an initial cluster center;

[0064] In this embodiment, K initialization clusters are constructed, and K blocks are used as cluster centers of the initialization clusters.

[0065] A13, traverse the initialization clusters, extract the target content from the initialization clusters, and use the k-means clustering algorithm to calculate the similarity between the target content and all the initialization clusters that do not contain the target content.

[0066] In this embodiment, for each paragraph, the similarity between the paragraph and all the initialization clusters that do not contain the paragraph is calculated. Based on a preset second similarity threshold, if the calculated similarity is greater than or equal to the second similarity threshold, the paragraph is reallocated to the initialization cluster corresponding to the calculated similarity while keeping the block corresponding to the paragraph unchanged, until all paragraphs are involved in the similarity calculation.

[0067] In this embodiment, if three initial blocks are obtained based on the Single-Pass algorithm, namely initial block A, initial block B and initial block C, K-means clustering is performed with the three initial blocks as cluster centers, and the paragraphs in initial block A are respectively calculated for similarity with initial block B and initial block C. If the similarity is greater than the second similarity threshold, the paragraph is placed in the corresponding block. If the similarity is less than the threshold, it is unchanged.

[0068] In this embodiment, in order to focus the content theme in a block as much as possible, as an optional embodiment, after the content is redistributed to the blocks corresponding to the calculated similarities, the method further includes:

[0069] In the case where the content is reallocated to the block corresponding to the calculated similarity, the block vector corresponding to the block is kept unchanged until the initialization cluster is traversed, and the block vector corresponding to the block is updated based on the content contained in each block.

[0070] In this embodiment, when performing K-means clustering, the block center is not updated. After the current paragraph in the initial block A is processed, the block vectors corresponding to the three updated cluster centers are respectively the same as the block vectors corresponding to the initial block A, the initial block B and the initial block C. The next paragraph in the initial block A is read and the same processing is performed until the paragraph in the initial block C is read. After clustering is completed, the block vector is updated according to the clustered blocks.

[0071] In this embodiment, the preliminary block results obtained by the Single-Pass algorithm are used as the clustering center of the k-means algorithm, and the k-means clustering algorithm clusters all paragraphs in the document. Using the k-means clustering algorithm, paragraphs that are not in the same document but have similar content semantics can be clustered together, thereby realizing cross-document semantic connectivity analysis.

[0072] In this embodiment, by combining the Single-Pass algorithm with the k-means algorithm, the paragraph content of the document is semantically segmented, which can not only consider the semantic coherence of the paragraph order, but also take into account the semantic correlation between non-adjacent paragraphs. Non-adjacent semantically related paragraphs are aggregated together, and answers can be generated more accurately for large-scale model knowledge base question and answer situations where the span of recalled content is relatively large.

[0073] In this embodiment, it should be noted that, for the question-answering method based on the model knowledge base in this implementation, steps S101 to S103 only need to be executed once.

[0074] In this embodiment, in the knowledge base, each document corresponds to a block list. As an optional embodiment, when the blocks obtained by K-means clustering are transferred to the knowledge base for storage, the same or similar documents can be processed according to a pre-set storage strategy, which will not be described in detail in this embodiment.

[0075] S104, receiving a question statement input by a user, and based on the question statement, respectively acquiring a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question statement from the knowledge base of the model knowledge base;

[0076] In this embodiment, as an optional embodiment, obtaining a keyword recall clustering block set matching the question sentence includes:

[0077] A21, for each cluster block in the knowledge base of the model knowledge base, extract the content corresponding to the cluster block, remove stop words and perform word segmentation processing to obtain a text block corresponding to the cluster block;

[0078] A22, based on word frequency-inverse document frequency, extract keywords from the text block, vectorize the extracted keywords, and obtain the candidate keyword vector representation of the text block;

[0079] A23, after removing stop words and performing word segmentation processing on the question sentence, keywords are extracted, and the extracted keywords are vectorized to obtain a vector representation of the question keywords;

[0080] A24, based on the similarity between the question keyword vector representation and the candidate keyword vector representation of each text block, recall the text blocks that meet the similarity strategy to obtain the sorted keyword recall cluster block set.

[0081] In this embodiment, firstly, stop words are removed from the cluster blocks, and the Jieba word segmenter is used to perform word segmentation to obtain text blocks. The term frequency-inverse document frequency (TF-IDF) method is used to extract keywords from the text blocks, and a candidate keyword vector representation of the text block is generated.

[0082] For the question sentences (user query sentences) submitted by the user, stop words are removed, the Jieba word segmenter is used to segment the words, the part-of-speech is tagged, nouns, verbs, adjectives and numerals are extracted as keywords, and the question keyword vector representation of the question sentence is obtained.

[0083] The question keyword vector representation of the question sentence is used to calculate the cosine similarity with the candidate keyword vector representation of each text block to obtain the correlation between the question sentence and each text block.

[0084] In this embodiment, text blocks whose similarity is greater than a third similarity threshold are recalled. In this embodiment, as an optional embodiment, the third similarity threshold is set to 0.7, thereby completing the recall of keyword text blocks. Multiple recalled text blocks form a keyword recall cluster block set.

[0085] In this embodiment, as an optional embodiment, obtaining a semantic recall clustering block set matching the question sentence includes:

[0086] A31, for each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale first text vector model, calculating the semantic similarity between the cluster block and the question sentence, obtaining the cluster block that meets the first semantic similarity threshold, and obtaining a first related text block set;

[0087] A32, for each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale second text vector model, calculating the semantic similarity between the cluster block and the question sentence, obtaining cluster blocks that meet the second semantic similarity threshold, and obtaining a second related text block set, wherein the number of cluster blocks included in the first related text block set is the same as the number of cluster blocks included in the second related text block set;

[0088] In this embodiment, cluster blocks that meet the requirements are sorted in order of similarity from high to low, to obtain a first related text block set and a second related text block set.

[0089] A33, using a pre-trained first re-arranged text vector representation model, re-arrange the clustered blocks sorted in the first related text block set to obtain a first related re-arranged text block set;

[0090] A34, using a pre-trained second re-arranged text vector representation model, re-arrange the clustered blocks sorted in the second relevant text block set to obtain a second relevant re-arranged text block set;

[0091] A35, cross-calculating semantic relevance based on the difference set of the first relevant re-ordered text block set and the second relevant re-ordered text block set, re-ordering the union of the first relevant re-ordered text block set and the difference set based on the cross-calculated semantic relevance to obtain the first relevant re-ordered text block set, and re-ordering the union of the second relevant re-ordered text block set and the difference set to obtain the second relevant re-ordered text block set;

[0092] A36, according to a preset overall sorting strategy, the first relevant re-sorted text block set and the second relevant re-sorted text block set are overall sorted to obtain a sorted semantic recall clustering block set.

[0093] In this embodiment, semantic recall adopts a multi-path and multi-level semantic cross-recall strategy to achieve more accurate semantic recall. Using two pre-trained large-scale text vector models, the semantic similarity between the user query statement and the clustered blocks in the knowledge base is calculated respectively, and the first n relevant text blocks, i.e., the first relevant text block set and the second relevant text block set, are obtained respectively. Then, the corresponding pre-trained two rearranged text vector representation models are used to perform secondary correlation calculation and sorting on the vector corresponding to the user query statement and the n relevant text blocks obtained above, to achieve precise sorting, and obtain the first relevant re-ordered text block set and the second relevant re-ordered text block set. The semantic relevance of the difference set of the two recalled re-ordered text block sets is then cross-calculated and sorted as a whole. Finally, the text block relevance scores obtained by the two-way calculation are averaged and sorted to obtain the semantic recall clustered block set.

[0094] In this embodiment, as an optional embodiment, the pre-trained large-scale first text vector model includes but is not limited to: bge-large-zh text vector representation model, the pre-trained large-scale second text vector model includes but is not limited to: bce-embedding-base text vector representation model, the pre-trained first rearrangement text vector representation model includes but is not limited to: bge_reranker text vector representation model, and the pre-trained second rearrangement text vector representation model includes but is not limited to: bce_reranker text vector representation model. Specifically, the bge-large-zh text vector representation model and the bce-embedding-base text vector representation model are used to perform the first semantic relevance calculation and sorting respectively. Then, the bge_reranker text vector representation model and the bce_reranker text vector representation model are used to perform the second semantic relevance calculation and sorting respectively. Then, the semantic relevance of the difference sets in the two recalled text blocks is cross-calculated and sorted as a whole. Finally, the text block relevance scores obtained by the two-way calculation are averaged and sorted.

[0095] Figure 2 Another flow chart of obtaining a semantic recall clustering block set in a question-answering method based on a model knowledge base provided by an embodiment of the present invention. Figure 2 As shown, the method includes:

[0096] S201, using bge, calculating the semantic similarity between each cluster block in the knowledge base and the question statement;

[0097] In this embodiment, the bge-large-zh text vector representation model is referred to as bge for short.

[0098] S202, obtaining cluster blocks A, cluster blocks B, cluster blocks C, and cluster blocks D that meet a first semantic similarity threshold, and obtaining a first related text block set;

[0099] In this embodiment, as an optional embodiment, the number of cluster blocks that meet the first semantic similarity threshold is 4, which are cluster block A (abbreviated as A), cluster block B (abbreviated as B), cluster block C (abbreviated as C) and cluster block D (abbreviated as D) arranged in sequence, forming the first related text block set.

[0100] S203, using bge_reranker, calculating the second semantic similarity between each cluster block in the first related text block set and the question sentence;

[0101] S204, reordering the clustered blocks in the first related text block set according to the second semantic similarity;

[0102] In this embodiment, the order of the reordered first related text block set is: B, A, D, C.

[0103] S205, using bce, calculating the second semantic similarity between each cluster block in the knowledge base and the question sentence;

[0104] In this embodiment, the bce-large-zh text vector representation model is referred to as bce.

[0105] S206, obtaining cluster blocks A, cluster blocks B1, cluster blocks C, and cluster blocks D1 that meet a first semantic similarity threshold, and obtaining a second related text block set;

[0106] S207, using bce_reranker, calculating the third semantic similarity between each cluster block in the second relevant text block set and the question sentence;

[0107] S208, reordering the clustered blocks in the second related text block set according to the third semantic similarity;

[0108] In this embodiment, the reordered second related text block set is in the order of: C, D1, A, B1.

[0109] S209, cross-calculating semantic relevance based on the difference set of the first relevant re-ordered text block set and the second relevant re-ordered text block set, and re-ordering the union of the first relevant re-ordered text block set and the difference set based on the cross-calculated semantic relevance to obtain the first relevant re-ordered text block set,

[0110] In this embodiment, the first relevant re-ordered text block set includes the sorted cluster blocks and the correlation scores corresponding to the cluster blocks. As an optional embodiment, the first relevant re-ordered text block set includes:

[0111] B 0.7

[0112] A 0.6

[0113] D 0.5

[0114] C 0.4

[0115] D1 0.3

[0116] B1 0.2

[0117] S210, based on the semantic relevance of the cross calculation, reorder the union of the second relevant reordered text block set and the difference set to obtain a second relevant reordered text block set,

[0118] In this embodiment, as an optional embodiment, the second relevant re-ordered text block set includes:

[0119] C 0.6

[0120] D1 0.5

[0121] A 0.4

[0122] B1 0.3

[0123] B 0.2

[0124] D 0.1

[0125] S211, merging and sorting the first relevant re-ordered text block set and the second relevant re-ordered text block set;

[0126] S212: Obtain a sorted semantic recall clustering block set.

[0127] In this embodiment, as an optional embodiment, the semantic recall clustering block set includes:

[0128] A 0.5

[0129] C 0.5

[0130] B 0.45

[0131] D1 0.4

[0132] D 0.3

[0133] B1 0.25

[0134] In this embodiment, as an optional embodiment, obtaining a topic recall clustering block set matching the question sentence includes:

[0135] A41, for each cluster block in the knowledge base of the model knowledge base, extract the content corresponding to the cluster block, remove stop words and perform word segmentation processing, and represent it as a candidate word pair;

[0136] A42, using the word pair topic model, learns the topic distribution based on the candidate word pairs and represents the clustering blocks as the topic probability distribution of each topic in the pre-set topic group;

[0137] A43, using a word pair topic model, representing the question sentence as a topic probability distribution of each topic in the topic group;

[0138] A44, based on the topic probability distribution of each cluster block and the topic probability distribution of the question sentence, obtain the topic recall cluster block set.

[0139] In this embodiment, the word pair topic model (BTM, Biterm Topic Model) is applied to topic recall, which can more accurately match documents or paragraphs related to user queries in the large model knowledge question answering system. First, the text block (clustering block) is pre-processed, such as word segmentation, stop word removal, etc., and then represented as word pairs. Then, the BTM topic model is used to model the pre-processed text block, wherein the BTM topic model learns the topic distribution based on the word pairs in the text block, and each text block is represented as a probability distribution of a group of topics, that is, for the word pairs corresponding to each text block, the text block is represented as the topic probability distribution of each topic in the pre-set topic group. Then, the BTM is used to convert the query text corresponding to the user query statement into the topic probability distribution of each topic in the topic group, and the cosine similarity between the topic distribution probability of the user query statement and the topic distribution probability of the text block is calculated. The text block with a cosine similarity greater than a pre-set cosine similarity threshold is recalled to obtain a topic recall clustering block set. In this embodiment, as an optional embodiment, the cosine similarity threshold is taken as 0.7, thereby completing the topic recall.

[0140] In this embodiment, a single path may not accurately and comprehensively capture all relevant information in the question and document, resulting in the omission of some effective information and inaccurate model answers. In this embodiment, a multi-path recall fusion strategy is proposed, which can simultaneously perform information retrieval and recall from multiple dimensions and multiple strategies when users ask questions, ensuring the diversity and accuracy of question and answer results. As an optional embodiment, three recall strategies based on term frequency-inverse document frequency (TF-IDF, TermFrequency_Inverse Document Frequency), semantic recall, and topic recall are proposed. The three recall strategies are integrated to achieve multi-path recall, thereby overcoming the problem of missing information in single path recall.

[0141] S105, obtaining candidate content included in the keyword recall cluster block set, the semantic recall cluster block set, and the theme recall cluster block set, and for each candidate content, obtaining the fusion relevance of the candidate content based on the frequency of occurrence of the candidate content in each recall cluster block set;

[0142] In this embodiment, for the keyword-based recall, semantic recall, and topic recall in the above-mentioned multi-path recall, the same text block (cluster block) may be recalled by multiple paths at the same time, or a text block may be recalled by only one of the paths, or a text block may not be recalled by any path. Therefore, in order to effectively fuse repeated and non-repeated text blocks in the recall, this embodiment adopts a fusion processing method of weighted fusion and deduplication strategy to ensure that repeated recalled text blocks do not lead to redundant answers, thereby affecting the question-and-answer experience. Therefore, as an optional embodiment, the candidate content contained in the keyword recall cluster block set, the semantic recall cluster block set, and the topic recall cluster block set is obtained, including:

[0143] Construct a candidate paragraph set, and write the contents of the keyword recall clustering block set into the candidate paragraph set;

[0144] Traverse the contents contained in the semantic recall clustering block set and the topic recall clustering block set;

[0145] If the traversed content exists in the candidate paragraph set, traverse the next paragraph. If the traversed content does not exist in the candidate paragraph set, write the traversed content into the candidate paragraph set and traverse the next paragraph.

[0146] In this embodiment, as an optional embodiment, based on the frequency of occurrence of the candidate paragraph in each recall cluster block set, the fusion relevance of the candidate paragraph is obtained, including:

[0147] Check whether the candidate paragraph exists in the keyword recall cluster block set, semantic recall cluster block set and topic recall cluster block set respectively. If so, increase the frequency by 1.

[0148] A weighted calculation is performed based on the fusion relevance strategy corresponding to the frequency to obtain the fusion relevance of the candidate paragraph.

[0149] In this embodiment, the value range of the frequency is 1 to 3. The value of the frequency is 2 or 3, indicating that there are repeated recalled cluster blocks, that is, repeated text blocks, in the keyword recall cluster block set, the semantic recall cluster block set, and the topic recall cluster block set.

[0150] In this embodiment, there are four situations for the recalled repeated text blocks:

[0151] The first case is that the same text block is recalled by three methods at the same time, the second case is that the same text block is recalled by keywords and semantics at the same time, the third case is that the same text block is recalled by keywords and topics at the same time, and the fourth case is that the same text block is recalled by semantics and topics at the same time.

[0152] For the first situation where the same text block is recalled by three paths simultaneously, as an optional embodiment, the fusion relevance (score) of the text block is the weighted sum of the relevance scores of the three paths, expressed as follows:

[0153] S combined =α×S keyword +β×S semantic +γ×S topic

[0154] Among them, S combined To fuse the correlation, S keyword is the keyword recall relevance, S semantic is the semantic recall relevance, S topic is the topic recall relevance. α, β, and γ are the keyword recall weight, semantic recall weight, and topic recall weight, respectively, satisfying:

[0155] α+β+γ=1

[0156] In this embodiment, as an optional embodiment, the keyword recall weight, semantic recall weight and topic recall weight are respectively 0.2, 0.6 and 0.2. Taking semantic recall relevance as an example, the semantic recall relevance of a text block can be the similarity of the text block in the semantic recall clustering block set.

[0157] For the second case where the same text block is recalled by both keywords and semantics, the fusion relevance score of the text block is the weighted sum of the keyword recall relevance score and the semantic recall relevance score, expressed as follows:

[0158] S combined =α×S keyword +β×S semantic

[0159] Wherein, α and β satisfy α+β=1, and as an optional embodiment, the values ​​are 0.4 and 0.6 respectively.

[0160] For the third case where the same text block is recalled by both keywords and topics, the fusion relevance score of the text block is the weighted sum of the keyword recall relevance score and the topic recall relevance score, expressed as follows:

[0161] S combined =α×S keyword +γ×S topic

[0162] Wherein, α and γ satisfy α+γ=1, and as an optional embodiment, the values ​​are 0.6 and 0.4 respectively.

[0163] For the fourth case where the same text block is recalled by both semantic and topic recall, the fusion relevance score of the text block is the weighted sum of the semantic recall relevance score and the topic recall relevance score, expressed as follows:

[0164] S combined =β×S semantic +γ×S topic

[0165] Wherein, β and γ satisfy β+γ=1. In this embodiment, as an optional embodiment, the values ​​of β and γ are 0.7 and 0.3 respectively.

[0166] In this embodiment, if a text block is only recalled by one path, the relevance score calculated by this path is the fusion relevance score of the text block.

[0167] S106, sorting the candidate contents according to their fusion relevance, concatenating the sorted candidate contents to obtain a concatenated paragraph, inputting the concatenated paragraph into the generative intelligent question-answering system in the model knowledge base, and obtaining an answer corresponding to the question statement.

[0168] In this embodiment, all recalled text blocks are sorted according to their fusion relevance scores, and the sorted text blocks are concatenated with line breaks to form a string. The string is input into a generative intelligent question-answering system (big model), and the big model generates an answer based on the input string.

[0169] In this embodiment, as an optional embodiment, the generative intelligent question answering system includes but is not limited to: Qwen-14B-Chat large model.

[0170] A specific embodiment is given below for detailed description.

[0171] In this embodiment, the local PDF, TXT, and Word documents are uploaded and parsed, and read in the order of the paragraphs in the document. As an optional embodiment, for the pictures in the document, the cogvlm2-llama3-chinese-chat-19B model is used to generate a picture-based text description of the picture, and the picture text description is represented as a vector using the text2vec-large-chinese vector representation model and stored in the vector database. For the text paragraphs in the document, the text2vec-large-chinese vector representation model is used to represent each paragraph as a vector.

[0172] Then, the Single-Pass algorithm is used to perform preliminary block division based on the vectors. As an optional embodiment, assume that the document contains 9 paragraphs, and the Single-Pass algorithm is used to perform preliminary block division based on the vectors corresponding to the 9 paragraphs. The similarity threshold is set to 0.7, and the vectors corresponding to paragraphs 1 to 9 are read sequentially. The vector corresponding to the first paragraph is read first, and a block is created for the first paragraph. The vector corresponding to the text of the first paragraph is represented as Then read the corresponding vector of the second paragraph text, expressed as Then calculate the cosine similarity of the two paragraph vectors. If the cosine similarity is greater than the similarity threshold of 0.7, the second paragraph is assigned to the block represented by the first paragraph, and the block vector representation is updated. The block vector representation is the sum and average of the two paragraph vectors. Otherwise, a new block is created for the second paragraph. For the third paragraph, if the second paragraph is assigned to an existing block, that is, no new block is formed, the block is divided based on the cosine similarity between the vector corresponding to the third paragraph and the vector corresponding to the existing block. If the second paragraph forms a new block, the block is divided based on the cosine similarity between the vector corresponding to the third paragraph and the vector corresponding to the new block. And so on, the document is initially divided into several blocks, each block contains multiple paragraphs. Assuming that it is finally divided into three blocks, the block results are as follows:

[0173] Block 1 contains three paragraphs 1, 2, and 3. The vector represents

[0174] Block 2 contains three paragraphs 4, 5, and 6. The vector represents

[0175] Block 3 contains three paragraphs 7, 8, and 9. The vector representation

[0176] In this embodiment, the Single-Pass algorithm is used for block segmentation, which takes into account the semantic coherence of the paragraph order, but it is unable to link the contents of multiple paragraphs that are semantically related but have a relatively large span in the document, and cannot provide a better context for the subsequent large model to answer the summary-oriented questions, resulting in unsatisfactory answers to such questions. Based on this, this embodiment uses the K-means clustering algorithm to fine-tune the above block segmentation so that the paragraphs with a large span but semantically related can be linked.

[0177] In this embodiment, the number of blocks obtained based on the Single-Pass algorithm is used as the cluster number K of the k-means clustering algorithm. All paragraphs of the document are clustered based on the K-means clustering algorithm, where the cluster center is the vector representation of the block. Calculate the similarity between the vector of the paragraph and the block vector of the block that does not contain the paragraph. If the similarity is greater than the similarity threshold of 0.8, the paragraph is assigned to the block again. At the same time, the original block corresponding to the paragraph is retained, and so on. Assume that the final block result is as follows:

[0178] Block 1 contains three paragraphs 1, 2, and 3. The vector represents

[0179] Block 2 contains three paragraphs 4, 5, and 6. The vector represents

[0180] Block 3 contains three paragraphs: 3, 7, 8, and 9. The vector represents

[0181] Then, the blocks formed based on the K-means clustering algorithm are stored in the vector database.

[0182] In this embodiment, the user input sentence is converted into a query vector using the text2vec-large-chinese vector representation model, and the correlation is calculated with the block vectors of each block in the vector database, and the first 50 blocks are recalled to complete the keyword text block recall.

[0183] Then, based on the 50 recalled blocks, the 50 blocks are represented as vectors using the bge-large-zh model and the bce-embedding-base model respectively. The user input sentences are also represented as vectors using the bge-large-zh model and the bce-embedding-base model respectively. Then, the correlations are calculated respectively. According to the calculated correlations, the first 20 blocks are recalled respectively. For the first 20 recalled blocks, the bge_reranker model and the bce_reranker model are used to reorder the 20 blocks respectively.

[0184] The 20 reordered blocks are cross-sorted to obtain the final semantic recall result.

[0185] Then, we get the recall results based on keyword recall and topic recall, and merge the three recall results to get the final relevance block sorting results, forming a prompt in the following form:

[0186] prompt_template="""Answer the user's question comprehensively and professionally based on the following known information.

[0187] If you cannot get an answer from it, please say "The question cannot be answered based on the known information" or "Not enough relevant information is provided". It is not allowed to add fabricated elements to the answer. Please use Chinese for the answer.

[0188] Known Content:

[0189] {context}

[0190] question:

[0191] {question}"""

[0192] In this embodiment, context is the recalled block, and question is the query input by the user.

[0193] Prompt is input to the big model (generative intelligent question-answering system), and the big model generates answers and returns them to the user. As an optional embodiment, the big model used is the Qwen-72B-Chat big model.

[0194] In this embodiment, a large-scale pre-trained model and a knowledge base are combined, and an improved chunking algorithm and multi-way recall mechanism are used to solve the chunking problem of complex documents and the limitations of information recall, which can significantly improve the accuracy of the generative intelligent question-answering system.

[0195] Based on the same inventive concept, Figure 3 As shown, the embodiment of the present invention also provides a question-answering device based on a model knowledge base, the device comprising:

[0196] The block list construction module 301 is used to read the content of each sample document in the sample document set according to a preset reading strategy, and construct a block list of the sample document. In the block list, a first block containing the first content read according to the preset reading strategy is constructed;

[0197] In this embodiment, if the sample document contains non-text content, as an optional embodiment, the block list construction module 301 is further used to:

[0198] For the pictures in the sample documents, the cogvlm2-llama3-chinese-chat-19B model is used to generate picture-based text descriptions. Each picture name contains a paragraph of picture text descriptions corresponding to each picture.

[0199] A block processing module 302 is used to sequentially calculate the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs based on a single-channel algorithm, and if the similarity is greater than or equal to a preset first similarity threshold, place the currently read content in the block to which the previously read content belongs; if the similarity is less than the first similarity threshold, create a new block and place the currently read content in the newly created block;

[0200] In this embodiment, as an optional embodiment, the block processing module 302 is specifically used for:

[0201] Input the currently read content into the text vector representation model to obtain the text vector corresponding to the currently read content;

[0202] Extracting each read content in the block to which the previously read content belongs, inputting the content into the text vector representation model, and obtaining the block vector of the block to which the previously read content belongs;

[0203] Using a single-pass algorithm, the cosine similarity between the text vector and the block vector is calculated.

[0204] In this embodiment, as another optional embodiment, the block processing module 302 is further configured to:

[0205] After placing the currently read content in the block to which the previously read content belongs, updating the block vector of the block based on the text vector representation model;

[0206] After the currently read content is placed in the newly created block, the text vector of the currently read content is written into the newly created block as a block vector.

[0207] The block clustering module 303 is used to traverse the content in each block in each block list, and use the k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content. When the calculated similarity is greater than or equal to a preset second similarity threshold, the content is again assigned to the block corresponding to the calculated similarity to obtain clustered blocks, which are stored in the knowledge base of the model knowledge base;

[0208] In this embodiment, as an optional embodiment, the block clustering module 303 is specifically used for:

[0209] Determine the number of clusters according to the number of blocks included in the block list;

[0210] Construct several initial clusters for clustering, and each block corresponds to an initial cluster center;

[0211] Traverse the initialization clusters, extract the target content from the initialization clusters, and use the k-means clustering algorithm to calculate the similarity between the target content and all the initialization clusters that do not contain the target content.

[0212] In this embodiment, as another optional embodiment, the block clustering module 303 is further used to:

[0213] In the case where the content is reallocated to the block corresponding to the calculated similarity, the block vector corresponding to the block is kept unchanged until the initialization cluster is traversed, and the block vector corresponding to the block is updated based on the content contained in each block.

[0214] The block recall module 304 is used to receive a question sentence input by a user, and based on the question sentence, obtain a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question sentence from the knowledge base of the model knowledge base;

[0215] In this embodiment, as an optional embodiment, the block recall module 304 is specifically used for:

[0216] For each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale first text vector model, calculate the semantic similarity between the cluster block and the question sentence, obtain the cluster block that meets the first semantic similarity threshold, and obtain a first related text block set;

[0217] For each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale second text vector model, calculate the semantic similarity between the cluster block and the question sentence, obtain the cluster block that meets the semantic second similarity threshold, and obtain a second related text block set, wherein the number of cluster blocks included in the first related text block set is the same as the number of cluster blocks included in the second related text block set;

[0218] Reordering the clustered blocks in the first set of related text blocks by using a pre-trained first reordered text vector representation model to obtain a first set of related reordered text blocks;

[0219] Reordering the sorted clustered blocks in the second relevant text block set by using a pre-trained second reordered text vector representation model to obtain a second relevant reordered text block set;

[0220] Cross-calculating semantic relevance based on the difference set of the first relevant re-ordered text block set and the second relevant re-ordered text block set, re-ordering the union of the first relevant re-ordered text block set and the difference set based on the cross-calculated semantic relevance to obtain the first relevant re-ordered text block set, and re-ordering the union of the second relevant re-ordered text block set and the difference set to obtain the second relevant re-ordered text block set;

[0221] According to a preset overall sorting strategy, the first relevant re-sorted text block set and the second relevant re-sorted text block set are sorted as a whole to obtain a sorted semantic recall clustering block set.

[0222] In this embodiment, as another optional embodiment, the block recall module 304 is further used to:

[0223] For each cluster block in the knowledge base of the model knowledge base, extract the content corresponding to the cluster block, remove stop words and perform word segmentation processing to obtain a text block corresponding to the cluster block;

[0224] Based on word frequency-inverse document frequency, keywords are extracted from the text block, and the extracted keywords are vectorized to obtain the candidate keyword vector representation of the text block;

[0225] After removing stop words and performing word segmentation processing on the question sentence, keywords are extracted, and the extracted keywords are vectorized to obtain a question keyword vector representation;

[0226] Based on the similarity between the question keyword vector representation and the candidate keyword vector representation of each text block, the text blocks satisfying the similarity strategy are recalled to obtain the ordered keyword recall cluster block set.

[0227] In this embodiment, as another optional embodiment, the block recall module 304 is further used to:

[0228] For each cluster block in the knowledge base of the model knowledge base, extract the content corresponding to the cluster block, remove stop words and perform word segmentation processing, and represent it as a candidate word pair;

[0229] Using the word pair topic model, the topic distribution is learned based on the candidate word pairs, and the cluster blocks are represented as the topic probability distribution of each topic in the pre-set topic group;

[0230] Using a word pair topic model, the question sentence is represented as a topic probability distribution of each topic in the topic group;

[0231] Based on the topic probability distribution of each cluster block and the topic probability distribution of the question sentence, the topic recall cluster block set is obtained.

[0232] The fusion processing module 305 is used to obtain candidate content included in the keyword recall cluster block set, the semantic recall cluster block set and the theme recall cluster block set, and for each candidate content, obtain the fusion relevance of the candidate content based on the frequency of occurrence of the candidate content in each recall cluster block set;

[0233] In this embodiment, as an optional embodiment, the fusion processing module 305 is specifically used for:

[0234] Construct a candidate paragraph set, and write the contents of the keyword recall clustering block set into the candidate paragraph set;

[0235] Traverse the contents contained in the semantic recall clustering block set and the topic recall clustering block set;

[0236] If the traversed content exists in the candidate paragraph set, traverse the next paragraph. If the traversed content does not exist in the candidate paragraph set, write the traversed content into the candidate paragraph set and traverse the next paragraph.

[0237] In this embodiment, as another optional embodiment, the fusion processing module 305 is further used to:

[0238] Based on the frequency of occurrence of the candidate paragraph in each recall cluster block set, the fusion relevance of the candidate paragraph is obtained, including:

[0239] Check whether the candidate paragraph exists in the keyword recall cluster block set, semantic recall cluster block set and topic recall cluster block set respectively. If so, increase the frequency by 1.

[0240] A weighted calculation is performed based on the fusion relevance strategy corresponding to the frequency to obtain the fusion relevance of the candidate paragraph.

[0241] The answer acquisition module 306 is used to sort the candidate contents according to their fusion relevance, splice the sorted candidate contents to obtain a spliced ​​paragraph, input the spliced ​​paragraph into the generative intelligent question-answering system in the model knowledge base, and obtain the answer corresponding to the question statement.

[0242] Based on the same inventive concept, an embodiment of the present invention further provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the question-answering method based on the model knowledge base in any possible implementation manner described above are implemented.

[0243] Alternatively, the storage medium may be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0244] Based on the same inventive concept, see Figure 4 The embodiment of the present invention further provides an electronic device, including a memory 101 (such as a non-volatile memory), a processor 102, and a computer program stored in the memory 101 and executable on the processor 102. When the processor 102 executes the program, the steps of the question-answering method based on the model knowledge base in any possible implementation manner described above are implemented, which can be equivalent to the question-answering device based on the model knowledge base as described above. Of course, the processor can also be used to process other data or operations. The electronic device can be a PC, a server, a terminal, and other devices.

[0245] like Figure 4As shown, the electronic device may also generally include: a memory 103, a network interface 104, and an internal bus 105. In addition to these components, other hardware may also be included, which will not be described in detail.

[0246] It should be pointed out that the above-mentioned question-and-answer device based on the model knowledge base can be implemented by software. As a device in a logical sense, it is formed by the processor 102 of the electronic device in which it is located reading the computer program instructions stored in the non-volatile memory into the memory 103 for execution.

[0247] The embodiments of the subject matter and functional operations described in this specification may be implemented in the following: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. The embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules in computer program instructions encoded on a tangible non-temporary program carrier to be executed by a data processing device or to control the operation of the data processing device. Alternatively or additionally, the program instructions may be encoded on an artificially generated propagation signal, such as a machine-generated electrical, optical or electromagnetic signal, which is generated to encode information and transmit it to a suitable receiver device for execution by a data processing device. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them.

[0248] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform the corresponding functions by operating on input data and generating output. The processes and logic flows can also be performed by special purpose logic circuits, such as FPGAs (field programmable gate arrays) or ASICs (application specific integrated circuits), and the apparatus can also be implemented as special purpose logic circuits.

[0249] Computers suitable for executing computer programs include, for example, general and / or special microprocessors, or any other type of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory and / or a random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, the computer will also include one or more large-capacity storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, or the computer will be operably coupled to this large-capacity storage device to receive data from it or to transmit data to it, or both. However, the computer does not necessarily have such a device. In addition, the computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.

[0250] Computer readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including, for example, semiconductor memory devices (e.g., EPROM, EEPROM and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. The processor and memory may be supplemented by, or incorporated in, special purpose logic circuitry.

[0251] Although this specification includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments in this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although the features may work as above in certain combinations and even initially claim protection, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.

[0252] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or requiring that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.

[0253] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0254] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0255] The above is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features applied herein.

Claims

1. A question-answering method based on a model knowledge base, characterized in that: include: For each sample document in the sample document set, read the content of the sample document in sequence according to a preset reading strategy, build a block list of the sample document, and in the block list, build a first block containing the first content read according to the preset reading strategy; Based on a single-channel algorithm, the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs is sequentially calculated; if the similarity is greater than or equal to a preset first similarity threshold, the currently read content is placed in the block to which the previously read content belongs; if the similarity is less than the first similarity threshold, a new block is created, and the currently read content is placed in the newly created block; For each block list, traverse the content in each block in the block list, use the k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content, and when the calculated similarity is greater than or equal to a preset second similarity threshold, assign the content again to the block corresponding to the calculated similarity to obtain clustered blocks, which are stored in the knowledge base of the model knowledge base; Receive a question statement input by a user, and based on the question statement, obtain a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question statement from the knowledge base of the model knowledge base; Obtain candidate content included in the keyword recall cluster block set, the semantic recall cluster block set, and the topic recall cluster block set, and for each candidate content, obtain the fusion relevance of the candidate content based on the frequency of occurrence of the candidate content in each recall cluster block set; The candidate contents are sorted according to their fusion relevance, and the sorted candidate contents are spliced ​​to obtain a spliced ​​paragraph. The spliced ​​paragraph is input into the generative intelligent question-answering system in the model knowledge base to obtain an answer corresponding to the question statement.

2. The question-answering method based on the model knowledge base according to claim 1, characterized in that: The method of sequentially calculating the similarity between the content currently read according to the reading strategy and the blocks to which the content previously read according to the reading strategy belongs based on the single-channel algorithm includes: Input the currently read content into the text vector representation model to obtain the text vector corresponding to the currently read content; Extracting each read content in the block to which the previously read content belongs, inputting the content into the text vector representation model, and obtaining the block vector of the block to which the previously read content belongs; Using a single-pass algorithm, the cosine similarity between the text vector and the block vector is calculated.

3. The question-answering method based on the model knowledge base according to claim 2, characterized in that: The method further comprises: After placing the currently read content in the block to which the previously read content belongs, updating the block vector of the block based on the text vector representation model; After the currently read content is placed in the newly created block, the text vector of the currently read content is written into the newly created block as a block vector.

4. The question-answering method based on the model knowledge base according to claim 1, characterized in that: The traversing the content in each block in the block list and using the k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content, includes: Determine the number of clusters according to the number of blocks included in the block list; Construct several initial clusters for clustering, and each block corresponds to an initial cluster center; Traverse the initialization clusters, extract the target content from the initialization clusters, and use the k-means clustering algorithm to calculate the similarity between the target content and all the initialization clusters that do not contain the target content.

5. The question-answering method based on the model knowledge base according to claim 4, characterized in that: After the content is redistributed to the blocks corresponding to the calculated similarities, the method further includes: In the case where the content is reallocated to the block corresponding to the calculated similarity, the block vector corresponding to the block is kept unchanged until the initialization cluster is traversed, and the block vector corresponding to the block is updated based on the content contained in each block.

6. The question-answering method based on a model knowledge base according to any one of claims 1 to 5, characterized in that: The step of obtaining a semantic recall clustering block set matching the question statement includes: For each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale first text vector model, calculate the semantic similarity between the cluster block and the question sentence, obtain the cluster block that meets the first semantic similarity threshold, and obtain a first related text block set; For each cluster block in the knowledge base of the model knowledge base, using a pre-trained large-scale second text vector model, calculate the semantic similarity between the cluster block and the question sentence, obtain the cluster block that meets the semantic second similarity threshold, and obtain a second related text block set, wherein the number of cluster blocks included in the first related text block set is the same as the number of cluster blocks included in the second related text block set; Reordering the clustered blocks in the first set of related text blocks by using a pre-trained first reordered text vector representation model to obtain a first set of related reordered text blocks; Reordering the sorted clustered blocks in the second relevant text block set by using a pre-trained second reordered text vector representation model to obtain a second relevant reordered text block set; Cross-calculating semantic relevance based on the difference set of the first relevant re-ordered text block set and the second relevant re-ordered text block set, re-ordering the union of the first relevant re-ordered text block set and the difference set based on the cross-calculated semantic relevance to obtain the first relevant re-ordered text block set, and re-ordering the union of the second relevant re-ordered text block set and the difference set to obtain the second relevant re-ordered text block set; According to a preset overall sorting strategy, the first relevant re-sorted text block set and the second relevant re-sorted text block set are sorted as a whole to obtain a sorted semantic recall clustering block set.

7. The question-answering method based on a model knowledge base according to any one of claims 1 to 5, characterized in that: The step of obtaining candidate content included in the keyword recall cluster block set, the semantic recall cluster block set, and the topic recall cluster block set includes: Construct a candidate paragraph set, and write the contents of the keyword recall clustering block set into the candidate paragraph set; Traverse the contents contained in the semantic recall clustering block set and the topic recall clustering block set; If the traversed content exists in the candidate paragraph set, traverse the next paragraph. If the traversed content does not exist in the candidate paragraph set, write the traversed content into the candidate paragraph set and traverse the next paragraph.

8. A question-answering device based on a model knowledge base, characterized in that: The question-answering device based on the model knowledge base includes: A block list building module is used to read the content of each sample document in the sample document set in sequence according to a preset reading strategy, build a block list of the sample document, and build a first block containing the first content read according to the preset reading strategy in the block list; A block processing module, for sequentially calculating the similarity between the content currently read according to the reading strategy and the block to which the content previously read according to the reading strategy belongs based on a single-channel algorithm, and if the similarity is greater than or equal to a preset first similarity threshold, placing the currently read content in the block to which the previously read content belongs; if the similarity is less than the first similarity threshold, creating a new block and placing the currently read content in the newly created block; A block clustering module is used to traverse the content of each block in each block list, and use a k-means clustering algorithm to calculate the similarity between the content and all blocks that do not contain the content. When the calculated similarity is greater than or equal to a preset second similarity threshold, the content is again assigned to the block corresponding to the calculated similarity to obtain clustered blocks, which are stored in the knowledge base of the model knowledge base; A block recall module is used to receive a question statement input by a user, and based on the question statement, obtain a keyword recall cluster block set, a semantic recall cluster block set, and a topic recall cluster block set that match the question statement from the knowledge base of the model knowledge base; A fusion processing module is used to obtain candidate content included in the keyword recall cluster block set, the semantic recall cluster block set and the theme recall cluster block set, and for each candidate content, based on the frequency of occurrence of the candidate content in each recall cluster block set, obtain the fusion relevance of the candidate content; The answer acquisition module is used to sort the candidate contents according to their fusion relevance, splice the sorted candidate contents to obtain a spliced ​​paragraph, input the spliced ​​paragraph into the generative intelligent question-answering system in the model knowledge base, and obtain the answer corresponding to the question statement.

9. A storage medium, characterized in that: The storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, the steps of the question-answering method based on a model knowledge base as described in any one of claims 1 to 7 are implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the question-answering method based on the model knowledge base according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Steel industry intelligent question and answer method and device based on large model and medium

    CN118051587A

  • Question and answer method and device based on keywords and semantic model and storage medium

    CN118520089A

  • Automatic question answering method and device, electronic equipment and computer storage medium

    CN118626615A

  • Chat response method, electronic device and storage medium

    WO2019153613A1

Cited By

  • System operation security dialogue method generated by large model fine tuning and two-stage retrieval

    CN120471172A

  • Text fragment recall method, electronic equipment and storage medium

    CN121029974A

  • Algorithm method for large-model long-context reasoning

    CN121365738A

  • An algorithm method for large model long context reasoning

    CN121365738B

  • Dynamic multi-knowledge-base intelligent interaction system based on heterogeneous data fusion

    CN121615747A