A method, apparatus, electronic device, and storage medium for generating answers.
By retrieving the second user feature vector and reference documents that match the first user feature vector, the feature vector is adjusted to generate personalized answers. This solves the problem of insufficient personalized feedback caused by the scarcity of historical dialogue data and improves the personalized response capability of the knowledge question answering system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2026-03-13
AI Technical Summary
Existing domain knowledge bases have significant limitations in personalized presentation, especially for users with scarce historical dialogue data, making it difficult to build accurate user profiles and provide personalized answers that meet their needs.
By retrieving the feature vector of a second user that matches the feature vector of the first user, the target answer and reference document are obtained. The feature vector is then adjusted using similarity and behavioral data to generate a personalized answer, thus avoiding the problem of scarce historical dialogue data.
It enables the generation of personalized answers that meet the needs of users, improves the accuracy and adaptability of personalized feedback, and enhances the personalized response capability of the knowledge question-and-answer system.
Smart Images

Figure CN120821834B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge-based question answering, and more specifically, to an answer generation method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, domain knowledge bases built upon Large Language Models (LLM) and Retrieval Enhanced Generation (RAG) technologies have gained significant traction in the knowledge-based question-answering field, becoming a key paradigm. However, existing domain knowledge bases still have significant limitations in personalized presentation. Current personalized feedback mechanisms primarily rely on the questioner's historical dialogue data to achieve personalized responses.
[0003] However, for users with scarce historical conversation data, existing personalized feedback mechanisms struggle to build accurate user profiles, thus failing to provide personalized answers that meet their needs. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide an answer generation method, apparatus, electronic device and storage medium that can enrich the historical dialogue data of a first user by using the second feature vector of a second user, and then generate an answer for the first user based on the second feature vector of a second user that matches the first user's first feature vector, thereby avoiding the inability to provide personalized answers that meet the user's needs due to the scarcity of historical dialogue data.
[0005] In a first aspect, embodiments of this application provide an answer generation method, the answer generation method comprising:
[0006] In response to a first question raised by a first user, at least one second feature vector of at least one second user that matches the first user's first feature vector is retrieved; wherein, the first feature vector includes a topic feature vector and a keyword feature vector of the first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions;
[0007] Obtain the target answer to the second question corresponding to all second feature vectors, as well as the target domain feature vector of the target answer and at least one first reference document;
[0008] Based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document, at least one second reference document is selected from all the first reference documents;
[0009] The answer to the first question is generated based on the second reference document.
[0010] In one possible implementation, retrieving at least one second feature vector of at least one second user that matches the first user's first feature vector includes:
[0011] Calculate the similarity between the first feature vector and each second feature vector of each historical user;
[0012] Based on the similarity between the first feature vector and the second feature vector of each historical user, at least one second feature vector of at least one second user is selected from all the second feature vectors of all historical users.
[0013] In one possible implementation, the target answer to the second question corresponding to any second feature vector is obtained through the following steps:
[0014] Obtain all initial answers to the second question corresponding to the second feature vector, and the behavioral data of the second user for each initial answer corresponding to the second feature vector;
[0015] The target answer is determined from all initial answers based on the second user's behavioral data for each initial answer.
[0016] In one possible implementation, the target domain feature vector of the target answer is obtained through the following steps:
[0017] Extract the initial domain feature vector of the target answer;
[0018] Based on the second user's behavioral data regarding the target answer, a first adjustment weight for the target answer is determined;
[0019] The initial domain feature vector is adjusted according to the first adjustment weight to obtain the target domain feature vector.
[0020] In one possible implementation, after adjusting the initial neighborhood feature vector according to the first adjustment weight to obtain the target neighborhood feature vector, the method further includes:
[0021] The second adjustment weight of the target domain feature vector is calculated based on the time elapsed between the generation time of the target answer and the current time.
[0022] The target domain feature vector is adjusted according to the second adjustment weight to obtain the final target domain feature vector.
[0023] In one possible implementation, selecting at least one second reference document from all first reference documents includes:
[0024] For each first reference document, a first score is calculated based on the similarity between the feature vector of each target answer and the feature vector of the first reference document, and the similarity between the domain feature vector of each target answer and the domain feature vector of the first reference document.
[0025] Based on the first score, at least one second reference document is selected from all the first reference documents.
[0026] In one possible implementation, calculating the first score of the first reference document includes:
[0027] For each target answer, the product of the similarity between the feature vector of the target answer and the feature vector of the first reference document and the similarity between the domain feature vector of the target answer and the domain feature vector of the first reference document is determined as the second score of the first reference document when generating the target answer;
[0028] The sum of the second scores of the first reference document when generating all target answers is determined as the first score of the first reference document.
[0029] Secondly, embodiments of this application provide an answer generation apparatus, the apparatus comprising:
[0030] A response module is configured to, in response to a first question raised by a first user, retrieve at least one second feature vector of at least one second user that matches the first user's first feature vector; wherein, the first feature vector includes a topic feature vector and a keyword feature vector of the first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions;
[0031] The acquisition module is used to acquire the target answer to the second question corresponding to all second feature vectors, as well as the target domain feature vector of the target answer and at least one first reference document;
[0032] The filtering module is used to filter at least one second reference document from all first reference documents based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document.
[0033] A generation module is used to generate an answer to the first question based on the second reference document.
[0034] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the answer generation method as described in any of the first aspects.
[0035] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the answer generation method as described in any of the first aspects.
[0036] This application provides an answer generation method, apparatus, electronic device, and storage medium. The method includes: retrieving at least one second feature vector of at least one second user that matches a first feature vector of a first user; wherein the first feature vector includes a topic feature vector and a keyword feature vector of a first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions; obtaining the target answer of the second question corresponding to all second feature vectors, the target domain feature vector of the target answer, and at least one first reference document; selecting at least one second reference document from all first reference documents based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document; and generating the answer to the first question based on the second reference document. This application enables the generation of answers for the first user based on the second feature vector of the second user that matches the first user's first feature vector, avoiding the inability to provide personalized answers tailored to the user's needs due to the scarcity of historical dialogue data. Attached Figure Description
[0037] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 A flowchart of an answer generation method provided in an embodiment of this application is shown;
[0039] Figure 2 A flowchart illustrating the filtering process of the second reference document provided in an embodiment of this application is shown;
[0040] Figure 3 This illustration shows a schematic diagram of the structure of an answer generation device provided in an embodiment of this application;
[0041] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0043] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0044] To enable those skilled in the art to utilize the content of this application, and in conjunction with the specific application scenario of "knowledge question answering," the following implementation methods are provided. For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is primarily described in the context of "knowledge question answering," it should be understood that this is merely an exemplary embodiment.
[0045] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0046] The following is a detailed description of an answer generation method provided by an embodiment of this application.
[0047] Reference Figure 1The diagram shown is a flowchart illustrating an answer generation method provided in an embodiment of this application. The exemplary steps of this embodiment are described below:
[0048] S101, In response to a first question raised by a first user, retrieve at least one second feature vector of at least one second user that matches the first feature vector of the first user.
[0049] In this embodiment, the first user refers to the user who asked the question. The first question refers to the question asked by the first user that has not yet been answered. The second user is selected from all historical users who have participated in knowledge-based question-and-answer sessions (which may include the first user). The first feature vector includes a topic feature vector and a keyword feature vector for the first question, obtained by concatenating these two vectors. Each second feature vector includes a topic feature vector and a keyword feature vector for a second question, obtained by concatenating these two vectors. Different second feature vectors for the same second user correspond to different second questions (e.g., the question corresponding to second user A's second feature vector a is different from the question corresponding to second user B's second feature vector b).
[0050] Here, the second user's second question refers to a question raised by the second user that has already generated an answer. The topic feature vector of the question includes the association probability between the question and each topic (such as artificial intelligence, health and wellness, etc.). The keyword feature vector of the question includes the importance of each keyword in the question.
[0051] In addition, the first feature vector may also include the personal attribute feature vector of the first user; the second feature vector may also include the personal attribute feature vector of the second user; the personal attribute feature vector refers to the feature vector of the user's personal attribute information. Personal attribute information includes demographic attributes (such as age group, occupation, gender, and place of residence), socio-emotional attribute tags (parent-child, couple, and single, etc.), and cultural background (education and major, etc.).
[0052] Here, a user's age attribute is represented by age groups. People of similar ages are generally considered to be peers, and their similarity is more likely to be similar compared to people in other age groups. Compared to directly using age values as personal attribute information, this method can retrieve more second feature vectors of second users that match the first user's first feature vector. This avoids the situation where too few second feature vectors of second users are matched, which would result in a lack of personalized answers tailored to the user's needs due to scarce historical dialogue data.
[0053] Before retrieving the second feature vector of the second user that matches the first feature vector of the first user, it is necessary to first obtain the topic feature vector and keyword feature vector from the first feature vector of each historical user. The specific steps are as follows:
[0054] Step 1: Obtain all second questions for historical users.
[0055] In this application's implementation, a "historical user" refers to a user who has participated in a knowledge-based question-and-answer session. The "second question" from a historical user refers to a question raised by a historical user for which an answer has already been generated.
[0056] Optionally, each second problem can be preprocessed to obtain the final second problem.
[0057] In this embodiment of the application, stop words and special symbols in the second question are removed, and keywords (domain keywords (such as technical terms, product names) and subject keywords) are retained.
[0058] Optionally, each second question is segmented into words, and the segmented words are replaced according to the technical terms in the knowledge graph to obtain the final second question.
[0059] Step 2: Extract the topic feature vector and keyword feature vector for each second question.
[0060] In this embodiment of the application, each second problem is generated using an LDA topic model. Topic Feature Vector :
[0061] ;
[0062] in, It means Generate a vector of dimension m.
[0063] In the embodiments of this application, by Extract each second question Keyword feature vector :
[0064] ;
[0065] in, It means Generate Dimensions The vector.
[0066] Here, TF-IDF (Term Frequency-Inverse Document Frequency) is a commonly used weighting technique for information retrieval and text mining, used to measure the importance of a word to a document in a document set or corpus.
[0067] Optionally, obtaining the first feature vector for each historical user also includes:
[0068] Step 1: Obtain the personal attribute information of historical users.
[0069] In the embodiments of this application, personal attribute information includes demographic attributes (such as age group, occupation, gender and place of residence), socio-emotional attribute tags (parent-child, couple and single, etc.) and cultural background (education and major, etc.).
[0070] Step 2: Represent the personal attribute information of historical users through corresponding numerical values to obtain the personal attribute feature vector of historical users.
[0071] In this embodiment, the attribute information of any historical user is processed using a one-hot encoding method to represent the attribute information of any historical user through corresponding numerical values, thereby obtaining the personal attribute feature vector of the historical user. Referring to Table 1, an example table is provided in this embodiment where 00 represents the user's gender; referring to Table 2, an example table is provided in this embodiment where 000000 represents the age range.
[0072] Table 1
[0073]
[0074] Table 2
[0075]
[0076] As can be seen from the above examples, each person's attribute feature vector is a numerical string composed of 1s and 0s. The number of values in this numerical string is the same as the number of attribute values of the corresponding personal attribute information. Moreover, if the attribute value of personal attribute information (such as the attribute value of gender, which includes male and female) is 1, it means that the personal attribute information is that attribute value; if the attribute value of personal attribute information (such as the attribute value of age range, which includes "18<" and "18-25") is 0, it means that the personal attribute information is not that attribute value.
[0077] Further, at least one second feature vector of at least one second user that matches the first feature vector of the first user is retrieved through the following steps:
[0078] i. Calculate the similarity between the first feature vector and each second feature vector of each historical user.
[0079] In this embodiment, the process of obtaining the first feature vector is the same as the process of obtaining the second feature vector of historical users, and will not be repeated here. For any second feature vector of any historical user, the first feature vector is... The second feature vector of the historical user Substituting into the following formula, we obtain the similarity between the first feature vector and the second feature vector of the historical user. :
[0080] ;
[0081] in, This refers to the number of elements (topic feature vector, keyword feature vector, or personal attribute feature vector) in either the first or second feature vector. Let be the preset weight value for the i-th element. Let i be the eigenvalue of the i-th element in the first eigenvector. Let be the eigenvalue of the i-th element in the second eigenvector.
[0082] ii. Based on the similarity between the first feature vector and the second feature vector of each historical user, select at least one second feature vector of at least one second user from all the second feature vectors of all historical users.
[0083] In this embodiment, the greater the similarity between the first feature vector and the second feature vector of a historical user, the more effectively the second feature vector of the historical user can characterize the personalized features of the first user. Specifically, the second feature vectors of historical users whose similarity to the first feature vector is greater than a preset similarity threshold are determined as the second feature vectors of the second user. Alternatively, the second feature vectors of a preset number of historical users whose similarity to the first feature vector is the largest are determined as the second feature vectors of the second user.
[0084] S102. Obtain the target answer to the second question corresponding to all second feature vectors, as well as the target domain feature vector of the target answer and at least one first reference document.
[0085] In this embodiment, the target domain feature vector includes the association probability between the target answer and each domain. The first reference document refers to the document cited by the knowledge question answering system when generating the target answer.
[0086] Here, while the second user's second feature vector and second feature vector can represent the first user's intuitive personalized characteristics, the semantic complexity of the question is insufficient and the contextual relevance is low, resulting in insufficient contextual evolution capability and difficulty in capturing the first user's personalized characteristics. Furthermore, there is a semantic granularity difference between the relevant features of the second question and the data in the knowledge graph, making it difficult to retrieve personalized features within the knowledge graph. Therefore, it is necessary to deeply mine the implicit personalized characteristics of the first user from the answers to improve the personalized generation effect of the answers, avoid the lag in adapting to dynamic user needs due to insufficient contextual evolution capability, and avoid problems such as the inability to retrieve personalized features in the knowledge graph.
[0087] Specifically, the target answer to the second question corresponding to any second feature vector is obtained through the following steps:
[0088] Step 1: Obtain all initial answers to the second question corresponding to the second feature vector, and the behavioral data of the second user for each initial answer corresponding to the second feature vector.
[0089] In this application's implementation, the initial answer refers to all answers generated by the knowledge-based question-and-answer system for the second question. The behavioral data for the initial answer includes explicit and implicit behaviors. Explicit behaviors refer to actions by which the second user clearly expresses their preference for the initial answer (such as liking, saving, sharing, copying content, and disapproving). Liking, saving, sharing, and copying content indicate that the second user approves of the initial answer. Disapproving behavior indicates that the second user does not approve of the initial answer. Implicit behaviors refer to actions by which the second user does not explicitly express their preference for the initial answer but implicitly expresses it, such as single-word browsing time (referring to the reading time of a single word; specifically, the ratio between the number of words in the initial answer and the total browsing time of the initial answer is used as the single-word reading time). The longer the single-word browsing time, the higher the second user's level of approval of the initial answer.
[0090] Step 2: Based on the second user's behavioral data for each initial answer, determine the target answer from all initial answers.
[0091] In this application embodiment, for any initial answer, if the behavioral data includes a first initial answer that expresses approval (like, favorite, share, and copy content, etc.), then the first initial answer ranked first is determined as the target answer; if the behavioral data does not include a first initial answer that expresses approval but includes implicit behavior, then the second initial answer with the highest degree of approval for implicit behavior in the behavioral data is determined as the target answer; otherwise, the initial answer ranked first is determined as the target answer.
[0092] The initial answers were sorted according to how well they fit the second question, with earlier initial answers fitting the second question better than later ones.
[0093] Here, the fit between the initial answer and the second question refers to the extent to which the initial answer accurately and effectively responds to the second question.
[0094] Specifically, the target domain feature vector of the target answer is obtained through the following steps:
[0095] Step 1: Extract the initial domain feature vector of the target answer.
[0096] In this embodiment, a multi-label classification model is used to predict the initial domain feature vector of the target answer, and the specific formula is as follows:
[0097] ;
[0098] in, Let be the initial domain feature vector of the target answer. For multi-label classification models, the activation function is... For a fully connected layer in a multi-label classification model, For pre-trained language models Extracted target answer The vector, This refers to the initial domain feature vector having a dimension of 1. The vector.
[0099] Step 2: Determine the first adjustment weight of the target answer based on the second user's behavioral data on the target answer.
[0100] In this embodiment, a user approval score is pre-set for each behavioral data point, such as a user approval score of 3 for a like and -5 for a dislike. The sum of the user approval scores corresponding to all behavioral data of the target answer is determined as the second user's behavioral feedback score for the target answer; the product of the second user's behavioral feedback score for the target answer and a preset weight coefficient is used as the first adjustment weight of the target answer.
[0101] Step 3: Adjust the initial domain feature vector according to the first adjustment weight to obtain the target domain feature vector.
[0102] In this embodiment of the application, the first adjustment weight and the initial domain feature vector are substituted into the following formula to obtain the target domain feature vector.
[0103] ;
[0104] in, For the feature vector of the target domain, For the initial neighborhood feature vector, For preset weighting coefficients, The score is given as feedback to the second user's behavior regarding the target answer. The first adjustment weight is given to the target answer.
[0105] Furthermore, after adjusting the initial neighborhood feature vector according to the first adjustment weight to obtain the target neighborhood feature vector, the method further includes:
[0106] Step 1: Calculate the second adjustment weight of the target domain feature vector based on the time elapsed between the generation time of the target answer and the current time.
[0107] In this embodiment of the application, the generation time of the target answer is... Recent time Duration Substituting into the following formula, we obtain the second adjusted weight of the target domain feature vector. .
[0108] ;
[0109] in, To control the decay rate parameter.
[0110] Here, user preferences may change over time. For example, folk music might be popular in 2020, but rock music might be more popular in 2021. Therefore, user preferences should be differentiated along the time dimension. Topics or content have life cycles; for example, they may be popular for a period of time, but then lose their appeal. Furthermore, user preferences also exhibit seasonality; for instance, users might enjoy ice cream in the summer and hot pot in the winter. Therefore, this application improves the accuracy of the target domain feature vector by introducing a second adjustment weight to incorporate the time attribute, thereby enhancing the answer generation effect.
[0111] Step 2: Adjust the target domain feature vector according to the second adjustment weight to obtain the final target domain feature vector.
[0112] In this embodiment of the application, the product of the second adjustment weight and the target domain feature vector is determined as the final target domain feature vector.
[0113] Alternatively, the feature vectors of the target domain can be normalized using the following formula:
[0114] ;
[0115] in, This is the normalized feature vector of the target domain. The second adjusted weight is the j-th initial answer to the second question corresponding to the target answer.
[0116] S103. Based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document, select at least one second reference document from all the first reference documents.
[0117] Reference Figure 2 The diagram shown is a flowchart of the screening process for the second reference document provided in an embodiment of this application. The steps are described below:
[0118] S201. For each first reference document, calculate the first score of the first reference document based on the similarity between the feature vector of each target answer and the feature vector of the first reference document, and the similarity between the domain feature vector of each target answer and the domain feature vector of the first reference document.
[0119] In this embodiment of the application, for each target answer, the product of the similarity between the feature vector of the target answer and the feature vector of the first reference document and the similarity between the domain feature vector of the target answer and the domain feature vector of the first reference document is determined as the second score of the first reference document when generating the target answer; the sum of the second scores of the first reference document when generating all target answers is determined as the first score of the first reference document.
[0120] S202. Based on the first score, select at least one second reference document from all the first reference documents.
[0121] In this application embodiment, the first preset number of reference documents with the largest first score is used as the second reference document.
[0122] Optionally, in addition to determining the second reference document based on the second user's second feature vector, the first user's first question can also be used to determine the second reference document. Specifically, a search is performed on the knowledge graph based on the keyword text in the first question, and a search is also performed on the knowledge graph based on the text data of the first question to obtain a third reference document and a corresponding third score. The third score is used to characterize the importance of the third reference document in generating the answer to the first question. Based on the third score, a second preset number of initial documents are selected from the third reference documents. For each third reference document, at least one second reference document is selected from all the third reference documents based on the similarity between the feature vector of each target answer and the feature vector of each third reference document, as well as the similarity between the target domain feature vector of each target answer and the target domain feature vector of each third reference document.
[0123] In this embodiment of the application, for each first reference document, a fourth score of the third reference document is calculated based on the similarity between the feature vector of each target answer and the feature vector of the third reference document, and the similarity between the domain feature vector of each target answer and the domain feature vector of the third reference document; based on the fourth score, at least one second reference document is selected from all the third reference documents.
[0124] Optionally, after determining the second reference document using the first user's first question, the method further includes: selecting a first preset number of second reference documents from all second reference documents as the final second reference documents based on the score corresponding to the second reference document.
[0125] It should be noted that the method for obtaining the feature vectors of the third reference document and the target domain feature vector is the same as that for obtaining the feature vectors of the first reference document and the target domain feature vector, and will not be repeated here. The process of selecting at least one second reference document from all third reference documents is the same as the process of selecting at least one second reference document from all first reference documents.
[0126] S104. Generate the answer to the first question based on the second reference document.
[0127] In this embodiment, prompt information is generated based on the first question, the second reference document, the second user corresponding to the second reference document, and the score corresponding to the second reference document. This prompt information is then input into a large language model to obtain at least one answer to the first question. The order of the generated answers is determined based on the score of the corresponding second reference document.
[0128] In addition to regular prompts, additional prompt words can be added to help the large language model generate answers, such as: "{Users similar to him have asked: Question 2, + liked this answer at the time, : answer, please refer to it}", etc.
[0129] This application provides an answer generation method, which includes: retrieving at least one second feature vector of at least one second user that matches a first feature vector of a first user; wherein the first feature vector includes a topic feature vector and a keyword feature vector of a first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions; obtaining the target answer of the second question corresponding to all second feature vectors, the target domain feature vector of the target answer, and at least one first reference document; selecting at least one second reference document from all first reference documents based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document; and generating the answer to the first question based on the second reference document. This application enables the generation of answers for the first user based on the second feature vector of the second user that matches the first user's first feature vector, avoiding the inability to provide personalized answers tailored to the user's needs due to the scarcity of historical dialogue data.
[0130] Based on the same inventive concept, this application also provides an answer generation device corresponding to the answer generation method. Since the principle of the device in this application is similar to the answer generation method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0131] Reference Figure 3 The diagram shown is a schematic representation of an answer generation device provided in an embodiment of this application. The answer generation device includes:
[0132] The response module 301 is configured to, in response to a first question raised by a first user, retrieve at least one second feature vector of at least one second user that matches the first feature vector of the first user; wherein, the first feature vector includes a topic feature vector and a keyword feature vector of the first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions;
[0133] The acquisition module 302 is used to acquire the target answer to the second question corresponding to all the second feature vectors, as well as the target domain feature vector of the target answer and at least one first reference document;
[0134] The filtering module 303 is used to filter at least one second reference document from all first reference documents based on the similarity between the feature vector of each target answer and the feature vector of each first reference document, and the similarity between the target domain feature vector of each target answer and the target domain feature vector of each first reference document.
[0135] The generation module 304 is used to generate an answer to the first question based on the second reference document.
[0136] This device can generate answers for the first user based on the second feature vector of the second user that matches the first user's first feature vector, thus avoiding the inability to provide personalized answers that meet the user's needs due to the scarcity of historical dialogue data.
[0137] like Figure 4 As shown in the embodiment of this application, an electronic device 400 includes a processor 401, a memory 402, and a bus. The memory 402 stores machine-readable instructions executable by the processor 401. When the electronic device is running, the processor 401 communicates with the memory 402 via the bus, and the processor 401 executes the machine-readable instructions to perform the steps of the answer generation method described above.
[0138] Specifically, the memory 402 and processor 401 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 401 runs the computer program stored in the memory 402, it can execute the above-mentioned answer generation method.
[0139] Corresponding to the above-described answer generation method, this application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described answer generation method.
[0140] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0141] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0142] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0143] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the information processing methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0144] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for generating answers, characterized in that, The method includes: In response to a first question raised by a first user, at least one second feature vector of at least one second user that matches the first user's first feature vector is retrieved; wherein, the first feature vector includes a topic feature vector and a keyword feature vector of the first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions; Obtain the target answer to the second question corresponding to all second feature vectors, the target domain feature vector of the target answer, and at least one first reference document; the target domain feature vector of the target answer includes the association probability between the target answer and each domain; The first score of each first reference document is calculated by the following steps: For each target answer, the product of the similarity between the feature vector of the target answer and the feature vector of the first reference document and the similarity between the domain feature vector of the target answer and the domain feature vector of the first reference document is determined as the second score of the first reference document when generating the target answer; the sum of the second scores of the first reference document when generating all target answers is determined as the first score of the first reference document. The first reference document with the largest first preset number of the first score is used as the second reference document; The answer to the first question is generated based on the second reference document.
2. The answer generation method according to claim 1, characterized in that, The retrieval of at least one second feature vector of at least one second user that matches the first user's first feature vector includes: Calculate the similarity between the first feature vector and each second feature vector of each historical user; Based on the similarity between the first feature vector and the second feature vector of each historical user, at least one second feature vector of at least one second user is selected from all the second feature vectors of all historical users.
3. The answer generation method according to claim 1, characterized in that, The target answer to the second question corresponding to any second feature vector is obtained through the following steps: Obtain all initial answers to the second question corresponding to the second feature vector, and the behavioral data of the second user for each initial answer corresponding to the second feature vector; The target answer is determined from all initial answers based on the second user's behavioral data for each initial answer.
4. The answer generation method according to claim 3, characterized in that, The target domain feature vector of the target answer is obtained through the following steps: Extract the initial domain feature vector of the target answer; Based on the second user's behavioral data regarding the target answer, a first adjustment weight for the target answer is determined; The initial domain feature vector is adjusted according to the first adjustment weight to obtain the target domain feature vector.
5. The answer generation method according to claim 4, characterized in that, After adjusting the initial neighborhood feature vector according to the first adjustment weight to obtain the target neighborhood feature vector, the method further includes: The second adjustment weight of the target domain feature vector is calculated based on the time elapsed between the generation time of the target answer and the current time. The target domain feature vector is adjusted according to the second adjustment weight to obtain the final target domain feature vector.
6. An answer generation device, characterized in that, The device includes: A response module is configured to, in response to a first question raised by a first user, retrieve at least one second feature vector of at least one second user that matches the first user's first feature vector; wherein, the first feature vector includes a topic feature vector and a keyword feature vector of the first question; the second feature vector includes a topic feature vector and a keyword feature vector of a second question; different second feature vectors of the same second user correspond to different second questions; The acquisition module is used to acquire the target answer to the second question corresponding to all second feature vectors, the target domain feature vector of the target answer, and at least one first reference document; the target domain feature vector of the target answer includes the association probability between the target answer and each domain; The filtering module is used to calculate a first score for each first reference document through the following steps: for each target answer, the product of the similarity between the feature vector of the target answer and the feature vector of the first reference document, and the similarity between the domain feature vector of the target answer and the domain feature vector of the first reference document, is determined as a second score of the first reference document when generating the target answer; the sum of the second scores of the first reference document when generating all target answers is determined as the first score of the first reference document; and the first reference document with the largest first score is selected as a second reference document. A generation module is used to generate an answer to the first question based on the second reference document.
7. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the answer generation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the answer generation method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Multi domain real-time question answering system
CN109983454A
Information reply method and device and medium
CN114328878A
Question and answer processing method and device
CN119494392A