Method and apparatus for outputting information

By constructing candidate problem vector index and unsupervised model training, the problems of low FAQ retrieval recall and high cost are solved, and efficient and low-cost question-and-answer search is achieved, which is suitable for intelligent customer service systems.

CN110427474BActive Publication Date: 2025-08-19BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910718803.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-05
Publication Date
2025-08-19
Estimated Expiration
2039-08-05

AI Technical Summary

Technical Problem

The existing FAQ search methods have low recall rates and high costs in robot dialogue systems, especially in privatization projects, which require high machine performance, resulting in increased customer service costs.

Method used

Unsupervised models are used for offline training, candidate problem vector index is constructed, candidate problem vectors that meet the conditions are found through geometric relationships, reducing the amount of calculations for online evaluation, and using word vectors for search.

Benefits of technology

It improves the accuracy and efficiency of question-and-answer retrieval, reduces the cost of manual labeling, has a higher adaptability than deep learning models, and is suitable for intelligent customer service scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110427474B_ABST
    Figure CN110427474B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a method and apparatus for outputting information. A specific implementation of the method includes: in response to receiving a question, converting the question into a question vector; obtaining a pre-constructed candidate question vector index; setting the current search radius, and performing the following search steps: based on the current search radius and the longest radius of each linked list, determining the geometric relationship between the question vector and each group of candidate question vectors; searching for candidate question vectors that meet predetermined search conditions in the group of candidate question vectors whose geometric relationship is containment, intersection, or tangency, and adding them to the result set; if the result set meets the predetermined end condition, outputting the answers corresponding to the predetermined number of candidate question vectors in the result set that are closest to the question vector; otherwise, increasing the current search radius and continuing to perform the above search steps. This implementation improves the accuracy of question-answering retrieval and improves the efficiency of cloud computing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly, to a method and apparatus for outputting information. Background Art

[0002] In a robot dialogue system, users' query statements must be answered in real time with semantically sound answers. Different dialogue tasks employ different strategies for different scenarios. Frequently Asked Questions (FAQ) retrieval tasks involve selecting the most appropriate candidate sentence for the user's query from a list of candidate sentences and then obtaining the corresponding answer.

[0003] For FAQ dialogues, the system needs to pre-populate some question-answer pairs—questions and their corresponding answers. When a user enters a new sentence, the system needs to generalize it, retrieve the most matching question from the existing questions, and return the answer to the user.

[0004] Existing FAQ retrieval methods primarily segment candidate questions and store them in an inverted index. Then, candidate questions are retrieved from the inverted index based on the user's query. A previously trained deep learning model is then used to score all candidate questions. The answer to the question with the highest score is selected and returned to the user as the final result.

[0005] Although inverted index-based retrieval is fast, the recall rate is not very high because it is based on word frequency and does not incorporate semantics. Secondly, for the second stage of re-ranking using a deep learning model, the model requires a large amount of training data. Although the use of a metric learning-based model can greatly reduce the need for annotation, for a specific field (such as banking), tens of thousands of manually annotated sentences are still required. In addition, the training and prediction overhead of complex models (such as those containing Transformers or BiLSTMs) is relatively high, which not only affects the QPS (Queries Per Second) of the entire dialogue system, but also places higher requirements on machine performance. In privatization projects, the cost of customer service increases and reduces the competitiveness of the product. Summary of the Invention

[0006] Embodiments of the present disclosure provide methods and apparatus for outputting information.

[0007] In a first aspect, an embodiment of the present disclosure provides a method for outputting information, comprising: in response to receiving a question, converting the question into a question vector; obtaining a pre-constructed candidate question vector index, wherein the candidate question vector index is composed of at least one linked list, each linked list including a group of candidate question vectors, the centroid of the linked list and the longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; setting a current search radius, and performing the following search steps: based on the current search radius and the longest radius of each linked list, determining the geometric relationship between the question vector and each group of candidate question vectors; searching for candidate question vectors that meet predetermined search conditions in the group of candidate question vectors whose geometric relationship is a containment, intersection or tangency relationship, and adding them to a result set; if the result set meets a predetermined end condition, outputting the answers corresponding to a predetermined number of candidate question vectors in the result set that are closest to the question vector; otherwise, increasing the current search radius and continuing to perform the above-mentioned search steps.

[0008] In some embodiments, determining the geometric relationship between the question vector and each group of candidate question vectors includes: calculating the distance from the question vector to the center of mass of each linked list respectively; for at least one linked list in the linked list, if the distance from the question vector to the center of mass of the linked list is less than the longest radius of the linked list, then the candidate question vector in the linked list contains the question vector; if the distance from the question vector to the center of mass of the linked list is less than the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list intersects with the question vector; if the distance from the question vector to the center of mass of the linked list is equal to the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list is tangent to the question vector; if the distance from the question vector to the center of mass of the linked list does not meet the above-mentioned conditions of inclusion, intersection or tangency, then the candidate question vector in the linked list is separated from the question vector.

[0009] In some embodiments, a candidate question vector that meets a predetermined search condition is searched for in a group of candidate question vectors whose geometric relationships are containment, intersection or tangency, and is added to a result set, including: for a linked list whose geometric relationships are containment, intersection or tangency, a candidate question vector is searched for in the linked list, whose distance to the centroid of the linked list is greater than or equal to the difference between the distance from the question vector to the centroid of the linked list and the current search radius, and is added to the result set.

[0010] In some embodiments, the predetermined termination condition includes:

[0011] The value is greater than or equal to the predetermined value and the current search radius is greater than the distance of the vector farthest from the question vector in the result set.

[0012] In some embodiments, converting a question into a question vector includes: cutting the question into a word sequence; converting the word sequence into at least one word vector based on a pre-trained unsupervised model; and composing the at least one word vector into a question vector.

[0013] In some embodiments, the question vector is composed of the median, maximum, and minimum value of at least one word vector.

[0014] In some embodiments, a candidate question vector index is constructed by the following steps: grouping the candidate questions in a pre-stored set of candidate question-answer pairs by category; for each group of candidate questions, converting the group of candidate questions into a candidate question vector, calculating the centroid of the group of candidate question vectors, and determining the distance from the centroid to the farthest point from the centroid in the group of candidate question vectors as the longest radius of the group of candidate question vectors, storing the centroid and the longest radius of the group of candidate question vectors in the first element of the linked list corresponding to the group of candidate question vectors, and arranging the group of candidate question vectors in ascending order according to the distance to the centroid and storing them in other elements of the linked list respectively.

[0015] In a second aspect, an embodiment of the present disclosure provides a device for outputting information, comprising: a conversion unit, configured to convert a question into a question vector in response to receiving a question; an acquisition unit, configured to acquire a pre-constructed candidate question vector index, wherein the candidate question vector index is composed of at least one linked list, each linked list including a group of candidate question vectors, the centroid of the linked list and the longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; a search unit, configured to set a current search radius, and perform the following search steps: based on the current search radius and the longest radius of each linked list, determine the geometric relationship between the question vector and each group of candidate question vectors; search for candidate question vectors that meet predetermined search conditions in the group of candidate question vectors whose geometric relationship is containment, intersection or tangency, and add them to a result set; if the result set meets a predetermined end condition, output the answers corresponding to a predetermined number of candidate question vectors in the result set that are closest to the question vector; a loop unit, configured to increase the current search radius and continue to perform the above-mentioned search steps if the result set does not meet the predetermined end condition.

[0016] In some embodiments, the search unit is further configured to: calculate the distance from the question vector to the centroid of each linked list respectively; for at least one linked list in the linked list, if the distance from the question vector to the centroid of the linked list is less than the longest radius of the linked list, then the candidate question vector in the linked list contains the question vector; if the distance from the question vector to the centroid of the linked list is less than the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list intersects with the question vector; if the distance from the question vector to the centroid of the linked list is equal to the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list is tangent to the question vector; if the distance from the question vector to the centroid of the linked list does not meet the above-mentioned conditions of inclusion, intersection or tangency, then the candidate question vector in the linked list is separated from the question vector.

[0017] In some embodiments, the search unit is further configured to: for a linked list whose geometric relationship is containment, intersection or tangency, search from the linked list for a candidate question vector whose distance from the center of mass of the linked list is greater than or equal to the difference between the distance from the question vector to the center of mass of the linked list and the current search radius, and add the candidate question vector to the result set.

[0018] In some embodiments, the predetermined end condition includes: the number of candidate question vectors in the result set is greater than or equal to a predetermined value and the current search radius is greater than the distance of the vector farthest from the question vector in the result set.

[0019] In some embodiments, the conversion unit is further configured to: cut the question into a word sequence; convert the word sequence into at least one word vector based on a pre-trained unsupervised model; and compose a question vector from the at least one word vector.

[0020] In some embodiments, the question vector is composed of the median, maximum, and minimum value of at least one word vector.

[0021] In some embodiments, the device also includes a construction unit: grouping the candidate questions in the pre-stored set of candidate question-answer pairs by category; for each group of candidate questions, converting the group of candidate questions into a candidate question vector, calculating the center of mass of the group of candidate question vectors, and determining the distance from the center of mass to the point farthest from the center of mass in the group of candidate question vectors as the longest radius of the group of candidate question vectors, storing the center of mass and the longest radius of the group of candidate question vectors in the first element of the linked list corresponding to the group of candidate question vectors, and arranging the group of candidate question vectors in ascending order according to the distance to the center of mass and storing them in other elements of the linked list respectively.

[0022] In a third aspect, an embodiment of the present disclosure provides an electronic device for outputting information, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement any method as described in the first aspect.

[0023] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, any method in the first aspect is implemented.

[0024] The method and device for outputting information provided by the embodiments of the present disclosure use an unsupervised model for offline training. During online evaluation, it is only necessary to obtain word vectors and perform vector retrieval, which is fast and can greatly improve the response time of customer service products. This method uses unlabeled data (corpus) to train word vectors. The difficulty of obtaining data is low, and the manual labeling of candidate sets is not as high as that of supervised models, so the cost required is low. When the user needs to modify the candidate sentences, for example, some new question and answer pairs are added, this method does not require any model retraining, and only the corresponding incremental update of the index is required. Most customer service scenarios have insufficient labeled data. At this time, the effect of using a retrieval method based on unsupervised word vectors is often not significantly different from that of using a deep learning model, and the method of the present disclosure is highly adaptable to intelligent customer service scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Other features, objects and advantages of the present disclosure will become more apparent from a reading of the detailed description of non-limiting embodiments made with reference to the following drawings:

[0026] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;

[0027] Figure 2 is a flow chart of an embodiment of a method for outputting information according to the present disclosure;

[0028] Figure 3 is a schematic diagram of an index structure of a method for outputting information according to the present disclosure;

[0029] Figure 4 is a schematic diagram of an application scenario of the method for outputting information according to the present disclosure;

[0030] Figure 5 is a structural diagram of an embodiment of a device for outputting information according to the present disclosure;

[0031] Figure 6 It is a schematic diagram of the structure of a computer system of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION

[0032] The present disclosure will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended only to illustrate the relevant invention and are not intended to limit the invention. It should also be noted that, for ease of description, only portions relevant to the relevant invention are shown in the accompanying drawings.

[0033] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0034] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the method for outputting information or the apparatus for outputting information disclosed herein may be applied.

[0035] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0036] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as automatic question and answer applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0037] Terminal devices 101, 102, and 103 can be hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices that support voice or text input of questions and can output answers through voice or text, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Compression Standard Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) players, laptop computers and desktop computers, etc. When terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0038] The server 105 may be a server that provides various services, such as a background question-answering server that provides support for the answers displayed on the terminal devices 101, 102, and 103. The background question-answering server may analyze and process the received questions, and feed back the processing results (e.g., answers) to the terminal devices.

[0039] It should be noted that the server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software or software modules (e.g., multiple software or software modules used to provide distributed services), or as a single software or software module. No specific limitations are given here.

[0040] It should be noted that the method for outputting information provided in the embodiments of the present disclosure is generally executed by the server 105 , and accordingly, the device for outputting information is generally provided in the server 105 .

[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0042] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for outputting information according to the present disclosure. The method for outputting information includes the following steps:

[0043] Step 201: In response to receiving a question, convert the question into a question vector.

[0044] In this embodiment, the execution subject of the method for outputting information (eg Figure 1 The server (shown in FIG. 1 ) can receive a question from a terminal used by a user to inquire about a question via a wired or wireless connection. The question can be in text or voice. If the question is in voice, voice recognition is performed before conversion to text. Question vectors can be obtained in a variety of ways.

[0045] 1. Convert the question sentence into a question vector through word vectors. First, segment the question sentence, perform preprocessing to remove punctuation marks, meaningless words such as "的", "地", and "得", and obtain a word sequence. Then, convert each word in the word sequence into a word vector. Combine all the word vectors into a question vector. An unsupervised model (such as Word2Vec, FastText, or Elmo) can be trained with a large amount of corpus to obtain the word vector of each word. In practical applications, when training word vectors, the dimension of the word vector can be preset in advance to form word vectors of the corresponding dimension, and then sentence vectors of the corresponding dimension can be obtained. That is, word vector training can be performed on the question phrase based on the training data and the preset vector dimension. For example, after obtaining the word vectors, the sentence vector can be formed by adding vectors. Preferably, the word vectors can be weighted and summed to obtain the sentence vector. For example, when there are word vectors W1, W2, W3,..., Wn of the same dimension, the formula: W1*X1 + W2*X2 + W3*X3 + Wi*Xi... W6*X6 = S can be used, where S is the Sentence sentence vector, and Xi is the weight value corresponding to the word vector Wi.

[0046] Optionally, use the sentence vector formula to convert the sentence into a vector, which respectively represent the sentence vector, the value in the word vector, the maximum value of the word vector, and the minimum value of the word vector.

[0047]

[0048] Here, the sentence S is composed of several words w, v w is the word vector of the word w, f w is the word frequency of the word w in the corpus, n is the number of words in the sentence, α is a smoothing parameter, taking 0.01. v max and v min respectively correspond to taking the maximum value and the minimum value of each bit of all word vectors.

[0049] 2. The question sentence can also be represented as a corresponding question matrix, and convolution processing is performed on the question matrix based on the convolutional neural network model to obtain the question vector corresponding to the question sentence.

[0050] Step 202, obtain the pre-constructed candidate question vector index.

[0051] In this embodiment, the candidate question vector index is composed of at least one linked list. Each linked list includes a group of candidate question vectors, the centroid of the linked list, and the longest radius of the linked list. Each group of candidate question vectors corresponds to an answer.

[0052] The candidate question vector index (hereinafter simply referred to as the index) is constructed through the following steps:

[0053] Step 2021, group the candidate questions in the pre-stored candidate question-and-answer pair set by category.

[0054] In this embodiment, candidate questions with the same answers may be grouped into one category, that is, a group of candidate question vectors in the same linked list corresponds to one same answer.

[0055] Step 2022: For each set of candidate questions, convert the set of candidate questions into a candidate question vector.

[0056] In this embodiment, each set of candidate questions can be converted into a candidate question vector according to the method of step 201. Figure 3 As shown:

[0057] Before implementing the search algorithm, it is necessary to first select a distance function d (such as Manhattan distance) that satisfies the triangle inequality, that is:

[0058] Assume that the question-answer pairs can be divided into n categories, n i ={(q i1 , a i ),...(q im , a i )}, where (q i1 , a i ) is a question-answer pair in group i, q i1 For a question, a i is the answer of group i. All candidate questions can be converted into sentence vectors according to the method of step 201, so the vector of group i is represented as {v i1 ,...,v im}.

[0059] Step 2023, calculate the centroid of each group of candidate question vectors, and determine the distance from the centroid to the point farthest from the centroid in each group of candidate question vectors as the longest radius of each group of candidate question vectors, and store the centroid and longest radius of each group of candidate question vectors in the first element of the linked list corresponding to each group of candidate question vectors.

[0060] In this embodiment, the centroid of each group of candidate question vectors can be calculated by weighted averaging. Figure 3 As shown, the index designed by the present disclosure consists of n linked lists (n is the number of question-answer pairs). The i-th linked list consists of the vectors of the i-th group (assuming it contains m vectors), and contains a total of m+1 elements. The first element records the centroid of the i-th group of vectors (using v i denoted) and the longest radius r imax (It is equal to the distance from the center of mass to the point of the group farthest from the center of mass.) The next m elements in the linked list represent a vector of the i-th group.

[0061] Step 2024: sort each group of candidate question vectors in ascending order according to their distance to the centroid and store them in other elements of the linked list.

[0062] In this embodiment, the distances from the vectors represented by the positions to the centroid are arranged in ascending order, i.e.

[0063]

[0064] Step 203 sets the current search radius and performs the following search steps: based on the current search radius and the longest radius of each linked list, the geometric relationship between the question vector and each group of candidate question vectors is determined, and the candidate question vectors that meet the predetermined search conditions are searched in the candidate question vector groups whose geometric relationships are containment, intersection, or tangency, and added to the result set.

[0065] In this embodiment, all the previous work is completed after the index is built. When the user enters a query, a fast vector search is performed according to the following search algorithm to find the top k candidate questions closest to the query.

[0066] 1) Use the method in step 201 to obtain the sentence vector Q of the question and initialize the result set S

[0067] 2) Set the current search radius to r

[0068] 3) Determine whether the termination conditions are met. These conditions may include that the size of the result set S is k and the current search radius is greater than the distance of the vector farthest from Q in the result set S. If the termination conditions are met, the result set S is returned. Other termination conditions, such as the number of iterations and the search time, can also be set as needed. If the termination conditions are not met during the initial search, the subsequent steps are executed directly.

[0069] 4) Use a predefined distance function d (e.g., Manhattan distance) to calculate Q to each list centroid v i The distance, combined with the longest radius of this category, can be known: under the current radius, the geometric relationship between query Q and the i-th group.

[0070]

[0071] 5) If the relationship is containment, intersection, or tangency, then the search for the grouped data begins. Each linked list has two search methods: head-to-head and tail-to-tail. Therefore, each linked list needs to maintain two pointers, one indicating the search position for the group within the current radius, to avoid duplicate searches. When searching a group for the first time, a binary search can be used to quickly locate the starting positions of the head-to-tail and tail-to-head search pointers.

[0072] The following uses the head search pointer as an example to introduce the specific strategy of pointer movement. As the name suggests, the head search pointer can only move towards the head of the linked list. In a search, according to the triangle inequality of distance, when the jth vector of the i-th group satisfies d(v i , v ij )≥d(q,v i )-r, indicating that the vector is within the search radius, and the distance between the vector and the query Q is calculated.

[0073] 6) Under the current radius r, for all vectors that meet the search conditions, the distance between them and the query Q must be calculated

[0074] Step 204: determine whether the result set meets a predetermined end condition.

[0075] In this embodiment, the termination condition may include that the size of the result set S is k and the current search radius is greater than the distance of the vector farthest from Q in the result set S. If the termination condition is met, the result set S is returned. Other termination conditions, such as the number of iterations, search time, etc., may also be set as needed.

[0076] Step 205: If the result set satisfies a predetermined end condition, then the answers corresponding to a predetermined number of candidate question vectors in the result set that are closest to the question vector are output.

[0077] In this embodiment, if the result set meets the predetermined termination criteria, the final result set S, containing the top k results closest to the query, is selected and returned to the user. If a single answer is found, the top answer is presented. If multiple answers are found, the user is asked to clarify, and the top k answers are presented.

[0078] Step 206: If the result set does not meet the predetermined end condition, the current search radius is increased and the above search steps are continued.

[0079] In this embodiment, the radius r is added, and the process returns to step 2) and is repeated until the end condition is met.

[0080] Continue to see Figure 4 , Figure 4 FIG. 1 is a schematic diagram of an application scenario of the method for outputting information according to this embodiment. Figure 4In an application scenario, a user sends the question "What's the weather like today?" to the server via a terminal. The server converts the question into a sentence vector Q. A search radius of 10 is then set. The server searches the index for candidate question vectors whose distance to the centroid plus 10 is greater than or equal to the distance from Q to the centroid. Vectors v1 and v2 are found and added to the result set S. The distances between v1 and v2 and Q are calculated to be 18 and 15, respectively. This does not satisfy the requirement that the size of the result set S is greater than or equal to the predetermined value of 4. The search radius is increased to 40. The server searches the index for candidate question vectors whose distance to the centroid plus 40 is greater than or equal to the distance from Q to the centroid. Vectors v3 and v4 are found and added to the result set S. The distances between v3 and v4 and Q are calculated to be 28 and 35, respectively. Since the size of the result set S is greater than or equal to the predetermined value of 4, and the search radius of 40 is greater than the distance of the farthest vector, 35, the search ends, and the answers corresponding to the four vectors v1, v2, v3, and v4 are output.

[0081] The method provided by the above-mentioned embodiments of the present disclosure improves search efficiency and reduces labor costs by constructing a sentence vector index. The index has low maintenance costs and is highly compatible with intelligent customer service scenarios.

[0082] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for outputting information. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0083] like Figure 5 As shown, the apparatus 500 for outputting information in this embodiment includes: a converting unit 501 , an acquiring unit 502 , a searching unit 503 and a circulating unit 504 . Among them, the conversion unit 501 is configured to convert the question into a question vector in response to receiving the question; the acquisition unit 502 is configured to obtain a pre-constructed candidate question vector index, wherein the candidate question vector index is composed of at least one linked list, each linked list includes a group of candidate question vectors, the center of mass of the linked list and the longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; the search unit 503 is configured to set the current search radius and perform the following search steps: based on the current search radius and the longest radius of each linked list, determine the geometric relationship between the question vector and each group of candidate question vectors; search for candidate question vectors that meet the predetermined search conditions in the group of candidate question vectors whose geometric relationship is a containment, intersection or tangency relationship and add them to the result set; if the result set meets the predetermined end condition, output the answers corresponding to the predetermined number of candidate question vectors in the result set that are closest to the question vector; the loop unit 504 is configured to increase the current search radius if the result set does not meet the predetermined end condition and continue to perform the above-mentioned search steps.

[0084] In this embodiment, the specific processing of the conversion unit 501, the acquisition unit 502, the search unit 503 and the circulation unit 504 of the device for outputting information 500 can be referred to. Figure 2 This corresponds to steps 201-206 in the embodiment.

[0085] In some optional implementations of this embodiment, the search unit 503 is further configured to: calculate the distance from the question vector to the centroid of each linked list respectively; for at least one linked list in the linked list, if the distance from the question vector to the centroid of the linked list is less than the longest radius of the linked list, then the candidate question vector in the linked list contains the question vector; if the distance from the question vector to the centroid of the linked list is less than the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list intersects with the question vector; if the distance from the question vector to the centroid of the linked list is equal to the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list is tangent to the question vector; if the distance from the question vector to the centroid of the linked list does not meet the above-mentioned conditions of inclusion, intersection or tangency, then the candidate question vector in the linked list is separated from the question vector.

[0086] In some optional implementations of this embodiment, the search unit 503 is further configured to: for a linked list whose geometric relationship is a containment, intersection or tangency relationship, search from the linked list for a candidate question vector whose distance from the centroid of the linked list is greater than or equal to the difference between the distance from the question vector to the centroid of the linked list and the current search radius, and add the candidate question vector to the result set.

[0087] In some optional implementations of this embodiment, the predetermined end condition includes: the number of candidate question vectors in the result set is greater than or equal to a predetermined value and the current search radius is greater than the distance of the vector farthest from the question vector in the result set.

[0088] In some optional implementations of this embodiment, the conversion unit 501 is further configured to: cut the question into a word sequence; convert the word sequence into at least one word vector based on a pre-trained unsupervised model; and compose the at least one word vector into a question vector.

[0089] In some optional implementations of this embodiment, the question vector is composed of three parts: the median, maximum, and minimum value of at least one word vector.

[0090] In some optional implementations of this embodiment, the device 500 also includes a construction unit 505, which is configured to: group the candidate questions in the pre-stored set of candidate question-answer pairs by category; for each group of candidate questions, convert the group of candidate questions into a candidate question vector, calculate the center of mass of the group of candidate question vectors, and determine the distance from the center of mass to the point farthest from the center of mass in the group of candidate question vectors as the longest radius of the group of candidate question vectors, store the center of mass and the longest radius of the group of candidate question vectors in the first element of the linked list corresponding to the group of candidate question vectors, and arrange the group of candidate question vectors in ascending order according to the distance to the center of mass and store them in other elements of the linked list respectively.

[0091] Reference below Figure 6 , which shows an electronic device (eg, Figure 1 A schematic diagram of the structure of the server in (600). Figure 6 The server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0092] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0093] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead. Figure 6 Each block shown in the figure may represent one device, or may represent multiple devices as needed.

[0094] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed. It should be noted that the computer-readable medium described in the embodiment of the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In embodiments of the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including, but not limited to, an electromagnetic signal, an optical signal, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wire, optical cable, RF (radio frequency), etc., or any suitable combination thereof.

[0095] The computer-readable medium may be included in the electronic device; or it may exist independently and not be assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to receiving a question, converts the question into a question vector; obtains a pre-constructed candidate question vector index, wherein the candidate question vector index is composed of at least one linked list, each linked list includes a group of candidate question vectors, the centroid of the linked list and the longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; sets the current search radius and performs the following search steps: based on the current search radius and the longest radius of each linked list, determines the geometric relationship between the question vector and each group of candidate question vectors; searches for candidate question vectors that meet the predetermined search conditions in the group of candidate question vectors whose geometric relationship is a containment, intersection or tangency relationship and adds them to the result set; if the result set meets the predetermined end condition, outputs the answers corresponding to the predetermined number of candidate question vectors in the result set that are closest to the question vector; otherwise, increases the current search radius and continues to perform the above search steps.

[0096] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0098] The units involved in the embodiments described in the present disclosure may be implemented in software or in hardware. The units described may also be provided in a processor. For example, they may be described as follows: a processor includes a conversion unit, an acquisition unit, a search unit, and a loop unit. The names of these units do not, in some cases, constitute a limitation on the units themselves. For example, the conversion unit may also be described as a "unit that converts the question into a question vector in response to receiving the question."

[0099] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention herein is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

Claims

1. A method for outputting information, comprising: In response to receiving a question, converting the question into a question vector, including: converting the question vector through a word vector, or representing the question into a corresponding question matrix, and performing convolution processing on the question matrix based on a convolutional neural network model to obtain a question vector corresponding to the question; Obtain a pre-constructed candidate question vector index, wherein the candidate question vector index consists of at least one linked list, each linked list includes a group of candidate question vectors, a centroid of the linked list, and a longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; A current search radius is set, and the following search steps are performed: based on the current search radius and the longest radius of each linked list, a geometric relationship between the question vector and each group of candidate question vectors is determined; for linked lists whose geometric relationship is a containment, intersection, or tangency relationship, a candidate question vector is searched from the linked list for a distance from the centroid of the linked list that is greater than or equal to the difference between the distance from the question vector to the centroid of the linked list and the current search radius, and the candidate question vector is added to a result set; if the result set satisfies a predetermined termination condition, answers corresponding to a predetermined number of candidate question vectors in the result set that are closest to the question vector are output, and the predetermined termination condition includes: the number of candidate question vectors in the result set is greater than or equal to a predetermined value and the current search radius is greater than the distance of the vector in the result set that is farthest from the question vector; Otherwise, increase the current search radius and continue to perform the above search steps.

2. The method according to claim 1, wherein Determining the geometric relationship between the question vector and each group of candidate question vectors includes: Calculate the distance between the question vector and the centroid of each linked list respectively; For the linked list in the at least one linked list, if the distance from the question vector to the centroid of the linked list is less than the longest radius of the linked list, then the candidate question vector in the linked list contains the question vector; if the distance from the question vector to the centroid of the linked list is less than the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list intersects with the question vector; if the distance from the question vector to the centroid of the linked list is equal to the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list is tangent to the question vector; if the distance from the question vector to the centroid of the linked list does not meet the above-mentioned conditions of inclusion, intersection or tangency, then the candidate question vector in the linked list is separated from the question vector.

3. The method according to claim 1, wherein The converting the question into a question vector includes: Cutting the question sentence into word sequences; Converting the word sequence into at least one word vector based on a pre-trained unsupervised model; The at least one word vector is combined into a question vector.

4. The method according to claim 3, wherein: The question vector is composed of three parts: the median, the maximum, and the minimum of the at least one word vector.

5. The method according to any one of claims 1 to 4, wherein: The candidate question vector index is constructed by the following steps: Grouping candidate questions in a pre-stored set of candidate question-answer pairs into categories; For each group of candidate questions, convert the group of candidate questions into candidate question vectors, calculate the centroid of the group of candidate question vectors, and determine the distance from the centroid to the point farthest from the centroid in the group of candidate question vectors as the longest radius of the group of candidate question vectors. Store the centroid and longest radius of the group of candidate question vectors in the first element of the linked list corresponding to the group of candidate question vectors. Arrange the group of candidate question vectors in ascending order according to the distance to the centroid and store them in other elements of the linked list respectively.

6. A device for outputting information, comprising: a conversion unit configured to, in response to receiving a question, convert the question into a question vector, including: converting the question vector through a word vector, or representing the question into a corresponding question matrix, and performing convolution processing on the question matrix based on a convolutional neural network model to obtain a question vector corresponding to the question; an acquisition unit configured to acquire a pre-constructed candidate question vector index, wherein the candidate question vector index is composed of at least one linked list, each linked list including a group of candidate question vectors, a centroid of the linked list, and a longest radius of the linked list, and each group of candidate question vectors corresponds to an answer; A search unit is configured to set a current search radius and perform the following search steps: determining a geometric relationship between the question vector and each group of candidate question vectors based on the current search radius and the longest radius of each linked list; for a linked list whose geometric relationship is a containment, intersection, or tangency relationship, searching the linked list for a candidate question vector whose distance from the centroid of the linked list is greater than or equal to the difference between the distance from the question vector to the centroid of the linked list and the current search radius, and adding the candidate question vector to a result set; if the result set satisfies a predetermined end condition, outputting answers corresponding to a predetermined number of candidate question vectors in the result set that are closest to the question vector, the predetermined end condition including: the number of candidate question vectors in the result set is greater than or equal to a predetermined value and the current search radius is greater than the distance of the vector in the result set that is farthest from the question vector; The loop unit is configured to increase the current search radius and continue to perform the above-mentioned search step if the result set does not meet the predetermined end condition.

7. The device according to claim 6, wherein The search unit is further configured to: Calculate the distance between the question vector and the centroid of each linked list respectively; For a linked list in the at least one linked list, if the distance from the question vector to the centroid of the linked list is less than the longest radius of the linked list, then the candidate question vector in the linked list includes the question vector; if the distance from the question vector to the centroid of the linked list is less than the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list intersects with the question vector; If the distance from the question vector to the centroid of the linked list is equal to the sum of the longest radius of the linked list and the current search radius, then the candidate question vector in the linked list is tangent to the question vector; if the distance from the question vector to the centroid of the linked list does not meet the above-mentioned conditions of inclusion, intersection or tangency, then the candidate question vector in the linked list is separated from the question vector.

8. The device according to claim 6, wherein The conversion unit is further configured to: Cutting the question sentence into word sequences; Converting the word sequence into at least one word vector based on a pre-trained unsupervised model; The at least one word vector is combined into a question vector.

9. The device according to claim 8, wherein The question vector is composed of three parts: the median, the maximum, and the minimum of the at least one word vector.

10. The device according to any one of claims 6 to 9, wherein: The device further comprises a building unit configured to: Grouping candidate questions in a pre-stored set of candidate question-answer pairs into categories; For each group of candidate questions, convert the group of candidate questions into candidate question vectors, calculate the centroid of the group of candidate question vectors, and determine the distance from the centroid to the point farthest from the centroid in the group of candidate question vectors as the longest radius of the group of candidate question vectors. Store the centroid and longest radius of the group of candidate question vectors in the first element of the linked list corresponding to the group of candidate question vectors. Arrange the group of candidate question vectors in ascending order according to the distance to the centroid and store them in other elements of the linked list respectively.

11. An electronic device for outputting information, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

12. A computer-readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Question and answer matching method, system and equipment based on language model and storage medium

    CN110019736A