Question and answer method and device, equipment, storage medium and product
By introducing a business logic tree and a multi-level retrieval strategy, the intelligent question-answering assistant can accurately locate answers to questions in professional fields, solving the problem of insufficient knowledge support in existing intelligent assistants and achieving efficient and accurate professional knowledge retrieval.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-04-03
AI Technical Summary
Existing intelligent assistants lack authoritative and comprehensive knowledge support when dealing with complex and diverse professional issues, and cannot provide satisfactory answers. Furthermore, general retrieval methods cannot effectively utilize multi-source data, resulting in insufficient authenticity and comprehensiveness of the answers.
By adopting a multi-source data and multi-strategy fusion approach and introducing a business logic tree, professional knowledge is displayed hierarchically. Combined with similarity search and multi-level retrieval strategies, the answer text is accurately located and key related information is recalled, thereby improving the accuracy of data search.
Accurately locate answer text in complex question-and-answer formats, reduce the risk of missing information, improve the precision of professional knowledge queries and the accuracy of data searches, and meet the complex needs of public policy documents.
Smart Images

Figure CN121787573A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence technology, and in particular relates to a question-answering method, apparatus, device, storage medium and product. Background Technology
[0002] With the development of artificial intelligence technology, intelligent assistants have become an indispensable part of people's daily lives. However, existing intelligent assistants still have shortcomings in understanding and responding to users' complex and diverse needs, especially when dealing with problems in professional fields, where they often fail to provide satisfactory answers due to a lack of authoritative and comprehensive knowledge support. Summary of the Invention
[0003] This application provides a question-and-answer method, apparatus, device, storage medium, and product that can ensure accurate location of answer text and recall of all key related information in complex question-and-answer scenarios, reducing the risk of missed queries and improving the accuracy of data search.
[0004] In a first aspect, embodiments of this application provide a question-answering method, which includes: obtaining question text; obtaining a first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; performing a similarity search on the target search knowledge base based on the question text to obtain a second candidate answer text; obtaining a target answer text from the first candidate answer text and the second candidate answer text, where the similarity between the target answer text and the question text is greater than a first similarity threshold; and outputting the target answer text.
[0005] In some possible implementations, the first candidate answer text corresponding to the question text is obtained from the target search knowledge base using a business logic tree corresponding to the target search knowledge base. This includes: performing entity recognition on the question text and extracting the question entity from the question text; sequentially traversing the nodes in the business logic tree to determine the target node that matches the question entity; and obtaining the text pointed to by the target node from the target search knowledge base to obtain the first candidate answer text.
[0006] In some possible implementations, the question-answering method also includes: obtaining business documents and the corresponding business types; identifying business elements in the business documents; constructing a tree structure corresponding to the business types based on the business elements, wherein the tree structure includes multiple nodes and edges between multiple nodes, each node is used to represent a business element, and the edges are used to represent the relationships between business elements; and adjusting the nodes and / or edges in the tree structure in response to the node labeling operation of the tree structure to obtain a business logic tree.
[0007] In some possible implementations, the second candidate answer text includes a third candidate answer text and a fourth candidate answer text. The second candidate answer text is obtained by performing a similarity search on the target search knowledge base based on the question text. This includes: segmenting the question text to obtain at least one keyword; slicing the text in the target search knowledge base to obtain multiple knowledge slices; determining the third candidate answer text whose relevance score is greater than a threshold from the multiple knowledge slices based on the relevance between the at least one keyword and the multiple knowledge slices; obtaining the text vector corresponding to the question text and the slice vectors corresponding to the multiple knowledge slices; and obtaining the fourth candidate answer text whose semantic similarity is greater than a second similarity threshold from the multiple knowledge slices based on the similarity between the text vector and the slice vector.
[0008] In some possible implementations, obtaining the target answer text from the first and second candidate answer texts, where the similarity to the question text is greater than a first similarity threshold, includes: generating a candidate answer text set based on the first, third, and fourth candidate answer texts; performing word segmentation on the question text and the candidate answer texts in the candidate answer text set to obtain question word segments and answer word segments; representing the question word segments and answer word segments into vectors based on the word segmentation weights corresponding to the question word segments and the answer word segments to obtain question vectors and answer vectors; obtaining the target answer vector with a similarity greater than the first similarity threshold based on the similarity between the question vector and the answer vector; and merging the question text and the target answer vector to obtain the target answer text.
[0009] In some possible implementations, the question-answering method also includes: if the similarity between the question vector and the answer vector is less than or equal to a first similarity threshold, using a preset text as the target answer text.
[0010] In some possible implementations, before retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base, the question answering method further includes: determining the target search knowledge base from multiple search knowledge bases in response to a knowledge base selection instruction.
[0011] In some possible implementations, before retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base, the question answering method further includes: obtaining summary description information corresponding to multiple search knowledge bases; performing intent recognition on the question text to determine the user intent information corresponding to the question text; calculating the text similarity between the summary description information and the user intent information; and determining the search knowledge base with the highest text similarity from multiple search knowledge bases to obtain the target search knowledge base.
[0012] Secondly, embodiments of this application provide a question-answering device, which includes: a data acquisition module for acquiring question text and a target search knowledge base; a first search module for acquiring a first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; a second search module for performing a similarity search on the target search knowledge base based on the question text to obtain a second candidate answer text; an answer acquisition module for acquiring a target answer text from the first candidate answer text and the second candidate answer text, wherein the similarity between the target answer text and the question text is greater than a similarity threshold; and an answer output module for outputting the target answer text.
[0013] Thirdly, embodiments of this application provide an electronic device, which includes: a processor and a memory storing computer program instructions; the processor executes the computer program instructions to implement the question-and-answer method of any of the above.
[0014] Fourthly, embodiments of this application provide a computer storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, they implement the question-and-answer method described above.
[0015] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform any of the above-mentioned question-and-answer methods.
[0016] As described above, in this embodiment, the business logic tree can hierarchically display the knowledge in the professional knowledge base. Through the business logic tree, users can conduct business consultations within the scope of the professional knowledge base, improving the accuracy of professional knowledge queries. Furthermore, in this embodiment, the target answer text is determined jointly by the answer search results based on the business logic tree and the answer search results determined based on the similarity search between the question text and the target search knowledge base. This process employs a multi-level retrieval strategy, ensuring accurate location of the answer text and retrieval of all key related information in complex question-and-answer scenarios, reducing the risk of missed queries and improving the accuracy of data search. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the server structure corresponding to the intelligent question-answering assistant provided in one embodiment of this application; Figure 2 This is a flowchart illustrating a question-and-answer method provided in one embodiment of this application; Figure 3 This is a flowchart illustrating the determination of a target search knowledge base according to an embodiment of this application; Figure 4 This is a schematic diagram of the business logic tree structure provided in one embodiment of this application; Figure 5 This is a complete flowchart of a question-and-answer method provided in one embodiment of this application; Figure 6 This is a schematic diagram of the structure of a question-and-answer device provided in another embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in another embodiment of this application. Detailed Implementation
[0019] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0020] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0021] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.
[0022] Furthermore, it should be noted that in the embodiments of this application, certain software, components, models, and other existing solutions in the industry may be mentioned. These should be considered as exemplary, and their purpose is only to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0023] With the development of artificial intelligence technology, intelligent assistants have become an indispensable part of people's daily lives. However, existing intelligent assistants still have shortcomings in understanding and responding to users' complex and diverse needs, especially when dealing with problems in professional fields, often failing to provide satisfactory answers due to a lack of authoritative and comprehensive knowledge support. Furthermore, how to effectively utilize knowledge resources from different channels is also a major challenge facing current intelligent assistants.
[0024] With the continuous updating and development of policies and regulations, quickly and accurately obtaining and understanding relevant policies has become a challenge. Traditional information retrieval methods often fall short of meeting the complex needs of public policy documents, especially when faced with a large number of complex policy documents. Effectively extracting key information and providing explanations becomes particularly important.
[0025] Furthermore, in related technologies, search engines are typically used to retrieve general knowledge, but the uncontrollable data sources mean that the authenticity of the answers cannot be fully guaranteed. When answering questions requiring specialized knowledge, multiple interpretations of policy-related knowledge are needed, but general search results are not comprehensive enough to cover all policy provisions, making it difficult to meet the complex needs of public policy documents.
[0026] To address the problems of existing technologies, embodiments of this application provide a question-and-answer method, apparatus, device, storage medium, and product. In these embodiments, a multi-source data and multi-strategy fusion approach is employed to achieve question-and-answer functionality in the intelligent question-and-answer assistant, thereby enhancing its understanding and responsiveness to user needs. Furthermore, a business logic tree is introduced to strengthen the intelligent question-and-answer assistant's retrieval capabilities and improve the efficiency and accuracy of retrieving public policy documents. By constructing a business logic tree structure, key information from policy documents is presented hierarchically, thereby enabling efficient retrieval and in-depth analysis of policy documents.
[0027] It should be noted that, in this embodiment of the application, the server corresponding to the intelligent question-answering assistant can serve as the execution entity of the method provided in this embodiment. For example, Figure 1 This diagram illustrates the structure of the server corresponding to the intelligent question-answering assistant. Figure 1As shown, the server includes a business logic tree management unit 11, an intelligent reasoning unit 12, an answer generation unit 13, and a feedback unit 14. The business logic tree management unit 11 can integrate knowledge data from multiple reliable data sources; the intelligent reasoning unit 12 can retrieve relevant information from the knowledge base based on the user's question-and-answer requirements and generate answer text based on its own knowledge base; the answer generation unit 13 displays the generated answer text to the user; and the feedback unit 14 can monitor and provide feedback on the execution of the solution.
[0028] Through the collaboration among the aforementioned units, the intelligent question-answering assistant can effectively provide reliable answers and reference knowledge sources when faced with a large number of complex policy documents.
[0029] The question-and-answer method provided in this application embodiment is described below, taking the server corresponding to the intelligent question-and-answer assistant as the execution subject.
[0030] Figure 2 A flowchart illustrating a question-and-answer method provided in one embodiment of this application is shown. Figure 2 As shown, the method may include the following steps S201 to S205: Step S201: Obtain the problem text.
[0031] In step S201, the question text is the question that the user inputs into the intelligent question-answering assistant. For example, the question text could be "Please explain what the key points of the economic policies issued by the state in 2025 are."
[0032] It should be noted that, in this embodiment of the application, the user can directly input the question text into the intelligent question-answering assistant, or input the corresponding voice, image, etc. into the intelligent question-answering assistant, so that the server can recognize the voice, image, etc. to identify the question text.
[0033] Step S202: Use the business logic tree corresponding to the target search knowledge base to obtain the first candidate answer text corresponding to the question text from the target search knowledge base.
[0034] In step S202, the search knowledge base is the knowledge base used by the server to search for answers to question texts. In this embodiment, the target search knowledge base can be selected by the user from multiple search knowledge bases based on their question-and-answer needs. For example, the user can select a "marketing script library," and the server can then query the answer text corresponding to the question text from the "marketing script library." In this embodiment, the server can also identify the user's question-and-answer intent and select a target search knowledge base that matches the intent from multiple search knowledge bases.
[0035] In step S202, the business logic tree is used to visualize the problem decomposition process through a hierarchical branching structure. In this embodiment, different business types correspond to different business logic trees, so that when searching for answers, using the business logic tree that matches the current business can improve the accuracy of answer searches.
[0036] It should be noted that, in this embodiment, the business logic tree is used to present professional knowledge. For corporate policy documents, they are presented through the business logic tree, which effectively extracts key information from complex corporate policy documents and provides explanations. This approach can improve the retrieval efficiency and accuracy of corporate policy information.
[0037] Step S203: Perform a similarity search on the target search knowledge base based on the question text to obtain the second candidate answer text.
[0038] To improve the accuracy of answer search, this embodiment of the application also performs text similarity search in the target search knowledge base, thereby searching for answers from the perspective of text semantics and strong text association, so as to improve the comprehensiveness of answer search.
[0039] Step S204: Obtain the target answer text from the first candidate answer text and the second candidate answer text, where the similarity between the target answer text and the question text is greater than the first similarity threshold.
[0040] In step S204, after searching for answers from the target search knowledge base from multiple dimensions, a similarity recognition method is used to filter out target answer texts with high similarity from candidate answer texts. That is, the server performs fine sorting on the recall results to achieve secondary filtering of answer texts and improve the accuracy of answer text search.
[0041] Step S205: Output the target answer text.
[0042] In step S205, after determining the target answer text, the server pushes the target answer text to the front-end page of the intelligent question-answering assistant, allowing the assistant to display it to the user. Furthermore, to enhance the user experience, the intelligent question-answering assistant can also output the target answer text using the same input method as the user's question text. For example, if the user inputs the question text via voice, the intelligent question-answering assistant can play the target answer text via voice. The intelligent question-answering assistant can also output the target answer text simultaneously using multiple methods. For instance, while displaying the target answer text on the interface, it can also play it via voice to further enhance the user experience.
[0043] Based on the scheme defined in steps S201 to S205, it can be understood that in this embodiment, the business logic tree can hierarchically display the knowledge in the professional knowledge base. Through the business logic tree, users can conduct business consultations within the scope of the professional knowledge base, improving the accuracy of professional knowledge queries. Furthermore, in this embodiment, the target answer text is determined jointly by the answer search results based on the business logic tree and the answer search results determined based on the similarity search between the question text and the target search knowledge base. This process employs a multi-level retrieval strategy, ensuring that the answer text can be accurately located in complex question-and-answer scenarios, while also recalling all key related information, reducing the risk of missed queries and improving the accuracy of data search.
[0044] The specific implementation process of the method provided in the embodiments of this application is described below.
[0045] In some embodiments, before retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base, the server corresponding to the intelligent question answering assistant may determine the target search knowledge base from multiple search knowledge bases in response to a knowledge base selection instruction.
[0046] For example, the question-and-answer page of the intelligent question-and-answer assistant displays multiple knowledge base tags, such as "marketing rhetoric library" and "policy knowledge base," for users to choose from. Users can select the target knowledge base tag from the multiple knowledge base tags according to their question-and-answer needs, and the server can then search for the answer from the target search knowledge base corresponding to that target knowledge base tag.
[0047] It should be noted that by setting knowledge base tags, users can flexibly select the search scope of answer text, improving the flexibility of knowledge search.
[0048] In some embodiments, before obtaining the first candidate answer text corresponding to the question text from the target search knowledge base using the business logic tree corresponding to the target search knowledge base, the server corresponding to the intelligent question answering assistant may also obtain summary description information corresponding to multiple search knowledge bases; and perform intent recognition on the question text to determine the user intent information corresponding to the question text; then, calculate the text similarity between the summary description information and the user intent information; and then determine the search knowledge base with the highest text similarity from multiple search knowledge bases to obtain the target search knowledge base.
[0049] In the above embodiments, each knowledge base has corresponding summary description information, which is used to describe the text contained in the knowledge base, such as the field involved in the text in the knowledge base, the scope of the knowledge base, the subject, the data structure, and the application scenario. For example, the summary description information for a medical knowledge base may be "This knowledge base integrates entities such as medical, symptoms, drugs, and examinations and their relationships, and adopts structured data storage, aiming to provide doctors with auxiliary diagnostic support and patients with reliable medical information query services."
[0050] It should be noted that, in the embodiments of this application, the summary description information corresponding to the search knowledge base can be obtained by summarizing the knowledge contained in the search knowledge base manually, or by the server performing semantic recognition and text integration on the text contained in the search knowledge base.
[0051] Furthermore, it should be noted that in this embodiment of the application, when the text in the search knowledge base is updated, for example, when the text in the search knowledge base is added, deleted, or modified, the server can perform semantic recognition on the updated text and update the summary description information corresponding to the search knowledge base according to the result of semantic recognition, so as to improve the accuracy of the summary description information of the search knowledge base.
[0052] In this embodiment, the server can perform preprocessing such as word segmentation and cleaning on the user's question text, and then use a pre-trained language model, such as the BERT model, to encode the question text into a vector representation rich in contextual semantics. Next, the vector is input into a classification network for inference to calculate the probability of it belonging to each predefined intent category. Finally, through post-processing such as threshold filtering, the intent label with the highest probability and confidence score are output, thereby accurately mapping natural language into structured user intent information. The entire process relies on labeled data for model fine-tuning to continuously improve the accuracy and robustness of recognition.
[0053] After obtaining the user intent information and the corresponding summary description information of each search knowledge base, the server calculates the text similarity between the user intent information and the corresponding summary description information of each search knowledge base, and selects the search knowledge base with the highest text similarity to obtain the target search knowledge base.
[0054] For example, Figure 3 A flowchart illustrating the process of determining the target search knowledge base is shown, such as... Figure 3As shown, the server first checks whether it has received a knowledge base selection instruction from the user. If it has, the server determines the target knowledge base from multiple knowledge bases based on the user's selection. If it has not received an instruction, the server determines the target knowledge base based on the user's intent information corresponding to the question text. The server first queries multiple specialized knowledge bases for knowledge bases where the text similarity between the summary description information and the user intent information is greater than a similarity threshold. If no such knowledge base is found, the server continues to query multiple general knowledge bases for knowledge bases where the text similarity between the summary description information and the user intent information is greater than a similarity threshold, and uses the retrieved knowledge base as the target knowledge base. If multiple knowledge bases are retrieved, or if no knowledge base is retrieved, the knowledge base with the highest text similarity is selected as the target knowledge base.
[0055] In some embodiments, after determining the target search knowledge base, the server can use the business logic tree corresponding to the target search knowledge base to obtain the first candidate answer text corresponding to the question text from the target search knowledge base. Specifically, the server performs entity recognition on the question text, extracts the question entity from the question text; sequentially traverses the nodes in the business logic tree to determine the target node that matches the question entity; and obtains the text pointed to by the target node from the target search knowledge base to obtain the first candidate answer text.
[0056] For example, the server first selects the corresponding business logic tree based on user intent information. For instance, if the user's question text is "What are the tax reduction and exemption benefits for high-tech enterprises?", and the server identifies the user's intent as "tax incentive policy inquiry," then it initiates the "tax inquiry logic tree." Then, starting from the root node of the business logic tree, it determines whether the information required for the current node (e.g., enterprise type, tax type, incentive type) is already implicitly contained in the user's original question text. If it determines that the information required for the current node is already implicitly contained in the user's original question text, it extracts key information (i.e., entities) from the question text using entity recognition technology, such as high-tech enterprises, corporate income tax, and tax reduction and exemption benefits, to answer the node's question. If the question text contains sufficient information, the server automatically selects the corresponding branch and moves to the next node. If the information is insufficient, the server proactively asks the user, for example, "Are you interested in corporate income tax or value-added tax?", and determines the next path based on the user's answer. This "determination-extraction-movement / clarification" process is repeated until a leaf node is reached. After reaching the leaf node, the server executes a predefined retrieval operation for that node, pointing to the knowledge base. Since the search scope has been narrowed down to a very small and highly relevant range, this search can directly hit the most accurate answer, namely the first candidate answer text.
[0057] It's important to note that when a user submits a query for policy documents, the server utilizes a pre-built business logic tree for retrieval. By matching the user's query with nodes in the business logic tree, the most relevant policy information is found. Furthermore, based on the associations between nodes in the business logic tree, more comprehensive policy information can be retrieved. Using the business logic tree to determine the first candidate answer text allows the query results to focus more on knowledge base tags, reducing omissions and improving the accuracy and reliability of the query results.
[0058] In some embodiments, the business logic tree can be determined as follows: the server first obtains the business document and the business type corresponding to the business document, and identifies the business elements in the business document; then, it constructs a tree structure corresponding to the business type based on the business elements; in response to the node labeling operation of the tree structure, it adjusts the nodes and / or edges in the tree structure to obtain the business logic tree.
[0059] In the above embodiments, the tree structure includes multiple nodes and edges between the multiple nodes. Each node is used to represent a business element, and the edges are used to represent the relationship between business elements.
[0060] For example, consider a corporate policy document. The server identifies the document content of the corporate policy document and extracts business elements, for example, using... Figure 4 Taking the business logic tree shown as an example, business elements include market access elements, business operation elements, internal control and compliance elements, and other elements. Then, the server performs a structured representation of corporate policy documents, with each node representing a specific business logic unit, and the relationships between nodes reflecting the inherent connections between business logics. Next, the server manually annotates the constructed business logic tree to ensure that each node accurately corresponds to the specific content of the policy document, thus enabling the business logic tree to accurately reflect the business logic structure of the policy document. Through the above method, the following can be obtained: Figure 4 The business logic tree shown.
[0061] In some embodiments, while extracting the first candidate answer text, the server can also perform a similarity search on the target search knowledge base based on the question text to obtain the second candidate answer text. In this embodiment, the second candidate answer text may include a third candidate answer text and a fourth candidate answer text. Specifically, the server first performs word segmentation on the question text to obtain at least one keyword, then segments the text in the target search knowledge base to obtain multiple knowledge slices; based on the relevance between the at least one keyword and the multiple knowledge slices, a third candidate answer text with a relevance score greater than a score threshold is determined from the multiple knowledge slices; simultaneously, the server can also obtain the text vector corresponding to the question text and the slice vectors corresponding to the multiple knowledge slices, and based on the similarity between the text vector and the slice vector, a fourth candidate answer text with a semantic similarity greater than a second similarity threshold is obtained from the multiple knowledge slices.
[0062] For example, the server can use the BM25 algorithm to search for the third candidate answer text. The server first preprocesses and segments documents in the target search knowledge base, dividing long documents into semantically complete and appropriately sized knowledge slices (such as paragraphs or sections) for precise location. Next, the server builds an inverted index for all these knowledge slices, recording which slices each keyword appears in, its location, and frequency. When the user enters the question text, the server performs similar word segmentation and preprocessing. Then, the BM25 algorithm begins its work, based on a probabilistic model, to perform retrieval by calculating the relevance score between each keyword in the question and each knowledge slice. This algorithm considers not only the frequency of keyword occurrences in the slice (term frequency) but also the prevalence of keywords across all slices (inverse document frequency) for weighting; for example, common words are assigned lower weights, while scarce and important words are assigned higher weights, thus effectively evaluating the overall relevance of the slices. Finally, the server ranks all knowledge slices according to the relevance scores calculated by the BM25 algorithm, returning the top-ranked slices as the most relevant search results to the user's question, providing an information basis for subsequent answer generation or refinement. This process enables the rapid and accurate retrieval of relevant contextual fragments from massive amounts of unstructured documents.
[0063] In this embodiment, the server also uses an embedding model (such as BERT or OpenAI's text-embedding model) to convert all pre-prepared knowledge slices into high-dimensional vector representations (i.e., slice vectors), each slice vector encapsulating deep semantic information of the corresponding text fragment. Subsequently, these slice vectors, along with their corresponding original text, are stored in a dedicated vector database (such as Milvus, Pinecone, or Weaviate). This database constructs an efficient index for all vectors (typically using approximate nearest neighbor algorithms such as HNSW or IVF-Flat) to support rapid searching within the massive amount of vectors. When a user inputs question text, the server uses the same embedding model to convert the question into a query vector (i.e., a text vector) in real time. Next, the vector database receives this text vector and performs an approximate nearest neighbor search in its index, quickly finding several slice vectors that are semantically closest to the text vector by calculating metrics such as cosine similarity or Euclidean distance. Finally, the server returns the original text fragments corresponding to these most similar vectors as retrieval results semantically related to the question. This method can capture "conceptual similarity," and can find relevant information based on semantic associations even if the question and knowledge slice do not have direct keyword overlap.
[0064] In some embodiments, after obtaining candidate answer texts from target search knowledge across multiple dimensions, the server can determine the target answer text for replying to the question text based on the obtained candidate answer texts. Specifically, the server generates a candidate answer text set based on the first, third, and fourth candidate answer texts; it performs word segmentation on the question text and the candidate answer texts in the candidate answer text set to obtain question word segments and answer word segments; then, based on the word segmentation weights corresponding to the question word segments and the answer word segments, it performs vector representation on the question word segments and the answer word segments to obtain question vectors and answer vectors; then, based on the similarity between the question vector and the answer vector, it obtains the target answer vector with a similarity greater than a first similarity threshold, and merges the question text and the target answer vector to obtain the target answer text; if the similarity between the question vector and the answer vector is less than or equal to the first similarity threshold, a preset text is used as the target answer text.
[0065] For example, the server selects the top K (e.g., 5) search results (i.e., candidate answer texts) from business logic tree matching, BM25 search, and vector retrieval, respectively, to form a candidate answer text set containing multiple candidate answer texts. Then, word segmentation is performed on the question text and the candidate answer texts in the candidate answer text set, respectively, to obtain question word segmentation and answer word segmentation. Next, based on a corpus containing all text, the server calculates a TF-IDF (Term Frequency-Inverse Document Frequency) weight for each word segment. This TF-IDF weight comprehensively considers term frequency (i.e., the importance of the word segment in the document) and inverse document frequency (i.e., the distinguishability of the word segment in the entire corpus), thus assigning each word a value that represents its importance. Then, using the TF-IDF weights calculated in the previous step, the server converts the question segment and the answer segment into high-dimensional numerical vectors, i.e., word vectors, respectively, obtaining the question vector corresponding to the question segment and the answer vector corresponding to the answer segment. Each dimension of the vector corresponds to a word in the vocabulary, and its value is the TF-IDF weight of that word in the corresponding text. In this way, each piece of text is mapped to a point in the vector space.
[0066] Next, the server uses a cosine similarity algorithm to calculate the similarity between each question vector and each answer vector. This algorithm assesses the semantic similarity by measuring the cosine of the angle between two vectors in a given direction, effectively avoiding bias caused by differences in text length. The value ranges from 0 to 1, with higher values indicating stronger semantic similarity. Finally, the server performs a re-ranking based on similarity. The server collects the cosine similarity scores between all knowledge slices and the question text and sorts them from highest to lowest score. By setting a threshold or selecting Top-K results, a secondary screening and fine-ranking of the candidate answer text set is completed, ultimately outputting a list of knowledge slices that are most relevant and best matched to the question text at the lexical statistical level.
[0067] For example, the server can obtain a set of candidate knowledge points with a similarity greater than 0.75, merge them according to the format of title: slice content; combine the merged knowledge, question text, and prompt words together, and input them into a large model for answer reasoning; if the similarity is greater than 0.75, the result of the large model's reasoning and the cited reference source information are displayed to the user, completing the question-and-answer interaction. If the similarity is less than or equal to 0.75, a fallback statement is output to the user, indicating that no corresponding answer was found in the knowledge base.
[0068] For example, Figure 5 A complete flowchart of the question-and-answer method provided in the embodiments of this application is shown, such as... Figure 5 As shown, the process includes the following steps S501 to S507: Step S501: The server obtains the question text input by the user; Step S502: The server determines the target search knowledge base based on the user intent corresponding to the question text; In step S503, the server uses multiple strategies such as business logic tree, BM25, and vector retrieval to retrieve data from the target search knowledge base and obtain a set of candidate answer texts. Step S504: Perform secondary scoring and sorting on the candidate answer texts in the candidate answer text set to obtain a sorting result. In this sorting result, the candidate answer texts are arranged in descending order of similarity. Step S505: Compare the similarity of candidate answer texts with a similarity threshold based on the sorting results to obtain the threshold comparison result; if the similarity is greater than the similarity threshold, proceed to step S506; otherwise, proceed to step S507. Step S506: Perform answer reasoning and answer generation on the candidate answer text to obtain the target answer text; Step S507: Use the catch-all answer text as the target answer text.
[0069] This concludes the introduction of the methods provided in the embodiments of this application.
[0070] As can be seen from the above, the solution provided in this application embodiment supports users in conducting business consultations within a specified professional knowledge base, thereby improving the accuracy of knowledge search. Furthermore, in this application embodiment, a business logic tree strategy is introduced for knowledge matching and retrieval, improving the recall rate of related knowledge. In addition, in this application embodiment, business logic trees, literal search, and vector search results are combined to construct TF-IDF vectors for secondary ranking of results, effectively improving the accuracy of knowledge search.
[0071] Based on the question-and-answer method provided in the above embodiments, this application also provides specific implementations of the question-and-answer device. Please refer to the following embodiments.
[0072] First see Figure 6 The question-and-answer device 600 provided in this application embodiment includes: a data acquisition module 601, a first search module 602, a second search module 603, an answer acquisition module 604, and an answer output module 605.
[0073] Data acquisition module 601 is used to acquire the question text and the target search knowledge base; The first search module 602 is used to obtain the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; The second search module 603 is used to perform a similarity search on the target search knowledge base based on the question text to obtain the second candidate answer text. The answer acquisition module 604 is used to acquire the target answer text from the first candidate answer text and the second candidate answer text, which has a similarity greater than a similarity threshold with the question text; The answer output module 605 is used to output the target answer text.
[0074] In some embodiments, the first search module is specifically used to perform entity recognition on the question text, extract the question entity from the question text; sequentially traverse the nodes in the business logic tree to determine the target node that matches the question entity; and obtain the text pointed to by the target node from the target search knowledge base to obtain the first candidate answer text.
[0075] In some embodiments, the question-answering device further includes: a logic tree construction module, configured to obtain a business document and the business type corresponding to the business document; identify business elements in the business document; construct a tree structure corresponding to the business type based on the business elements, wherein the tree structure includes multiple nodes and edges between multiple nodes, each node is used to represent a business element, and the edges are used to represent the association relationship between business elements; and adjust the nodes and / or edges in the tree structure in response to the node labeling operation of the tree structure to obtain a business logic tree.
[0076] In some embodiments, the second candidate answer text includes a third candidate answer text and a fourth candidate answer text. The second search module is specifically used to perform word segmentation on the question text to obtain at least one keyword; to perform slicing on the text in the target search knowledge base to obtain multiple knowledge slices; to determine the third candidate answer text with a relevance score greater than a score threshold from the multiple knowledge slices based on the relevance between the at least one keyword and the multiple knowledge slices; to obtain the text vector corresponding to the question text and the slice vector corresponding to the multiple knowledge slices; and to obtain the fourth candidate answer text with a semantic similarity greater than a second similarity threshold from the multiple knowledge slices based on the similarity between the text vector and the slice vector.
[0077] In some embodiments, the answer acquisition module is specifically used to generate a candidate answer text set based on the first candidate answer text, the third candidate answer text, and the fourth candidate answer text; to perform word segmentation on the question text and the candidate answer text in the candidate answer text set respectively, to obtain question word segments and answer word segments; to perform vector representation on the question word segments and answer word segments based on the word segmentation weights corresponding to the question word segments and the word segmentation weights corresponding to the answer word segments, to obtain question vectors and answer vectors; to obtain the target answer vector with a similarity greater than a first similarity threshold based on the similarity between the question vector and the answer vector; and to merge the question text and the target answer vector to obtain the target answer text.
[0078] In some embodiments, the answer acquisition module is further configured to use preset text as the target answer text when the similarity between the question vector and the answer vector is less than or equal to a first similarity threshold.
[0079] In some embodiments, the question-answering device further includes: a first determining module, configured to determine a target search knowledge base from multiple search knowledge bases in response to a knowledge base selection instruction before obtaining a first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base.
[0080] In some embodiments, the question-answering device further includes: a second determining module, configured to: obtain summary description information corresponding to multiple search knowledge bases before obtaining the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; perform intent recognition on the question text to determine the user intent information corresponding to the question text; calculate the text similarity between the summary description information and the user intent information; and determine the search knowledge base with the highest text similarity from the multiple search knowledge bases to obtain the target search knowledge base.
[0081] The various modules of the question-and-answer device provided in this application embodiment can achieve Figure 2 It provides functionality for each step of the question-and-answer method and achieves the corresponding technical effects. For the sake of brevity, it will not be elaborated here.
[0082] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0083] The electronic device 700 may include a processor 701 and a memory 702 storing computer program instructions.
[0084] Specifically, the processor 701 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0085] Memory 702 may include mass storage for data or instructions. For example, and not limitingly, memory 702 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 702 may include removable or non-removable (or fixed) media. Where appropriate, memory 702 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 702 is non-volatile solid-state memory.
[0086] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Thus, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.
[0087] The processor 701 implements any of the question-and-answer methods described in the above embodiments by reading and executing computer program instructions stored in the memory 702.
[0088] In some examples, the electronic device 700 may also include a communication interface 703 and a bus 704. For example, Figure 7 As shown, the processor 701, memory 702, and communication interface 703 are connected through bus 704 and complete communication with each other.
[0089] The communication interface 703 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0090] Bus 704 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, bus 704 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 704 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0091] For example, the electronic device 700 can be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc.
[0092] The electronic device 700 can execute the question-and-answer method in the embodiments of this application, thereby achieving a combination Figure 2 The question-and-answer method described.
[0093] In addition, in conjunction with the question-and-answer methods in the above embodiments, this application also provides a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the question-and-answer methods in the above embodiments. Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, etc.
[0094] This application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, they implement any of the question-and-answer methods described in the above embodiments.
[0095] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0096] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0097] This application also provides a computer program product, including a computer program, which, when executed, implements any of the question-and-answer methods described in the above embodiments.
[0098] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0099] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable question-and-answer device to create a machine such that these instructions, executable via the processor of the computer or other programmable question-and-answer device, enable the implementation of the function / action specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, can also be implemented by special-purpose hardware performing the specified function or action, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0100] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A question-and-answer method, characterized in that, include: Get the problem text; The first candidate answer text corresponding to the question text is obtained from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; Based on the question text, a similarity search is performed on the target search knowledge base to obtain the second candidate answer text; From the first candidate answer text and the second candidate answer text, obtain the target answer text whose similarity to the question text is greater than a first similarity threshold; Output the target answer text.
2. The method according to claim 1, characterized in that, The step of retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base includes: Entity recognition is performed on the question text to extract question entities from the question text; The nodes in the business logic tree are traversed sequentially to determine the target node that matches the problem entity; The text pointed to by the target node is obtained from the target search knowledge base to obtain the first candidate answer text.
3. The method according to claim 2, characterized in that, The method further includes: Obtain the business document and the corresponding business type; Identify the business elements in the business document; Based on the business elements, a tree structure corresponding to the business type is constructed, wherein the tree structure includes multiple nodes and edges between the multiple nodes, each node is used to represent the business element, and the edges are used to represent the association relationship between the business elements; In response to the node labeling operation of the tree structure, the nodes and / or edges in the tree structure are adjusted to obtain the business logic tree.
4. The method according to claim 1, characterized in that, The second candidate answer text includes a third candidate answer text and a fourth candidate answer text. The step of performing a similarity search on the target search knowledge base based on the question text to obtain the second candidate answer text includes: The question text is segmented to obtain at least one keyword; The text in the target search knowledge base is sliced to obtain multiple knowledge slices; Based on the relevance between the at least one keyword and the plurality of knowledge slices, a third candidate answer text with a relevance score greater than a score threshold is determined from the plurality of knowledge slices; Obtain the text vector corresponding to the question text and the slice vector corresponding to the multiple knowledge slices; Based on the similarity between the text vector and the slice vector, a fourth candidate answer text with a semantic similarity greater than a second similarity threshold is obtained from the multiple knowledge slices.
5. The method according to claim 4, characterized in that, The step of obtaining the target answer text from the first candidate answer text and the second candidate answer text, where the similarity between the target answer text and the question text is greater than a first similarity threshold, includes: A candidate answer text set is generated based on the first candidate answer text, the third candidate answer text, and the fourth candidate answer text; The question text and the candidate answer text in the candidate answer text set are respectively processed by word segmentation to obtain question word segmentation and answer word segmentation; Based on the segmentation weights corresponding to the question segmentation and the answer segmentation, vector representations are performed on the question segmentation and the answer segmentation to obtain question vectors and answer vectors. Based on the similarity between the question vector and the answer vector, obtain the target answer vector whose similarity is greater than the first similarity threshold; The question text and the target answer vector are merged to obtain the target answer text.
6. The method according to claim 5, characterized in that, The method further includes: If the similarity between the question vector and the answer vector is less than or equal to the first similarity threshold, a preset text is used as the target answer text.
7. The method according to any one of claims 1 to 6, characterized in that, Before retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base, the method further includes: In response to a knowledge base selection instruction, the target search knowledge base is determined from multiple search knowledge bases.
8. The method according to any one of claims 1 to 6, characterized in that, Before retrieving the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base, the method further includes: Obtain summary description information corresponding to multiple search knowledge bases; The question text is subjected to intent recognition to determine the user intent information corresponding to the question text; Calculate the text similarity between the summary description information and the user intent information; The target search knowledge base is obtained by determining the search knowledge base with the highest text similarity from the multiple search knowledge bases.
9. A question-and-answer device, characterized in that, include: The data acquisition module is used to acquire the question text and the target search knowledge base; The first search module is used to obtain the first candidate answer text corresponding to the question text from the target search knowledge base using a business logic tree corresponding to the target search knowledge base; The second search module is used to perform a similarity search on the target search knowledge base based on the question text to obtain the second candidate answer text. The answer acquisition module is used to acquire the target answer text from the first candidate answer text and the second candidate answer text, which has a similarity greater than a similarity threshold with the question text; The answer output module is used to output the target answer text.
10. An electronic device, characterized in that, The device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the question-and-answer method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, implement the question-and-answer method as described in any one of claims 1-8.
12. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device is able to perform the question-and-answer method as described in any one of claims 1-8.