Question and answer method, device and electronic equipment
By extracting fine-grained, coarse-grained, and personalized recall knowledge from the knowledge base to generate prompt words, and inputting them into a large language model, the problem of insufficient answer accuracy in existing technologies is solved, and more accurate answer generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2023-10-24
- Publication Date
- 2026-06-02
AI Technical Summary
In the existing technology, the accuracy of answers in question-answering methods of electronic devices still needs to be improved, especially when it comes to understanding complex questions and questions outside the knowledge base, it is difficult to provide accurate answers.
By acquiring fine-grained, coarse-grained, and personalized recall knowledge from a pre-built knowledge base, prompt words are generated based on this knowledge and then fed into a large language model to obtain the answer.
It improves the accuracy of answers by generating more reference words through multi-dimensional recall of knowledge and information to be answered, thereby enhancing the answer generation capability of the large language model.
Smart Images

Figure CN117194646B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a question-and-answer method, apparatus, and electronic device. Background Technology
[0002] With the development of artificial intelligence (AI) technology, people are increasingly relying on it to complete everyday tasks. For example, users can ask questions to the voice assistants of electronic devices (such as computers, mobile phones, and tablets) to quickly obtain answers. One approach involves a text preprocessing module based on natural language processing (NLP) technology to understand the user's question, retrieve relevant information from a knowledge base, match appropriate prompts to the question, fill the retrieved information into a corresponding prompt template to obtain the answer, and finally use speech synthesis technology to convert the text into speech and output it to the user. However, the accuracy of the answers in this approach still needs improvement. Summary of the Invention
[0003] In view of the above problems, this application proposes a question-and-answer method, apparatus, and electronic device to improve the above problems.
[0004] In a first aspect, this application provides a question-answering method applied to an electronic device. The method includes: obtaining information to be answered; obtaining recall knowledge related to the information to be answered from a pre-built knowledge base, the recall knowledge including fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge; obtaining prompt words based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge; and inputting the prompt words into a large language model to obtain the answer corresponding to the information to be answered.
[0005] Secondly, this application provides a question-answering device operating in an electronic device, the device comprising: a question-to-answer information acquisition unit for acquiring question-to-answer information; a knowledge acquisition unit for acquiring knowledge related to the question-to-answer information from a pre-built knowledge base, the knowledge including fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge; a prompt word acquisition unit for obtaining prompt words based on the question-to-answer information, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge; and an answer acquisition unit for inputting the prompt words into a large language model to obtain the answer corresponding to the question-to-answer information.
[0006] Thirdly, this application provides an electronic device including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the methods described above.
[0007] Fourthly, this application provides a computer-readable storage medium storing program code, wherein the above-described method is executed when the program code is run.
[0008] This application provides a question-answering method, apparatus, electronic device, and storage medium. After obtaining information to be answered, it retrieves fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge related to the information to be answered from a pre-built knowledge base. Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, it obtains prompt words. The prompt words are then input into a large language model to obtain the answer corresponding to the information to be answered. This method allows prompt words to be obtained based on multi-dimensional recall knowledge and information to be answered, thus providing more reference points for the answer. Consequently, the large language model can obtain the answer based on prompt words containing more reference points, improving the accuracy of the answer. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 A flowchart of a question-and-answer method proposed in an embodiment of this application is shown;
[0011] Figure 2 This illustration shows a method for obtaining information to be answered, as proposed in this application.
[0012] Figure 3 A schematic diagram illustrating a method for acquiring fine-grained recall knowledge as proposed in this application is shown.
[0013] Figure 4 A schematic diagram of a knowledge base storage structure proposed in this application is shown;
[0014] Figure 5 A schematic diagram of a prompt word proposed in this application is shown;
[0015] Figure 6 A schematic diagram illustrating a method for obtaining answers using a large language model, as proposed in this application, is shown.
[0016] Figure 7 A schematic diagram of a scenario for generating answers according to this application is shown;
[0017] Figure 8A flowchart of a question-and-answer method according to another embodiment of this application is shown;
[0018] Figure 9 A schematic diagram illustrating a method for calculating similarity using a large language model, as proposed in this application, is shown.
[0019] Figure 10 A structural block diagram of a question-and-answer device according to an embodiment of this application is shown;
[0020] Figure 11 A structural block diagram of an electronic device proposed in this application is shown;
[0021] Figure 12 This is a storage unit in this application embodiment for storing or carrying program code that implements the question-and-answer method according to this application embodiment. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0023] With the widespread use of electronic devices (such as computers, mobile phones, and tablets), people have begun to rely on them to complete some daily tasks. For example, users can ask questions to the voice assistants of their electronic devices to quickly obtain answers. One approach involves a text preprocessing module based on natural language processing technology to understand the user's question, retrieve relevant information from a knowledge base, match appropriate prompts to the user's question, fill the retrieved information into the corresponding prompt template to obtain the answer, and finally use speech synthesis technology to convert the text into speech and output it to the user. However, the accuracy of the answers in this approach still needs improvement.
[0024] The inventors discovered in their research that the accuracy of answers obtained through these methods needs improvement. For example, natural language processing technology may fail to accurately understand complex questions; furthermore, obtaining answers from knowledge base retrieval may not be able to handle questions not found in the knowledge base.
[0025] Therefore, the inventors have proposed a question-answering method, apparatus, and electronic device as described in this application. After obtaining the information to be answered, fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge related to the information to be answered are retrieved from a pre-built knowledge base. Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, prompt words are obtained. The prompt words are then input into a large language model to obtain the answer corresponding to the information to be answered. This method allows prompt words to be obtained based on multi-dimensional recall knowledge and the information to be answered, thereby increasing the number of references available for the answer in the prompt words. This enables the large language model to obtain the answer based on prompt words containing more references, improving the accuracy of the answer.
[0026] To better understand the solutions of the embodiments of this application, the technical terms used in the embodiments of this application will be explained below.
[0027] LLM (Large Language Model): This refers to a deep learning model trained on a large amount of text data. LLMs can generate natural language text or understand the meaning of language text, and are typically used to handle various natural language tasks, such as text classification, question answering, and dialogue. For example, a large language model could be the ChatGPT (Chat Generative Pre-trained Transformer) model.
[0028] In-Context Learning (ICL) refers to a method of estimating conditional probability distributions given examples using a well-trained language model. ICL provides the language model with a "prompt," which can be a list of input-output pairs. Each input-output pair can be an example that describes a task. At the end of the prompt, there can be a test input, allowing the language model to predict the corresponding output solely based on the prompt.
[0029] The embodiments of this application will now be described in conjunction with the accompanying drawings.
[0030] Please see Figure 1 This application provides a question-and-answer method applied to an electronic device, the method comprising:
[0031] S110: Obtain information to be answered.
[0032] In this context, the query information can refer to the references used to generate the answer. The query information center can contain the user's intent, which can refer to the user's intention to achieve a certain goal. For example, when the query information is "What is the mechanism by which mannitol reduces intracranial hypertension?", the user's intent could be to understand the mechanism by which mannitol reduces intracranial hypertension.
[0033] As one method, users can directly input the information to be answered into the electronic device.
[0034] Optionally, users can directly input the information to be answered into the electronic device via voice interaction. For example, the electronic device can be equipped with a voice assistant, and users can call out the voice assistant's name. After receiving a response from the voice assistant, users can directly tell the voice assistant the information to be answered via voice.
[0035] Optionally, users can directly input the information to be answered into the electronic device via text input. For example, such as... Figure 2 As shown in the left image, the screen of the electronic device can display cards such as smart Q&A and map navigation. Users can access these features by clicking on the smart Q&A card. Figure 2 The image on the right shows the input interface for the information to be answered. You can directly input the information to be answered into this interface by typing text.
[0036] As another approach, users can indirectly input the information to be answered into the electronic device through other devices. For example, a user can wear a VR (Virtual Reality) device (such as VR glasses), which can make the content displayed on the electronic device appear in three dimensions. The user can select content on the electronic device through head movements, etc. When the user selects a card representing a smart question and answer, they can enter the input interface for the information to be answered, and input the information to be answered through gestures or other means.
[0037] S120: Obtain recall knowledge related to the information to be answered from a pre-built knowledge base, wherein the recall knowledge includes fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge.
[0038] The knowledge base can contain knowledge from professional fields and knowledge from private fields. Knowledge from professional fields can refer to common knowledge, truths, etc., that are universally accepted within the corresponding field, while knowledge from private fields can refer to knowledge that varies from person to person based on individual user behavior, living environment, etc. The knowledge base can be a vector database, which is a key-value pair database. That is, in the knowledge base, each piece of knowledge can be stored as the original text and the corresponding original text vector.
[0039] Fine-grained knowledge recall can refer to knowledge retrieved through non-generalization methods, such as matching keywords within the knowledge; coarse-grained knowledge recall can refer to knowledge retrieved through generalization methods, such as matching the entire knowledge; personalized knowledge recall can refer to knowledge obtained based on a user's personal historical query records. For example, if a user is a professional financial practitioner, then financial knowledge related to the user's unanswered information can be used as personalized knowledge recall.
[0040] One approach is to obtain the keywords to be queried, which can represent the important content of the information to be answered; match the keywords to be queried with the corresponding keywords of multiple original texts to obtain fine-grained recall knowledge; match the information to be answered with multiple original texts, and use the successfully matched original texts as coarse-grained recall knowledge; match the information to be answered with historical recall knowledge, and use the successfully matched historical recall knowledge as personalized recall knowledge, which can represent the user's knowledge preferences.
[0041] Optionally, the query keywords and the keywords corresponding to each of the multiple original texts can be obtained based on traditional natural language processing techniques (such as the BERT model).
[0042] Optionally, to speed up keyword matching, the keywords corresponding to each piece of knowledge can be obtained in advance and each piece of knowledge can be associated with the corresponding keywords and stored in the knowledge base.
[0043] As a way to acquire fine-grained recall knowledge, such as Figure 3 As shown, the following steps can be taken: First, obtain the query vector corresponding to the query keyword; second, obtain multiple keyword vectors from the knowledge base, where each keyword vector corresponds one-to-one with a keyword; third, obtain the similarity between the query vector and each of the multiple keyword vectors to obtain multiple first similarity scores, which characterize the degree of matching between the query vector and the corresponding keyword; fourth, obtain the target keyword based on the multiple first similarity scores, where the target keyword can be the keyword corresponding to the keyword vector ranked in the first similarity order from high to low (e.g., the first K positions, where K is an integer); and fifth, use the original text corresponding to the target keyword as fine-grained knowledge retrieval.
[0044] Optionally, when multiple first similarity scores are obtained, the query vector can be directly compared with each keyword vector one by one to obtain multiple first similarity scores.
[0045] Optionally, multiple first similarity scores can be obtained based on vector similarity measurement methods (such as Euclidean distance, cosine distance, etc.).
[0046] Optionally, the query vector and multiple keyword vectors can be input into a large language model, and multiple first similarity scores can be obtained based on the output of the large language model.
[0047] Optionally, the query keyword and multiple keywords can be input into the embedding model to obtain the query vector and multiple keyword vectors, respectively. The embedding model can refer to a large language model used to convert text into vectors.
[0048] Optionally, to speed up keyword matching, the keyword vector corresponding to each piece of knowledge can be obtained in advance, and the keywords of each piece of knowledge can be associated with the corresponding keyword vector and stored in the knowledge base.
[0049] At the same time, such as Figure 4 As shown, the multiple keyword vectors in the knowledge base can be stored in a tree index. This tree index can include nodes at multiple levels, each node corresponding to a summary / featured description. The summary vector represents a summary of the keywords corresponding to all nodes at that level. Therefore, multiple first similarities can be obtained through tree-based matching.
[0050] Optionally, the tree-structured matching method can be as follows: obtain the similarity between the query vector and the summary vector corresponding to the root node; determine the next level matching node of the root node based on the similarity, and the matching node is the node that successfully matches the query vector; continue to obtain the similarity between the query vector and the summary vector of the next level matching node, until the similarity between the query vector and multiple keyword vectors is obtained, so as to obtain multiple first similarities.
[0051] For example, when accessing knowledge in a knowledge base, one can start from the root node and search downwards. For instance, when the question to be answered is "What is the weather like in Beijing today?", one can start searching from the root node, find child nodes related to "Beijing" and "weather", and continue searching downwards until finally obtaining the knowledge related to the question to be answered and returning it.
[0052] As a method for obtaining coarse-grained recall knowledge, it can obtain the answer vector corresponding to the information to be answered; obtain multiple original text vectors in the knowledge base; obtain the similarity between the answer vector and multiple original text vectors respectively to obtain multiple third similarities, which can characterize the degree of matching between the answer vector and the corresponding original text; obtain the successfully matched original text based on multiple third similarities, which can be the original text vectors ranked in the first specified position (e.g., the first M positions, where M is an integer) according to the order of third similarity from high to low; and thus obtain coarse-grained recall knowledge.
[0053] As a method for acquiring personalized recall knowledge, knowledge in the knowledge base that is the same as or similar to historical feedback knowledge can be used as historical recall knowledge. Historical feedback knowledge can be the original text that successfully matched the historical information to be answered during the historical question-and-answer process. The method involves: obtaining the answer vector corresponding to the information to be answered; obtaining multiple historical original text vectors in the knowledge base, where each historical original text vector can correspond one-to-one with historical recall knowledge; obtaining the similarity between the answer vector and multiple historical original text vectors to obtain multiple second similarities, which can characterize the degree of matching between the query vector and the corresponding historical recall knowledge; and obtaining successfully matched historical recall knowledge based on multiple second similarities. The successfully matched historical recall knowledge can be the historical recall knowledge corresponding to the historical original text vector ranked in descending order of second similarity (e.g., the first N positions, where N is an integer).
[0054] Knowledge similar to historical feedback knowledge can be understood as knowledge within the same domain as historical feedback knowledge. For example, if the historical feedback knowledge is "a 99.5% ethanol solution can be called anhydrous ethanol," then the historical feedback knowledge can be identified as belonging to the field of chemistry, and knowledge from the field of chemistry can be considered as knowledge similar to historical feedback knowledge.
[0055] In this embodiment, before calculating the similarity between vectors, the information to be answered can be split into multiple sub-information pieces using a query planner. The information to be answered is then concatenated with these sub-information pieces. The concatenated information is then matched against a knowledge base to obtain fine-grained, coarse-grained, and personalized knowledge, thereby improving the accuracy of the obtained knowledge. For example, the information to be answered can be a Query, the sub-information pieces can be {sub query1; sub query2; sub query3}, and the concatenated information can be Query: subquery1; sub query2; sub query3.
[0056] In the embodiments of this application, by acquiring fine-grained recall knowledge, the recalled knowledge can be more relevant to the information to be answered, thus reducing the error rate; by acquiring coarse-grained recall knowledge, knowledge that is not completely matched with the information to be answered but has a certain relevance can be obtained, thus improving generalization; by acquiring personalized recall knowledge, recall knowledge that is related to the information to be answered and related to the user's knowledge preferences can be obtained, thus enhancing the user's personalized experience.
[0057] S130: Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, prompt words are obtained.
[0058] One approach is to remove duplicate knowledge from fine-grained, coarse-grained, and personalized recall knowledge to obtain the remaining knowledge; based on the remaining knowledge, the search results are obtained; based on the information to be answered and the intent analysis results corresponding to the information to be answered, the user analysis is obtained, which is obtained by inputting the information to be answered into a large language model; pre-configured background introduction, task description, and answer requirements are obtained; based on the background introduction, task description, answer requirements, search results, and user analysis, prompt words are obtained.
[0059] The background information section informs the large language model of its current role, tasks, and context. For example, in the question-answering scheme of this application, the background information could be: "The role the model needs to play now is an intelligent question-answering assistant based on existing knowledge, providing appropriate answers to users on the current electronic device. The current user's geographical location is Chengdu, and the user is a minor." The task description section informs the large language model of the content in the prompts that can be used as the basis for answer reasoning. For example, in the question-answering scheme of this application, the task description could be: "When answering user questions, the model needs to refer to the background information section, the answer requirements section, the search results section, and the user analysis section." The answer requirements section informs the large language model of the evaluation criteria and format of the answer. For example, in the question-answering scheme of this application, the answer requirements section could be: "The answer needs to be concise and gentle in tone, and the generated answer format is JSON text." For example, the prompts could be as follows: Figure 5 As shown.
[0060] S140: Input the prompt words into the large language model to obtain the answer corresponding to the information to be answered.
[0061] As a way, such as Figure 6 As shown, prompt words can be input into a large language model to obtain the answer corresponding to the information to be answered. The scenario for obtaining the answer can be as follows: Figure 7 As shown.
[0062] In the embodiments of this application, by using large language models and knowledge base retrieval technology, it is possible to better understand the user's question and generate a more accurate answer.
[0063] This embodiment provides a question-answering method that, after obtaining information to be answered, retrieves fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge related to the information to be answered from a pre-built knowledge base. Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, prompt words are obtained. The prompt words are then input into a large language model to obtain the answer corresponding to the information to be answered. This method allows prompt words to be obtained based on multi-dimensional recall knowledge and information to be answered, thus providing more reference points for the answer. Consequently, the large language model can obtain the answer based on prompt words containing more reference points, improving the accuracy of the answer.
[0064] Please see Figure 8 This application provides a question-and-answer method applied to an electronic device, the method comprising:
[0065] S210: Obtain content from the professional domain knowledge base and the private domain knowledge base as reference content, wherein the content of the professional domain knowledge base and the private domain knowledge base is in natural language description format.
[0066] One approach is to obtain content from professional domain knowledge bases via the internet, or to obtain content from private domain knowledge bases by acquiring user behavior on electronic devices.
[0067] For example, the content in the professional domain knowledge base could be "The temperature in Beijing on January 1, 2023 was 10℃", while the content in the private domain knowledge base could be "My Signals and Systems notes from last month were XXX".
[0068] S220: Based on the large language model, the reference content is transformed into multiple pieces of knowledge in the knowledge base, wherein the knowledge is in application programming interface format.
[0069] As one approach, pre-set format conversion examples and reference content can be input into a large language model to obtain multiple pieces of knowledge from the knowledge base.
[0070] The format conversion example can be used to guide the large language model on how to obtain the corresponding output based on the input. For example, the format conversion example can be: "Reference content: The temperature in Beijing on January 1, 2023 was 10℃, Knowledge: Get Beijing temperature (date): Temperature content." Then, when the input reference content is "My Signals and Systems notes last month were XXX", the knowledge output by the large language model in the form of an Application Programming Interface (API) can be "My notes (subject, time range): Note content".
[0071] The parentheses contain the format parameters of the knowledge. For knowledge that states facts, the statement parameters in the parentheses can be empty.
[0072] S230: Obtain the similarity between each piece of knowledge and the corresponding summary of each of the multiple levels.
[0073] As a way, such as Figure 9 As shown, the similarity between each piece of knowledge and the corresponding summaries at multiple levels can be calculated based on a large language model.
[0074] S240: Determine the level of each piece of knowledge based on the similarity between each piece of knowledge and the corresponding summary of each of the multiple levels.
[0075] As one approach, based on the similarity between each piece of knowledge and the corresponding summaries at multiple levels, the level with the highest similarity is used as the level where the corresponding knowledge resides, in order to store each piece of knowledge.
[0076] Optionally, if the similarity between existing knowledge and multiple current levels is lower than a preset value, a new level can be created to store that knowledge.
[0077] Optionally, if there is overlap or conflict between the knowledge and existing knowledge in the level with the highest similarity, the knowledge can be merged with the content of existing knowledge in the corresponding level through a large language model. Merging can refer to summarizing the commonalities between the knowledge and the content of existing knowledge in the corresponding level to generate a new summary for the corresponding level.
[0078] S250: Store each piece of knowledge in a node at the corresponding level to obtain the knowledge base.
[0079] One approach is to store each piece of knowledge in a node at the corresponding level to create a knowledge base.
[0080] S260: Retrieve information to be answered.
[0081] S270: Obtain recall knowledge related to the information to be answered from a pre-built knowledge base, wherein the recall knowledge includes fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge.
[0082] S280: Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, prompt words are obtained.
[0083] S290: Input the prompt words into the large language model to obtain the answer corresponding to the information to be answered.
[0084] This embodiment provides a question-answering method that, through the aforementioned approach, allows for the generation of prompt words based on multi-dimensional recalled knowledge and information to be answered. This results in a wider range of prompt words that can be used as references for the answer, enabling the large language model to obtain the answer based on prompt words containing more references, thus improving the accuracy of the answer. Furthermore, in this embodiment, by converting the content from professional domain knowledge bases and private domain knowledge bases into API format and storing it in the knowledge base, it is more conducive to the large language model's understanding of knowledge, thereby generating more accurate answers. Simultaneously, storing knowledge in a tree structure allows for more effective management and organization of large amounts of knowledge, further enhancing the large language model's understanding of knowledge and generating more accurate answers.
[0085] Please see Figure 10 This application provides a question-and-answer device 600, which operates in an electronic device. The device 600 includes:
[0086] The unanswered information acquisition unit 610 is used to acquire unanswered information.
[0087] The knowledge acquisition unit 620 is used to acquire knowledge related to the information to be answered from a pre-built knowledge base, including fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge.
[0088] The prompt word acquisition unit 630 is used to obtain prompt words based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge.
[0089] The answer acquisition unit 640 is used to input the prompt words into the large language model to obtain the answer corresponding to the information to be answered.
[0090] In one approach, the knowledge acquisition unit 620 is specifically used to acquire keywords to be queried, which represent important content in the information to be answered; to match the keywords to be queried with the keywords corresponding to each of the plurality of original texts to obtain the fine-grained recall knowledge; to match the information to be answered with the plurality of original texts, and to use the successfully matched original texts as the coarse-grained recall knowledge; and to match the information to be answered with historical recall knowledge, and to use the successfully matched historical recall knowledge as the personalized recall knowledge, where the historical recall knowledge is the original text representing the user's knowledge preferences.
[0091] Optionally, the knowledge acquisition unit 620 is specifically used to acquire the query vector corresponding to the query keyword; acquire multiple keyword vectors in the knowledge base, wherein the keyword vectors correspond one-to-one with the keywords; acquire the similarity between the query vector and the multiple keyword vectors respectively to obtain the multiple first similarities, wherein the first similarity characterizes the degree of matching between the query vector and the corresponding keyword; obtain the target keyword based on the multiple first similarities, wherein the target keyword is the keyword corresponding to the keyword vector ranked first in descending order of the first similarity; and use the original text corresponding to the target keyword as the fine-grained recall knowledge.
[0092] Optionally, the multiple keyword vectors in the knowledge base are stored in a tree structure, which includes nodes at multiple levels. Each node at each level corresponds to a summary vector, which represents a summary of the keywords corresponding to all nodes at the corresponding level. The knowledge acquisition unit 620 is specifically used to obtain the similarity between the query vector and the summary vector corresponding to the root node; determine the matching node at the next level of the root node based on the similarity, where the matching node is the node that successfully matches the query vector; continue to obtain the similarity between the query vector and the summary vector of the matching node at the next level, until the similarity between the query vector and the multiple keyword vectors is obtained, so as to obtain the multiple first similarities.
[0093] Optionally, the knowledge acquisition unit 620 is specifically used to take knowledge in the knowledge base that is the same as or similar to historical feedback knowledge as the historical recall knowledge, wherein the historical feedback knowledge is the original text that successfully matched the historical information to be answered during the historical question-and-answer process; obtain the answer vector corresponding to the information to be answered; obtain multiple historical original text vectors in the knowledge base, wherein the historical original text vectors correspond one-to-one with the historical recall knowledge; obtain the similarity between the answer vector and the multiple historical original text vectors respectively to obtain the multiple second similarities, wherein the second similarity characterizes the degree of matching between the query vector and the corresponding historical recall knowledge; obtain the successfully matched historical recall knowledge based on the multiple second similarities, wherein the successfully matched historical recall knowledge is the historical recall knowledge corresponding to the historical original text vector ranked first in descending order of second similarity.
[0094] In one approach, the prompt word acquisition unit 630 is specifically used to delete duplicate knowledge from the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge to obtain the remaining knowledge; obtain a search result portion based on the remaining knowledge; obtain a user analysis portion based on the information to be answered and the intent analysis result corresponding to the information to be answered, wherein the intent analysis result is obtained by inputting the information to be answered into the large language model; acquire a pre-configured background introduction portion, task description portion, and answer requirement portion, wherein the background introduction portion is used to inform the large language model of the role it needs to play, the task it needs to perform, and the background corresponding to the task; the task description portion is used to inform the large language model of the content in the prompt words that can be used as the basis for answer reasoning; and the answer requirement portion is used to inform the large language model of the evaluation criteria and format of the answer; and obtain the prompt words based on the background introduction portion, the task description portion, the answer requirement portion, the search result portion, and the user analysis portion.
[0095] The device 600 further includes:
[0096] The knowledge base construction unit 650 is used to acquire content from a professional domain knowledge base and a private domain knowledge base as reference content, wherein the content in the professional domain knowledge base and the private domain knowledge base is in natural language description format; based on the large language model, the reference content is transformed into multiple pieces of knowledge in the knowledge base, wherein the knowledge is in application programming interface format; the similarity between each piece of knowledge and the corresponding abstracts of the multiple levels is obtained; based on the similarity between each piece of knowledge and the corresponding abstracts of the multiple levels, the level of each piece of knowledge is determined; and each piece of knowledge is stored in the node of the corresponding level to obtain the knowledge base.
[0097] The following will combine Figure 11 This application describes an electronic device.
[0098] Please see Figure 11 Based on the above-described question-and-answer method and apparatus, this application embodiment also provides another electronic device 100 capable of executing the aforementioned question-and-answer method. The electronic device 100 includes a processor 102 and a memory 104, wherein the memory 104 stores a program capable of executing the contents of the aforementioned embodiments, and the processor 102 can execute the program stored in the memory 104.
[0099] The processor 102 may include one or more processing cores. The processor 102 connects to various parts within the electronic device 100 using various interfaces and lines, and performs various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 104, and by calling data stored in the memory 104. Optionally, the processor 102 may be implemented using at least one of the following hardware forms: a Neural Network Processing Unit (NPU), a Digital Signal Processing Unit (DSP), a Field-Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA). The processor 102 may integrate one or more of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a Neural Network Processing Unit (NPU), and a modem. Specifically, the CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; the NPU handles multimedia data such as video and images; and the modem handles wireless communication. It is understandable that the aforementioned modem may not be integrated into the processor 102, but may be implemented using a separate communication chip.
[0100] The memory 104 may include random access memory (RAM), read-only memory (ROM), and double data rate synchronous dynamic random access memory (DDR). The memory 104 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method embodiments described below. The data storage area may also store data created by the electronic device 100 during use (such as phonebook data, audio and video data, chat log data, etc.).
[0101] Please refer to Figure 12This diagram illustrates a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable storage medium 800 stores program code that can be called by a processor to execute the methods described in the above method embodiments.
[0102] The computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has storage space for program code 810 that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code 810 may, for example, be compressed in a suitable form.
[0103] In summary, the question-answering method, apparatus, and electronic device provided in this application, after obtaining information to be answered, retrieves fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge related to the information to be answered from a pre-built knowledge base. Based on the information to be answered, the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge, prompt words are obtained. The prompt words are then input into a large language model to obtain the answer corresponding to the information to be answered. This method allows prompt words to be obtained based on multi-dimensional recall knowledge and information to be answered, thereby increasing the number of references available for the answer from the prompt words. Consequently, the large language model can obtain the answer based on prompt words containing more references, improving the accuracy of the answer.
[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A question-and-answer method, characterized in that, Applied to electronic devices, the method includes: Get the information to be answered; Recall knowledge related to the information to be answered is obtained from a pre-built knowledge base. This recall knowledge includes fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge. The knowledge base includes multiple original texts and corresponding keywords for each original text. Fine-grained recall knowledge is obtained by matching the query keyword with the corresponding keywords of the original texts, where the query keyword represents important content in the information to be answered. Coarse-grained recall knowledge consists of original texts that successfully match the information to be answered from among the original texts. Personalized recall knowledge consists of historical recall knowledge that successfully matches the information to be answered, where the historical recall knowledge represents the user's knowledge preferences. The process involves deleting duplicate knowledge from the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge to obtain the remaining knowledge; obtaining the search results based on the remaining knowledge; obtaining the user analysis based on the information to be answered and the intent analysis results corresponding to the information to be answered, wherein the intent analysis results are obtained by inputting the information to be answered into a large language model; acquiring the pre-configured background introduction, task description, and answer requirements; and obtaining prompt words based on the background introduction, task description, answer requirements, search results, and user analysis. The prompt words are input into a large language model to obtain the answer corresponding to the information to be answered.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the query vector corresponding to the keyword to be queried; Obtain multiple keyword vectors from the knowledge base, wherein each keyword vector corresponds one-to-one with a keyword; The similarity between the query vector and the multiple keyword vectors is obtained to obtain multiple first similarities, where the first similarity represents the degree of matching between the query vector and the corresponding keyword. The target keywords are obtained based on the multiple first similarities, and the target keywords are the keywords corresponding to the keyword vectors that are ranked first in a specified position according to the first similarity from high to low. The original text corresponding to the target keyword is used as the fine-grained recall knowledge.
3. The method according to claim 2, characterized in that, The multiple keyword vectors in the knowledge base are stored in a tree structure, which includes nodes at multiple levels. Each node at each level corresponds to a summary vector, which represents a summary of the keywords corresponding to all nodes at that level. Obtaining the similarity between the query vector and the multiple keyword vectors to obtain the multiple first similarities includes: Obtain the similarity between the query vector and the summary vector corresponding to the root node; Based on this similarity, the next level of matching nodes is determined from the root node, and the matching nodes are the nodes that successfully match the query vector. Continue to obtain the similarity between the query vector and the summary vector of the matching node at the next level, until the similarity between the query vector and the multiple keyword vectors is obtained, so as to obtain the multiple first similarities.
4. The method according to claim 1, characterized in that, The method further includes: The knowledge in the knowledge base that is the same as or similar to the historical feedback knowledge is used as the historical recall knowledge, and the historical feedback knowledge is the original text that was successfully matched with the historical unanswered information during the historical question-and-answer process. Obtain the answer vector corresponding to the information to be answered; Obtain multiple historical original text vectors from the knowledge base, wherein each historical original text vector corresponds one-to-one with the historical recalled knowledge; The similarity between the vector to be answered and the plurality of historical original text vectors is obtained to obtain a plurality of second similarity, wherein the second similarity characterizes the degree of matching between the vector to be answered and the corresponding historical recalled knowledge; The successfully matched historical recall knowledge is obtained based on the multiple second similarities. The successfully matched historical recall knowledge is the historical recall knowledge corresponding to the first specified position of the historical original text vector in descending order of second similarity.
5. The method according to claim 1, characterized in that, The background introduction section informs the large language model of its current role, the task it performs, and the background of the task. The task description section informs the large language model of the content in the prompt words that can be used as the basis for answer reasoning. The answer requirements section informs the large language model of the evaluation criteria and the format of the answer.
6. The method according to claim 1, characterized in that, The knowledge base is a tree-structured storage structure, which includes nodes at multiple levels. Each level of node corresponds to a summary, which is a summary of the knowledge corresponding to all nodes in the corresponding level. Before obtaining the information to be answered, the following steps are also included: The content of the professional domain knowledge base and the private domain knowledge base is obtained as reference content, and the content of the professional domain knowledge base and the private domain knowledge base is in natural language description format; Based on the large language model, the reference content is transformed into multiple pieces of knowledge in the knowledge base, and the knowledge is in application programming interface format. Obtain the similarity between each piece of knowledge and the corresponding summary of each of the multiple levels; Based on the similarity between each piece of knowledge and the corresponding summaries of the multiple levels, the level to which each piece of knowledge belongs is determined. Each piece of knowledge is stored in a node at the corresponding level to obtain the knowledge base.
7. A question-and-answer device, characterized in that, Operating in an electronic device, the device includes: The unit for obtaining information to be answered is used to obtain information to be answered. A knowledge acquisition unit is used to acquire knowledge related to the information to be answered from a pre-built knowledge base. This knowledge includes fine-grained recall knowledge, coarse-grained recall knowledge, and personalized recall knowledge. The knowledge base includes multiple original texts and keywords corresponding to each of the original texts. The fine-grained recall knowledge is obtained by matching the query keyword with the keywords corresponding to the original texts, where the query keyword represents important content in the information to be answered. The coarse-grained recall knowledge consists of original texts that successfully match the information to be answered from among the original texts. The personalized recall knowledge consists of historical recall knowledge that successfully matches the information to be answered from among the historical recall knowledge, where the historical recall knowledge represents the user's knowledge preferences. The prompt word acquisition unit is used to delete duplicate knowledge from the fine-grained recall knowledge, the coarse-grained recall knowledge, and the personalized recall knowledge to obtain the remaining knowledge; obtain the search results based on the remaining knowledge; obtain the user analysis based on the information to be answered and the intent analysis result corresponding to the information to be answered, wherein the intent analysis result is obtained by inputting the information to be answered into a large language model; acquire the pre-configured background introduction, task description, and answer requirement; and obtain prompt words based on the background introduction, task description, answer requirement, search results, and user analysis. The answer acquisition unit is used to input the prompt words into the large language model to obtain the answer corresponding to the information to be answered.
8. An electronic device, characterized in that, Includes one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code, wherein the method described in any one of claims 1-6 is executed when the program code is run.