Query content library construction method, device, electronic device and readable storage medium
By determining high-frequency target query statements in the query content library and constructing the query content library, the problems of high redundancy and poor quality of the query content library in the existing technology are solved, and more accurate search results are achieved.
Patent Information
- Application Number
- CN202210404304.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-18
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2042-04-18
AI Technical Summary
The existing query content library has high redundancy, poor quality, inaccurate search results, and inability to meet user needs due to the numerous and complex user historical search behaviors.
By obtaining the clicked content and its corresponding query statements and search frequency values, we can determine high-frequency target query statements, build a query content library, streamline the query statement library, and improve the accuracy of search results.
The size of the query statement library is reduced, the quality of the query statement library is improved, and the accuracy of search results and the quality of recall results are improved.
Smart Images

Figure CN114706841B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of search technology, and in particular to a method, device, electronic device and readable storage medium for constructing a query content library. Background Art
[0002] With the development of Internet technology, users need to use the search function in many scenarios, and the search results correspond to the query content entered by the user.
[0003] Currently, when a user enters a query, he or she can retrieve the most relevant extended query statements from the query content library. The query content library is constructed based on the user's historical search behavior in different scenarios. However, since the user's historical search behavior is numerous and complex, the query content in the existing query content library has a high degree of redundancy, and there are many contents with low search frequency and poor quality, resulting in inaccurate search results that cannot meet the actual needs of users.
[0004] Therefore, how to streamline the existing query content library and improve the accuracy of search results is a technical problem that needs to be solved. Summary of the invention
[0005] One of the purposes of the present invention is to provide a method, device, electronic device and readable storage medium for constructing a query content library, which can streamline the existing query content library and improve the accuracy of search results.
[0006] In a first aspect, the present invention provides a method for constructing a query content library, the method comprising: obtaining multiple clicked contents, all query statements corresponding to each clicked content, and a search frequency value corresponding to each query statement; according to the search frequency value, determining part of the query statements corresponding to each clicked content as target query statements; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency values of other query statements of the clicked content; and constructing a query content library according to the target query statement corresponding to each clicked content.
[0007] In a second aspect, the present invention provides a query content library construction device, comprising: an acquisition module, used to obtain multiple clicked contents, all query statements corresponding to each clicked content, and a search frequency value corresponding to each query statement; a determination module, used to determine part of the query statements corresponding to each clicked content as target query statements based on the search frequency values; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency values of other query statements of the clicked content; and a construction module, used to construct a query content library according to the target query statement corresponding to each clicked content.
[0008] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the method described in the first aspect.
[0009] In a fourth aspect, the present invention provides a readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in the first aspect.
[0010] The present invention provides a method, device, electronic device and readable storage medium for constructing a query content library. The method includes: obtaining multiple clicked contents, all query statements corresponding to each clicked content, and the search frequency value corresponding to each query statement; according to the search frequency value, determining part of the query statements corresponding to each clicked content as target query statements; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency value of other query statements of the clicked content; and constructing a query content library according to the target query statement corresponding to each clicked content. Before constructing the query content library, the embodiment of the present invention first determines the search frequency value of all query contents corresponding to each clicked content. It can be understood that the larger the search frequency value, the more useful the query content is to the user and the higher the quality. Therefore, the embodiment of the present invention counts the search frequency values of all query contents that recall each clicked content, and then selects the target query statement from all the query contents. In this way, the query statement library is constructed together with the target query statements with high search frequency values corresponding to each clicked content, which not only reduces the scale of the query statement library, but also improves the quality of the query statement library. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0012] Figure 1 A schematic diagram of a scenario provided by an embodiment of the present invention;
[0013] Figure 2 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0014] Figure 3 A flowchart of a method for building a query content library provided by an embodiment of the present invention;
[0015] Figure 4One of the flowcharts of another method for building a query statement library provided by an embodiment of the present invention;
[0016] Figure 5 A second flowchart of another method for building a query content library provided by an embodiment of the present invention;
[0017] Figure 6 This is a functional module diagram of the query content library construction device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0019] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0021] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0022] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0023] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0024] Please refer to Figure 1 , Figure 1A schematic diagram of a scenario provided for an embodiment of the present invention, in which a terminal can be connected to a server for communication, and a query content library can be stored in the cloud or in the server, which is not limited here.
[0025] The terminal may be, but is not limited to, a smart phone, a tablet computer, a portable computer, a wearable mobile terminal, etc. The server may be an independent server or a server cluster composed of multiple servers, which is not limited here.
[0026] The user can enter any query content (Quary) in the search area of the terminal, and the terminal sends the obtained Quary to the server, and the server finds N recall results (Target Query) most relevant to the input Quary from the query content library (Quary library).
[0027] For example, a user enters a novel name A in the search interface, and the terminal sends the obtained novel name A to the server. The server searches the query content library based on the obtained novel name A to obtain the target query content most relevant to the novel name A, such as the latest chapter of A, TV series A to watch, how to evaluate A, and other target query content. Because the query library maintains common search content or frequently asked questions, and corresponds to high-quality recall content or answers, the existing query rewriting technology is used to help users retrieve the most relevant results.
[0028] However, the existing query content library is built based on the historical search behaviors of users in different scenarios. Due to the numerous and complex historical search behaviors of users, the query content redundancy in the existing query content library is high, and there are many contents with low search frequency and poor quality, resulting in inaccurate search results and unable to meet the actual needs of users.
[0029] For example, suppose that the content the user expects to see is ItemA, and 900,000 users obtain ItemA through Query1 search, 100,000 users obtain ItemA through Query2, and 1,000 users obtain ItemA through Query3. Then there is no doubt that for ItemA, Query1 is undoubtedly a high-quality query statement, while Query3 is obviously a low-quality query statement. In actual scenarios, users prefer to link to ItemA through Query1. Therefore, if the user enters a Query, the N Target Queries retrieved from the query content library contain a large number of low-quality results (such as the above Query3) but meet the similarity requirements, which obviously cannot meet the original intention of query rewriting.
[0030] Therefore, in order to streamline the existing query content library and improve the accuracy of search results, the present invention implements a query content library construction method, which can determine some high-quality query statements to construct a query content library, which not only filters out many query statements with high redundancy but poor quality, but also reduces the size of the query statement library, which provides a reliable guarantee for subsequently improving the quality of recall results.
[0031] First, an execution device of the query content library construction method provided by an embodiment of the present invention is introduced.
[0032] Figure 2 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, the electronic device may be Figure 1 The electronic device 200 may include: a memory 201, a processor 202, and a communication interface 203, wherein the memory 201, the processor 202, and the communication interface 203 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses or signal lines.
[0033] The memory 201 can be used to store software programs and modules, such as the query content library construction device 400 instructions / modules provided in the embodiment of the present invention, which can be stored in the memory 201 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 200. The processor 202 executes various functional applications and data processing by executing the software programs and modules stored in the memory 201. The communication interface 203 can be used to communicate signaling or data with other node devices.
[0034] Among them, the memory 201 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.
[0035] The processor 202 may be an integrated circuit chip with signal processing capability. The processor 202 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0036] Understandably, Figure 2 The structure shown is for illustration only. The electronic device 200 may also include Figure 2 More or fewer components as shown, or with Figure 2 Different configurations are shown. Figure 2 The components shown may be implemented in hardware, software or a combination thereof.
[0037] Figure 3 A flowchart of a method for building a query content library provided by an embodiment of the present invention. Figure 2 The electronic device in the above is the execution subject, refer to Figure 3 As shown, the method includes:
[0038] S301, obtaining a plurality of clicked contents, all query statements corresponding to each clicked content, and a search frequency value corresponding to each query statement.
[0039] In the embodiment of the present invention, the clicked content (hereinafter referred to as Item) can be any recall result corresponding to a query statement (Quary). It can be considered that each Item is meaningful to the user and can meet the content requirements. Each Item can correspond to multiple Queries, that is, the same Item can be recalled by different forms of Queries. Therefore, for a Quary, the recall result clicked by the user is the clicked content in the embodiment of the present invention.
[0040] In an optional implementation, feedback data may be obtained first. The feedback data all comes from the content clicked by the user after the online search. SQL may be used to find the correspondence between all queries and items and the search frequency value (aqcnt) corresponding to each query.
[0041] The above search frequency value (aqcnt) can be understood as: the total number of times a user searches with a Quarry and clicks on a recall result item in the Quarry. Since meaningful searches are all about obtaining content, the larger the aqcnt, the more commonly used the Quarry is, and the higher the quality of the Quarry is. Building a query content library (Quary library) with some high-quality Quarries can not only streamline the Quarry library, but also improve the accuracy and quality of recall results in actual query scenarios.
[0042] S302: According to the search frequency value, determine the partial query statement corresponding to each clicked content as the target query statement.
[0043] What is obviously different from the prior art is that the prior art may use all the query statements corresponding to the clicked content to build a query statement library. For example, continuing with the above-mentioned ItemA as an example, the prior art may store Query1, Query2 and Query3 in the query statement library. Obviously, Query3 is a low-quality Query, which will undoubtedly reduce the quality of subsequent query results. In this embodiment, for each clicked content, the number of target query statements (Target Query) is less than the total number of all query statements. That is to say, the embodiment of the present invention determines part of the query statements of each clicked content as target query statements, so as to build a query statement library, thereby achieving the effect of streamlining the query statement library.
[0044] In this embodiment, for each clicked content, the search frequency value of the target query statement is greater than the search frequency values of other query statements for the clicked content.
[0045] S303: construct a query content library according to the target query statement corresponding to each clicked content.
[0046] In the embodiment of the present invention, the search frequency value of the target query statement corresponding to each clicked content is greater than the search frequency value of the remaining query statements in all query statements corresponding to the clicked content. Through the search frequency value, the target query statement corresponding to each clicked content can be extracted, which can also be understood as extracting high-quality query statements to form a new query content library. In this way, the new query content library is full of high-quality queries, which can ensure the accuracy of queries in actual scenarios. For example, continuing to take the above ItemA as an example, the target query statement corresponding to ItemA can be Query1, and then Query1 is used to construct a query statement library, thereby improving the quality of the query statement library.
[0047] Optionally, in the process of determining the high-quality query content (ie, the target query sentence in the embodiment of the present invention) corresponding to each clicked content, the embodiment of the present invention provides a variety of different implementation methods.
[0048] In one implementation, the above step S302 may be implemented with reference to steps a1 to a2:
[0049] a1, according to a plurality of preset candidate content length intervals, all query statements corresponding to each clicked content are divided into a plurality of statement groups.
[0050] It is understandable that, considering the actual search scenario, the query lengths input by users are different, so all query statements can be grouped according to the text length, each statement group corresponds to a candidate content length interval, and then a preset number of target query statements are selected in each statement group according to the search frequency value, so that high-quality query statements can be evenly obtained from multiple statement groups.
[0051] In this embodiment, the candidate content length interval can be determined based on the length distribution of the query input by the user in the actual online search scenario. For example, the candidate content length interval can be: [1-3], [4-7], [8-10], [11-], which respectively represent the text length between 1 and 3 characters, the text length between 4 and 7 characters, the text length between 8 and 10 characters, and the text length above 11 characters.
[0052] It should be noted that the above candidate content length interval is only a preferred example and not a limitation of the candidate content length interval. The pre-defined candidate content length interval can be further expanded in combination with actual search behaviors so that the interval distribution can better fit the actual search situation.
[0053] a2. In each sentence group corresponding to each clicked content, a preset number of target query sentences are determined according to the search frequency value.
[0054] According to the above content, the higher the search frequency value, the more commonly used a query is and the higher the quality is. Therefore, in the process of determining the target query statement, the query statements in each statement group can be arranged in order from large to small according to the search frequency value, and then the first N query statements can be used as the target query statements. Alternatively, the query statements in each statement group can be arranged in order from small to large according to the search frequency value, and then the last N query statements can be used as the target query statements.
[0055] In another implementation, the above step S302 may also be implemented with reference to steps b1 to b2:
[0056] b1, dividing all query statements corresponding to each clicked content into multiple statement groups according to multiple preset candidate content length intervals;
[0057] b2, determining the number of target query sentences corresponding to each sentence group according to the sentence coverage of each of the multiple candidate content length intervals;
[0058] b3. In each sentence group of each clicked content, a target query sentence is determined according to the search frequency value and the number of target query sentences.
[0059] In an embodiment of the present invention, considering that in actual search scenarios, different numbers of queries are covered in different candidate content length intervals, the embodiment of the present invention can also select different numbers of target query statements in different content length intervals to ensure that the target query statements obtained meet the actual scenarios.
[0060] For example, let's continue to take the above candidate content length intervals: [1-3], [4-7], [8-10], [11-] as an example. Among them, the number of queries covered in the [4-7] interval is the largest, and the number of queries in the [11-] interval should not be too large. Therefore, according to aqcnt from large to small, the TOP1 can be retained in the [1-3] interval, the TOP3 in the [4-7] interval, the TOP1 in the [8-10] interval, and the TOP1 at most in the [11-]. In this way, many Target Queries with high redundancy that do not need to be retained are filtered out, and the Query library is streamlined.
[0061] In another implementation, the above step S302 can be implemented with reference to step c1:
[0062] c1, determine a query statement with the maximum search frequency value among all query statements corresponding to each clicked content as the target query statement.
[0063] In an embodiment of the present invention, it is also possible to ignore the different numbers of queries distributed in different length intervals and directly use the query statement with the maximum search frequency value corresponding to each Item as the target query statement. In this way, the query statement with the maximum search frequency value corresponding to each Item can form a high-quality query content library.
[0064] Figure 4 One of the flow charts of another query statement library construction method provided in an embodiment of the present invention, the method can apply the obtained high-quality query statements in actual search scenarios to improve the quality of recall results.
[0065] S304, obtaining the content to be queried.
[0066] In an embodiment of the present invention, the above-mentioned content to be queried may come from an actual online search, for example, the query content manually input by a user on a search interface, or the query content obtained through speech recognition, text recognition and other technologies, which is not limited here.
[0067] S305, based on the pre-trained vector coding model and the query content library, determine the recall results that match the content to be queried.
[0068] In the embodiment of the present invention, combined with the high-quality query content library constructed as above, the risk of obtaining low-quality recall results can be reduced, and the accuracy of the recall results can be ensured. At the same time, in order to improve the accuracy of the similarity between the query statement and the recall result, the embodiment of the present application provides a vector encoding model. The vector encoding model in the embodiment of the present invention is trained in the following manner, as shown in steps d1 to d2:
[0069] d1, obtaining multiple groups of training samples; each group of training samples includes a query sentence sample, a positive sample and a negative sample corresponding to the query sentence sample;
[0070] D2, through the query sentence samples, the positive samples and the negative samples corresponding to the query sentence samples, the first loss function and the second loss function of the BERT model to be trained are alternately trained until the training end condition is met, and the trained BERT model is used as the vector encoding model.
[0071] It should be noted that the above-mentioned vector coding model can be pre-trained, and when the sentence to be queried is obtained, the vector coding model is loaded to calculate the similarity. Alternatively, after obtaining the sentence to be queried, the above-mentioned steps d1 and d2 can be executed to obtain the vector coding model, and then the obtained vector coding model is used to calculate the similarity, which is not limited in the embodiments of the present invention.
[0072] At present, the BERT model is the most widely used model in query rewriting technology. Its principle is: first encode the query library content into a vector and build a vector index. When processing user queries in real time, encode it into a vector first, and then find the N target queries with the largest cosine similarity with the user query as the final rewriting result.
[0073] However, although the current BERT model can improve the accuracy of semantic similarity, in actual use, when the lengths of two query texts differ greatly, the problem of inaccurate semantic similarity still occurs. The reason is that the existing training method causes the trained BERT model to have the following problems: First, the model's "memory" is too strong, causing a certain component in the string to play a dominant role.
[0074] For example, the similarity between "In the Snow" and "Latest Chapters of The Snowy Path of the Blazing Blade" is very high. Due to the excessive co-occurrence contribution in the training set, the encoding vector of "Latest Chapters of The Snowy Path of the Blazing Blade" has been dominated by its component "In the Snow". Second, the model has learned semantics, but not the key semantics. For example, for the text "College English Book 3", its similarity to "College English Book 2" is lower than its similarity to "Japanese for College Students Book 3". Obviously, the model focuses on determiners such as "Book N" and ignores the similarity of the core words. Through research, it is found that the reason for the above problems is that the existing training methods make the learning tasks too easy and lack difficult comparison samples.
[0075] Therefore, to solve the above problems, the embodiments of the present invention use the training method of steps d1 to d2 to train the existing bert model. It should be noted that since the actual search business scenario is vertical search, usually the length of the Query ranges from 2 to 20 characters, and the Query library also contains search terms with high user click-through rates, which is not different from the distribution of user Queries. Therefore, the model structure of the Bert model to be trained in the embodiments of the present invention can use the model structure of the Bert model in the prior art. For example, the Bert model to be trained can be a 4-layer Bert distilled from a 12-layer Bert Base, with an output dimension of 256. After fine-tuning the Bert model to be trained with the training method provided by the embodiments of the present invention, the vector encoding model in the embodiments of the present invention is finally obtained.
[0076] During the training process, after obtaining a query statement sample, this embodiment can obtain positive and negative samples with similar semantics but different lengths from the query statement library constructed above. Among them, in addition to the above implementation methods, the acquisition of negative samples can also include: obtained by rewriting the query statement sample and / or the positive sample of the query statement sample, which is not limited here.
[0077] For example, for a query statement sample, assuming that there are M candidate statements for this query statement sample, arrange these M candidate statements in descending order of length, and then take the one with the largest length or N (N is less than M) as the negative sample, and take the one with the smallest length or S (S is less than N) as the positive sample. For example, if the Query is "In the Snow", both "In the Snow Walk" and "Latest Chapters of The Snowy Path of the Blazing Blade" are candidate statements, then "In the Snow Walk" is the positive sample, and "Latest Chapters of The Snowy Path of the Blazing Blade" is the negative sample.
[0078] In order to improve the accuracy of the model, the embodiment of the present invention adopts a training method of alternating the first loss function and the second loss function to ensure the training effect, wherein the first loss function may be, but not limited to, a contrast loss function (Contrast Loss), and the second loss function may be, but not limited to, a triplet loss. Taking Contrast Loss and Triplet Loss as examples, when the samples obtained in step d1 are used for training, Contrast Loss and Triplet Loss may be shown as formula (1) and formula (2), respectively:
[0079]
[0080] Among them, l i Characterizes the loss function of the first training sample; h i is the encoding vector corresponding to the i-th training sample; The encoding vector representing the positive sample corresponding to the i-th training sample; The encoding vector representing the positive sample corresponding to the jth training sample; t is a constant coefficient; sim() represents the calculation of similarity;
[0081]
[0082] Among them, q (i) Represents the i-th training sample, Represents the positive sample of the i-th training sample; Represents the negative sample of the i-th training sample; m is a constant coefficient.
[0083] It can be seen from the above two relationship equations that the training method of the embodiment of the present invention can be understood as follows: after obtaining multiple groups of training samples, all query sentence samples and positive samples in the multiple groups of training samples are used to train the first loss function so that the obtained model can achieve the function of improving the accuracy of similarity. The positive samples and negative samples in each group of training samples are used to train the second loss function, which can ensure that the obtained model improves the similarity to the maximum extent. Through the alternating training of the two loss functions, the trained BERT model can improve the accuracy of semantic similarity.
[0084] In an optional implementation manner, the above alternating training method may be:
[0085] The first implementation mode: training the first loss function at odd iterations and training the second loss function at even iterations; or training the second loss function at odd iterations and training the first loss function at even iterations;
[0086] The second implementation method: the first loss function and the second loss function are separated by a preset number of times. For example, after the first loss function is trained N times, the second loss function is trained; when the second loss function is trained M times, the first loss function is trained again until the preset number of training times is reached.
[0087] Wherein, M and N may be the same or different, and are not limited here.
[0088] It should be noted that the first loss function can be trained first, or the second loss function can be trained first. The embodiment of the present invention does not limit the training order of the first loss function and the second loss function.
[0089] It should also be noted that Figure 4 The flowchart shown is merely an example of the execution order between the above steps S304 and S305, and the above steps S301 to S303, and is not a limitation on the execution order between them. It can be understood that in one scenario, the query content library can be pre-constructed and stored, and after obtaining the query statement, the pre-constructed query content library is called to perform the query. In another scenario, after obtaining the query statement, the query content library can be constructed in real time, and then the query is performed based on the obtained query content library. The embodiment of the present invention is not limited to this.
[0090] In an optional implementation manner, the implementation process of the above step S305 can be performed with reference to steps e1 to e3:
[0091] e1, through the vector coding model, multiple candidate query contents that match the to-be-queried contents are retrieved from the query content library.
[0092] In the implementation of the present invention, the vector coding model obtained through steps d1 to d2 can be used to retrieve candidate query content matching the content to be queried from the query content library. The specific implementation method is as follows:
[0093] The first step is to encode the query content and the query content in the Query library through the vector encoding model to obtain their respective encoding vectors, and calculate the cosine similarity between the encoding vector corresponding to the query content and the encoding vector in the Query library;
[0094] In the second step, N candidate query contents (Target Query) are retrieved from the Query library, wherein the cosine similarity between the N candidate query contents and the content to be queried is greater than the cosine similarity between the remaining query contents in the Query library and the content to be queried.
[0095] It should be noted that in the second step, the vector indexing method (such as Hierarchical-Navigable-Small-World-Graph, abbreviated as HNSW) can be used, but is not limited to it. This embodiment does not make any limitations.
[0096] e2. Determine the string similarity between each candidate query content and the query content to be queried.
[0097] e3. Determine the candidate query content that meets the string similarity threshold as the recall result.
[0098] It can be understood that after obtaining N Target Queries, the string similarity between each Target Query and the Query can also be calculated to further screen the Target Queries to obtain Target Queries highly relevant to the Query.
[0099] In an optional implementation manner, the method for calculating the string similarity between each Target Query and the Query can be, but is not limited to, the Jaccard distance, the minimum edit distance algorithm, etc. No limitations are made here.
[0100] Figure 5 This is the second flowchart of another query content library construction method provided by the embodiments of the present invention. The purpose is to assume that there are multiple recall results and determine the sorting scores of the multiple recall results, which provides a reference basis for determining the rough sorting strategy for each recall result later. The method further includes:
[0101] S306. When there are multiple recall results, sort the multiple recall results according to the search frequency values, and based on the sorted multiple recall results, determine the corresponding arrangement serial number for each recall result.
[0102] In the embodiments of the present invention, all the search terms in the Query library are numbered from largest to smallest according to aqcnt. The earlier the number, the stronger the importance of the Query can be regarded as. Considering that the Bert model can only consider semantics, the quality of the recall results may vary. For example, if the Query is "Listen to Snow in the Severed Blade", the recall results are "Snow in the Severed Blade", "Severed Blade in the Snow", "Snow|Severed Blade", etc. Obviously, the purpose of rough sorting is to further filter out redundant results, and the basis is the importance of the Query.
[0103] It can be understood that the recall results all come from the query content library constructed above, so each recall result corresponds to a search frequency value, and multiple recall results are sorted based on the search frequency value. In this embodiment, the above recall results are arranged in order from large to small according to the search frequency value. It can be seen that the larger the search frequency value of the recall result, the higher the arrangement order and the smaller the arrangement number.
[0104] It should be noted that after arranging multiple recall results in descending order according to the search frequency value, the importance of each recall result is transformed from being represented by the size of the search frequency value to being represented by the arrangement needs. In other words, the smaller the arrangement number of the recall result, the more important the recall result is. In this way, the problem of high computational complexity and low efficiency due to uneven distribution of search frequency values of multiple recall results can be avoided.
[0105] S307, calculating the importance factor of each recall result based on the arrangement sequence number corresponding to each recall result.
[0106] In the embodiment of the present invention, the importance factor of the recall result and the arrangement sequence number of the recall result may satisfy the following relationship:
[0107] magnitude = int(log 10 max(idx,1))
[0108] Among them, magnitude represents the importance factor, and idx represents the ranking number.
[0109] S308, obtaining a ranking score for each recall result according to the importance factor and ranking sequence number of each recall result.
[0110] In an optional implementation manner, the ranking score and the importance factor and ranking number of each recall result satisfy the following relationship:
[0111]
[0112] Among them, rankScore represents the ranking score; magnitude represents the importance factor; idx represents the arrangement number.
[0113] Continuing with the above relationship, max(4-magnitude,0) can be understood as the magnitude importance score of a recall result. gnitude ), It can be understood as the numerical importance score of a recall result. internal), the sum of these two scores can be used to evaluate the ranking score of a recall result, where a higher ranking score of a recall result indicates that the recall result is more important.
[0114] After obtaining the ranking scores of multiple recall results, a reference basis can be provided for the subsequent determination of a rough ranking strategy for these multiple recall results. In an optional implementation, when considering a rough ranking strategy for multiple recall results, the cosine similarity (obtained through the vector coding model in the embodiment of the present invention) between the content to be queried and the multiple recall results, the string similarity and the ranking score can be weighted and summed to obtain an evaluation value, and the recall results can be roughly ranked based on the evaluation value, and the ranking results can be displayed on the user terminal so that the user can more intuitively obtain the recall results that are most relevant to the content to be queried.
[0115] Figure 6 The functional module diagram of the query content library construction device provided by the embodiment of the present invention is shown in FIG. Figure 6 As shown, the query content library construction device 400 includes: an acquisition module 410 , a determination module 420 and a construction module 430 .
[0116] The acquisition module 410 is used to obtain multiple clicked contents, all query statements corresponding to each clicked content, and the search frequency value corresponding to each query statement;
[0117] The determination module 420 is used to determine a target query statement from the partial query statements corresponding to each clicked content according to the search frequency value; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency values of other query statements of the clicked content;
[0118] The construction module 430 is used to construct a query content library according to the target query statement corresponding to each clicked content.
[0119] In an optional implementation, the determination module 420 is specifically used to: divide all query statements corresponding to each clicked content into multiple statement groups according to preset multiple candidate content length intervals; in each statement group corresponding to each clicked content, determine a preset number of target query statements according to the search frequency value.
[0120] In an optional embodiment, the determination module 420 is further specifically used to: divide all query statements corresponding to each clicked content into multiple statement groups according to a plurality of preset candidate content length intervals; determine the number of target query statements corresponding to each statement group according to the statement coverage of each of the plurality of candidate content length intervals; and determine the target query statement in each statement group of each clicked content according to the search frequency value and the number of target query statements.
[0121] In an optional implementation, the determination module 420 is further specifically configured to: determine the query statement with the maximum search frequency value among all query statements corresponding to each clicked content as the target query statement.
[0122] In an optional implementation, the acquisition module 410 is further used to acquire the content to be queried; the determination module 420 is further used to determine the recall results matching the content to be queried based on a pre-trained vector encoding model and a query content library.
[0123] In an optional implementation manner, the vector coding model is obtained by training in the following manner: obtaining multiple groups of training samples, each group of training samples comprising query statement samples, positive samples and negative samples corresponding to the query statement samples; alternately training the first loss function and the second loss function of the BERT model to be trained by using the query statement samples, the positive samples and the negative samples corresponding to the query statement samples, until the training end condition is met, and using the trained BERT model as the vector coding model.
[0124] In an optional implementation, the determination module 420 is further specifically used to: retrieve multiple candidate query contents that match the content to be queried from the query content library through a vector coding model; determine the string similarity between each candidate query content and the content to be queried; and determine the candidate query contents that meet the string similarity threshold as recall results.
[0125] In an optional implementation, the determination module 420 is also used to: when there are multiple recall results, sort the multiple recall results according to the search frequency value, and determine the arrangement number corresponding to each recall result based on the sorted multiple recall results; based on the arrangement number corresponding to each recall result, calculate the importance factor of each recall result; and obtain the ranking score of each recall result according to the importance factor and arrangement number of each recall result.
[0126] In an optional implementation manner, the ranking score satisfies the following relationship with the importance factor and the ranking number of each recall result:
[0127]
[0128] Among them, rankScore represents the ranking score; magnitude represents the importance factor; idx represents the arrangement number.
[0129] The embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the query statement library construction method as described in any one of the above embodiments is implemented. The computer readable storage medium can be, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a magnetic disk, or an optical disk.
[0130] It should be understood that the device and method disclosed in the present invention can also be implemented in other ways. The device embodiments described above are only schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing 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 from the order marked in the accompanying drawings. For example, two consecutive boxes 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 boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0131] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0132] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes. It should be noted that in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0133] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention. It should be noted that similar numbers and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
Claims
1. A method for constructing a query content library, characterized in that: The method comprises: Obtain multiple clicked contents, all query statements corresponding to each clicked content, and a search frequency value corresponding to each query statement; According to the search frequency value, determining the part of the query statement corresponding to each clicked content as the target query statement; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency value of other query statements of the clicked content; Build a query content library based on the target query statement corresponding to each clicked content; Acquire the content to be queried; determine the recall result matching the content to be queried based on a pre-trained vector coding model and the query content library, wherein the vector coding model is trained based on training samples and positive samples and negative samples corresponding to the training samples; When there are multiple recall results, the multiple recall results are sorted according to the search frequency value, and based on the sorted multiple recall results, the arrangement number corresponding to each recall result is determined; based on the arrangement number corresponding to each recall result, the importance factor of each recall result is calculated; according to the importance factor of each recall result and the arrangement number, the sorting score of each recall result is obtained; the sorting score and the importance factor of each recall result and the arrangement number satisfy the following relationship: Among them, rankScore represents the ranking score; magnitude represents the importance factor; idx represents the arrangement number.
2. The method for constructing a query content library according to claim 1, characterized in that: According to the search frequency value, a part of the query statement corresponding to each clicked content is determined as a target query statement, including: According to the preset multiple candidate content length intervals, all query statements corresponding to each clicked content are divided into multiple statement groups; In each sentence group corresponding to each clicked content, a preset number of the target query sentences are determined according to the search frequency value.
3. The method for constructing a query content library according to claim 1, characterized in that: According to the search frequency value, a target query statement is determined from all query statements corresponding to each clicked content, including: According to the preset multiple candidate content length intervals, all query statements corresponding to each clicked content are divided into multiple statement groups; Determining the number of target query sentences corresponding to each sentence group according to the sentence coverage of each of the plurality of candidate content length intervals; In each sentence group of each clicked content, the target query sentence is determined according to the search frequency value and the number of the target query sentences.
4. The method for constructing a query content library according to claim 1, characterized in that: According to the search frequency value, a target query statement is determined from all query statements corresponding to each clicked content, including: Among all query statements corresponding to each clicked content, a query statement having a maximum search frequency value is determined as a target query statement.
5. The method for constructing a query content library according to claim 1, characterized in that: The vector coding model is obtained by training in the following manner: Obtain multiple groups of training samples; each group of training samples includes a query sentence sample, a positive sample and a negative sample corresponding to the query sentence sample; The first loss function and the second loss function of the BERT model to be trained are alternately trained through the query sentence samples and the positive samples and negative samples corresponding to the query sentence samples until the training end condition is met, and the trained BERT model is used as the vector encoding model.
6. The method for constructing a query content library according to claim 1, characterized in that: When the content to be queried is obtained, based on the vector coding model and the query content library, a recall result matching the content to be queried is determined, including: Retrieving a plurality of candidate query contents that match the content to be queried from the query content library through the vector coding model; Determine the string similarity between each candidate query content and the content to be queried; The candidate query content that meets the string similarity threshold is determined as the recall result.
7. A query content library construction device, characterized in that: include: An acquisition module, used to obtain multiple clicked contents, all query statements corresponding to each clicked content, and a search frequency value corresponding to each query statement; A determination module, configured to determine, according to the search frequency value, a portion of the query statement corresponding to each clicked content as a target query statement; wherein, for each clicked content, the search frequency value of the target query statement is greater than the search frequency values of other query statements of the clicked content; A construction module, used to construct a query content library according to a target query statement corresponding to each clicked content; The acquisition module is further used to acquire the content to be queried; the determination module is further used to determine the recall result matching the content to be queried based on the pre-trained vector encoding model and the query content library; The determination module is also used for: when there are multiple recall results, sorting the multiple recall results according to the search frequency value, and determining the arrangement number corresponding to each recall result based on the sorted multiple recall results; calculating the importance factor of each recall result based on the arrangement number corresponding to each recall result; obtaining the sorting score of each recall result according to the importance factor and the arrangement number of each recall result; the sorting score and the importance factor and the arrangement number of each recall result satisfy the following relationship: Among them, rankScore represents the ranking score; magnitude represents the importance factor; idx represents the arrangement number.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the method according to any one of claims 1 to 6.
9. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Method for cascading hybrid document search with two-criteria pre-filtering based on access labels and thematic tags
RU2867094C1
