Method, device and electronic device for generating query processing model
By performing session segmentation and filtering of historical query data, extracting target queries and training query processing models, the difficulties of search engines in understanding user query intentions are solved, and more accurate and relevant search results are achieved.
Patent Information
- Application Number
- CN202111234747.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-10-22
AI Technical Summary
Existing search engines have difficulties in understanding user query intentions, which leads to inaccurate and relevant enough to effectively solve user query needs.
By performing session segmentation and filtering of historical query data, target queries are extracted, and training sample sets are constructed based on the similarity relationship between target queries, preset learning models are trained to generate target models for query override and recall.
It improves the accuracy and efficiency of the query processing model, enhances the accuracy of query rewriting and the restore degree of search intention, thereby improving the quality and relevance of search results.
Smart Images

Figure CN114117183B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of search engines, and particularly to a method, a device and an electronic device for generating a query processing model. Background Art
[0002] Search engines can retrieve and return corresponding documents based on the query entered by the user to provide users with information that meets their query needs and meet people's needs for searching in massive amounts of information. Today, search engines have become the portal and essential tool for many users to use the Internet. As the amount of Internet information and the terminal devices that access the Internet have experienced explosive growth, search engine technology is also constantly improving and innovating to adapt to new situations and changing needs. In addition to adapting to the growing number of searches, improving search quality is also an important aspect that search engines need to consider. For example, how to accurately determine and feedback documents related to the query conditions based on the query conditions proposed by the user, return as few irrelevant documents as possible, and enable the questions raised by the query to be quickly resolved is an intuitive measure of high-quality search; on the other hand, how to analyze the user's query request and fully and accurately understand the user's query intent based on the query text entered by the user is the basis for effectively recalling documents for the query.
[0003] Some factors affect the search engine's accurate understanding of the query input by the user, thereby affecting the recall of accurate search results. For example, the query words input by the user are usually relatively concise, and in most cases only contain one or two words. Therefore, it is difficult to accurately determine which aspect of the query word the search intent is based on the query. For example, when the user enters "browser" for query, the possible intentions may include browser download, browser knowledge, mobile browser app installation method, browser evaluation, etc. When the search engine cannot determine the user's specific intention, it can only return content according to a certain strategy, but it cannot guarantee that the recalled documents can quickly meet the query requirements. Problems such as short query words, difficult query descriptions, complex natural language semantics, polysemy, inaccurate user expressions, and input errors will cause difficulties in understanding the search intent, that is, the query intent cannot be accurately understood through the input query, and it is difficult to match with valid documents, thus forming a semantic gap between the query and the document, and it is impossible to obtain satisfactory query results. It can be seen that query analysis with the goal of understanding the query intent input by the user is a very important function and component of the search engine. The quality of search intent analysis directly affects the coverage and relevance of search results.
[0004] In the prior art, there are many ways to determine the query intent, such as providing query suggestions, query expansion, query rewriting, etc. Among them, the query rewriting process is to obtain a certain number of similar queries based on the original input query through a certain method, and then use the similar queries and the original input query to search together to obtain a richer and more accurate document collection. However, in the prior art, the query rewriting method needs to be improved to overcome the shortcomings. For example, in the query expansion method based on synonyms, relying on artificial a priori synonym tables, it is easy to have little or even no recall, and it cannot solve the problem of the semantic gap between the query and the document. Some query rewriting technologies based on algorithm models are not automated enough, or because the implementation method is relatively mechanical, a large amount of manual annotation or error correction of irrelevant results is still required during operation, and the accuracy of understanding the search intent needs to be further improved. Summary of the invention
[0005] The embodiments of the present invention provide a method, device and electronic device for generating a query processing model, which can efficiently and automatically construct a training sample set, train a more accurate query processing model, and obtain more accurate similar queries when rewriting queries.
[0006] The present invention provides the following scheme:
[0007] A method for generating a query processing model, comprising:
[0008] Perform session segmentation on historical query data and determine session segmentation data;
[0009] Filtering based on the session segmentation data to extract target queries;
[0010] Determine a similarity relationship between target queries, and construct a training sample set according to the similarity relationship;
[0011] Based on the constructed training sample set, the preset learning model is trained to obtain the target model.
[0012] A query processing method, comprising:
[0013] Receiving user queries for user search;
[0014] Determine similar queries to the user query using a target model, wherein the target model is obtained by:
[0015] Performing session segmentation on the historical query data to determine session segmentation data;
[0016] Filtering based on the session segmentation data to extract target queries;
[0017] Determine a similarity relationship between target queries, construct a training sample set according to the similarity relationship, and train a preset learning model based on the training sample set to obtain a target model;
[0018] The user query is rewritten according to the similar queries, so as to perform a search based on each of the similar queries, obtain search results corresponding to each of the similar queries and return them.
[0019] A method for training a query rewriting model, comprising:
[0020] Perform session segmentation based on historical query data to determine session segmentation data;
[0021] Performing vector embedding on the historical queries in the historical query data to determine a feature vector of the historical queries;
[0022] Filtering historical queries based on the session segmentation data to extract target queries;
[0023] Determine the similarity relationship between target queries based on the feature vectors of the target queries, and construct a training sample set in the form of triplet based on the similarity relationship between the target queries;
[0024] Based on the constructed training sample set, a metric learning method is applied to train the preset BERT pre-training model to obtain a target model.
[0025] An electronic device, comprising:
[0026] one or more processors; and
[0027] A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of any of the aforementioned methods.
[0028] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the methods described above.
[0029] According to the specific embodiments provided in this application, this application discloses the following technical effects:
[0030] Through the generation method of the query processing model provided by the present application, the historical query data can be segmented into sessions, and the session segmentation data can be determined; the target query can be extracted based on the session segmentation data; the similarity relationship between the target queries can be determined, and a training sample set can be constructed according to the similarity relationship; based on the constructed training sample set, the preset learning model can be trained to obtain the target model. Through this method, the session segmentation data is screened, and the high-quality and high-contribution target queries are extracted. Based on the high-quality and high-contribution target queries, the accuracy of the sample data can be improved, so that better model training can be achieved and the accuracy of the query expression used for recall can be improved. The method can also automatically construct a training sample set according to the similarity relationship between the target queries, and improve the construction efficiency of the training sample compared with the traditional method of manually labeling the learning samples. Further, the historical query data can be segmented from the semantic and time perspectives, which improves the accuracy of the segmentation, and the learning model training of the metric learning method improves the accuracy of the target model, and then more accurate query recall can be performed in query rewriting, and the introduction of multi-dimensional query vectors further makes the recall query richer and more accurate.
[0031] Of course, any product implementing the present application does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 It is a schematic diagram of the application of the method provided in the embodiment of the present application;
[0034] Figure 2 is a flow chart of the first method provided in an embodiment of the present application;
[0035] Figure 3 is a flow chart of the second method provided in an embodiment of the present application;
[0036] Figure 4 is a flowchart of the third method provided in an embodiment of the present application;
[0037] Figure 5 is a schematic diagram of a first device provided in an embodiment of the present application;
[0038] Figure 6 is a schematic diagram of a second device provided in an embodiment of the present application;
[0039] Figure 7 is a schematic diagram of a third device provided in an embodiment of the present application;
[0040] Figure 8 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention.
[0042] In the process of providing search services through search engines, the query input by the user can be received. The query input by the user represents the question he wants to retrieve, which is a keyword related to the specific question after summary and refinement. After a search is initiated, the search engine recalls documents according to the query input by the user and returns the search result page, which includes a list of documents related to the query. The user can choose to click on the document of interest to view. Through repeated search and click behaviors, a behavior sequence around the same search purpose will eventually be formed, which is called a session. Due to the existence of the semantic gap between the query and the document caused by various reasons, it is impossible to obtain sufficient and accurate valid documents according to the current query. According to the query, the user's search intention is understood, and an effective connection between the query and the document is established to solve the semantic gap problem. One of the technical means includes query rewriting. Query rewriting can determine a certain number of similar queries for the original input query based on the accumulated knowledge, and then use the similar queries and the original input query to search together to obtain a richer and more accurate document set. On the one hand, query rewriting can improve the richness of search results by expanding recall, and on the other hand, it can enable the search engine to better understand the user's search intention and improve the accuracy of search results relative to the search intention.
[0043] In the prior art, query rewriting methods include query expansion methods based on synonyms. Since they rely on artificial a priori synonym tables, they are prone to low or even no recall and cannot solve the language gap between queries and documents. Some query rewriting technologies based on algorithmic models also rely on manually labeled synonym samples, and their automation level is not high enough. In addition, since the borrowed usage method is relatively mechanical, the similar queries they output still lack accuracy, and the recalled queries are often mixed with queries that are not highly relevant to the topic or even irrelevant. In this way, the recall results often need further error correction processing to exclude queries with low relevance. Insufficient sample quality and mechanical training methods will cause inaccurate recall results, requiring additional error correction processing to avoid recalling documents with poor relevance based on queries with low relevance, thereby affecting search quality.
[0044] Embodiment 1
[0045] The first embodiment of the present application discloses a method for generating a query processing model, which can generate a target model for query rewriting. In the process of realizing model generation, it can reduce manual dependence, train the learning model through accurately constructed samples, improve the accuracy of query samples used for recall expressed through the learning model, improve the accuracy of query rewriting and the restoration of search intent, and thus lay a good foundation for more accurate and rich search results. Figure 1 , is a schematic diagram of the application of the method provided in Example 1 of the present application, such as Figure 1 As shown, the search engine may include a learning model, and the learning model may be trained based on the accumulated knowledge data. Different types of learning models may be used and the training methods thereof may also be different. After the training is completed, when the user uses the query term "query_a" to search, the learning model may rewrite the query based on the training results to obtain similar queries "query_b", "query_c" and "query_d" of "query_a", etc., and use the original input query and similar queries to search the document database, and documents related to the original query and similar queries may be obtained respectively, and the retrieved documents may be returned to the user as a document collection to meet the user's search needs. The following is a detailed description of the method for generating a query processing model provided in an embodiment of the present application.
[0046] like Figure 2 FIG. 1 is a flowchart of a method for generating a query processing model provided in Embodiment 1 of the present application. The method may include the following steps:
[0047] S210: performing session segmentation on the historical query data to determine session segmentation data;
[0048] The learning model can be trained using the accumulated knowledge data. In the first embodiment of the present application, the samples for training the learning model can come from historical query data. The historical query data can be obtained by legal collection. For example, the query received by the search engine can be recorded in the form of a query log, etc. The session segmentation data can be further determined based on the sequential sequence of the historical query data. For example, the sequential sequence of the historical query data in the historical query data shown in Table 1.
[0049] Table 1
[0050]
[0051] Each row represents a query that a user searches continuously. For example, a user in T i-1 Time, T i Time, T i+1 The query sequence used for time retrieval is:
[0052] {……, (aerosol observation network), (aeronet data, aerosol observation network), (http three-way handshake), …}.
[0053] For the convenience of processing, the query sequence can be segmented into sessions so that queries with the same or similar search intent can be grouped together as much as possible. For example, in the above example, after session segmentation, the query sequence can be segmented into two groups. i The query sequence is split at each time, and the resulting session segmentation data includes the following examples:
[0054] {…, (aerosol observation network), (aeronet data, aerosol observation network)};
[0055] {(http three-way handshake), …}.
[0056] In order to achieve accurate segmentation of session information, queries with the same or similar search intent are grouped as much as possible. One implementation method is to perform session segmentation based on time. The principle is that the retrieval for the same or similar search intent is usually in the same period. After searching for a suitable document, the retrieval is usually paused for a period of time or stopped. However, under this implementation method, the segmentation of historical query data will still segment some irrelevant queries into the same group, for example, breakfast and milk tea may be segmented together (in the example, when the correlation between query "milk tea" and query "breakfast" is considered to be low, but it still appears at a relatively close time point), resulting in a decrease in the similarity of samples, thereby affecting the training results and the recall of similar queries. In order to further improve the accuracy of similar query segmentation in session segmentation, in another implementation method, the historical query data can be segmented based on time and semantics to determine the session segmentation data, so as to obtain a more accurate and expected segmentation result. In specific implementation, the vector representation of the historical query can be calculated and determined based on a preset model or tool, that is, the historical query in the historical query data is vector embedded to determine the feature vector of the historical query. The feature vectors of historical queries can be used as vector representations of the semantics of each historical query. The semantic similarity between historical queries can be calculated and determined based on the feature vectors of historical queries. In this way, the historical query data can be semantically and temporally segmented according to the feature vectors of each historical query and the query time to determine the session segmentation data. The obtained session segmentation data satisfies both the temporal correlation and the semantic correlation. A session segmentation can more accurately reflect the user's search intent around a topic within a time period. Furthermore, in the obtained session segmentation data, the session segmentation containing a number of queries greater than a certain threshold can be used as valid session segmentation data to improve the sample validity of the session segmentation data.
[0057] S220: Screening based on the session segmentation data to extract a target query;
[0058] After determining the session segmentation data, the model can be trained based on the session segmentation data. In one implementation, in order to further improve the quality of the target model, the session segmentation data can be screened to improve the data quality. The session segmentation data can be further screened to extract the target query. The target query can be understood as a high-quality query or a high-quality query. The quality of the target query is reflected in that it can be a verified query, a verified query that can or is more likely to recall accurate documents, and from the expression level, it is more likely to be a query that can accurately describe the search requirements. As mentioned above, the semantic gap between the query and the document makes it difficult for the search engine to recall accurate documents. For example, if a query is "how far is the earth from the sun" and a document is "encyclopedia about astronomical units", then compared with "how far is the earth from the sun", searching with "what is an astronomical unit" or "astronomical unit AU" as a query is more likely to recall the document "encyclopedia about astronomical units". In the actual retrieval process, when the user uses the query "what is an astronomical unit" to search, it is more likely to obtain search results containing documents "encyclopedia about astronomical units", so that the user's search intention is satisfied. The user's search process may then be paused or ended by clicking on the document. It can be seen that for a query, being able to more accurately describe the problem it represents and correctly reflect the user's search intention, and on the other hand, being able to be more easily understood by the search engine and then recalling suitable documents through search, is a manifestation of high-quality or high-contribution queries. For session segmentation data, the queries therein can be filtered to extract target queries with high quality or contribution. Session segmentation data reflects the user's search intention around a topic within a period of time. Based on the above analysis, when filtering queries with high quality or high contribution, it can be based on the last query in the session segmentation data, that is, whether the last query corresponds to a click behavior, that is, whether the query brings clicks on the document. If so, the last query is determined to be a high-quality / contribution query, that is, the target query. For example, a session segmentation data is:
[0059] {…, (Astronomy Knowledge Network), (How far is the Earth from the Sun), (What is an astronomical unit)}
[0060] When a click occurs after the last query "What is an astronomical unit" in the session segmentation data is used, it can be determined that the query is the target query corresponding to the session segmentation data.
[0061] Historical query data may include click behavior information, such as a query behavior log that records the click behavior information corresponding to the query. When determining whether the last query in the session segmentation data corresponds to a click behavior, it can be determined based on the click behavior information included in the historical query data. For example, it can be determined based on the query behavior log whether the last query corresponds to a click behavior. If so, the last query is determined to be the target query.
[0062] For some existing learning model training, relatively original data samples or roughly processed samples are used. The trained learning model is not accurate when performing actual query rewriting, and the accuracy of query recall and document recall will be affected. Relying on manually labeled samples will consume a lot of manpower and have low efficiency. In the generation method of the query processing model provided in the embodiment of the present application, the session information is first accurately segmented based on parameters such as time and semantics; high-quality target queries are extracted from the session segmentation data, thereby improving the accuracy of the sample data from multiple aspects, so that better model training can be achieved and the accuracy of query expression used for recall can be improved (for example, the accuracy of vector expression of recall query), which is conducive to improving the accuracy of query rewriting. At the same time, the determined target query can be used for model training and can also be used for recall of similar queries, which improves the efficiency of using data mined from the original data.
[0063] Furthermore, for target queries with the same intent, their query expressions are often the same or similar. In order to obtain more effective target queries and reduce target queries with the same intent, the target queries can be deduplicated. One way to deduplicate target queries is to deduplicate target queries based on whether the click behaviors of the target queries correspond to the same target documents. If the click behaviors of two target queries correspond to the same document, it means that the search results obtained when using the two target queries contain the same document, and the user clicks on the same document. The target queries may have similar retrieval intents, so deduplication can be performed. For example, for the target queries in the following two session segmentation data:
[0064] {…,…,(astronomical distance)},
[0065] {…,…,(what is an astronomical unit)}
[0066] The click behaviors of the two queries "astronomical distance" and "what is an astronomical unit" correspond to the same document, such as the document "encyclopedia about astronomical units", which means that the same document was clicked when the two target queries were used for retrieval. The target queries may have similar retrieval intentions, so deduplication processing can be performed, such as removing "astronomical distance" and retaining the target query "what is an astronomical unit".
[0067] For target queries with the same intent, only one of them can be retained. For example, the one with a closer generation time can be retained based on the generation time. This method is simple and efficient based on whether the click behavior of the target query corresponds to the same target document. There are other methods for deduplicating target queries, such as comparing the semantic feature vectors between target queries. By deduplicating target queries, the data quality of the target query set can be further improved, thereby improving the quality of model training and reducing the recall of queries with the same meaning.
[0068] S230: Determine a similarity relationship between target queries, and construct a training sample set according to the similarity relationship;
[0069] Different from the previous supervised learning, which requires manual annotation and configuration of training samples, the method provided in the embodiment of the present application can automatically construct a training sample set, thereby improving the construction efficiency of training samples. When constructing a training sample set, the method provided in the embodiment of the present application can automatically construct a training sample set according to the similarity relationship of the target query. When determining the similarity relationship between target queries, the similarity relationship between target queries can be calculated according to the characteristic vector of the target query. Based on a preset model or tool, such as a model or tool such as Word2Vec, BERT, etc., the vector features of the query can be calculated and determined, and vector embedding is performed on each target query to determine the feature vector of the historical query. Of course, as in the aforementioned steps, feature vectors have been determined for all historical queries. Since the set of target queries is a subset of the historical query set, the feature vectors of each historical query are determined, and the feature vectors of each target query are naturally determined. After determining the feature vectors of each target query, the similarity relationship between the target queries can be calculated according to the feature vectors of each target query, and then the training sample set can be constructed.
[0070] In the process of training the learning model, the selection of negative samples often plays a very critical role in the training quality of the learning model. A better negative sample selection strategy can often better train the learning model, achieve better training results, and make the final model more accurate. In the method provided in the embodiment of the present application, when constructing a training sample set based on the similarity relationship between target queries, it can be done in the following way: for a target query, determine the similarity of other target queries with the target query, sort the other target queries according to the similarity with the target query, and determine the other target queries in the preset interval within the sorting as negative samples. The principle of determining negative samples is that after sorting other target queries according to their similarity to the target query, the queries at the head of the sort can be excluded, because the queries at the head of the sort include other target queries that are more similar to the target query; the tail of the sort is other target queries that have a lower similarity to the target query, and tend to no longer have the same retrieval intent as the target query; other target queries in a preset interval in the middle of the sort are selected as negative samples. These target queries tend not to have the same retrieval intent as the target query, but still have a higher expression similarity with the target query than the queries at the tail. Compared with using the tail queries as negative samples, and compared with using non-target queries in historical queries as negative samples, using some queries in other target queries in the preset interval in the middle of the sort as negative samples can enable the learning model to obtain more sufficient training and obtain more accurate training results. Based on a similar principle, in a preferred embodiment, the preset interval can be selected in the middle of the sort and close to the head. For example, assuming that the sort head is positioned as other target queries ranked 1-100, the preset interval can be defined as 100-200, that is, the target queries ranked 100-200 are used as negative samples.
[0071] When constructing a training sample set, a training sample set in the form of a triple can be constructed. In specific implementation, the target query can be used as an anchor, and the historical query in the same session segmentation data as the target query can be used as a positive sample positive, and the negative sample negative obtained above can be used to construct a triple of the anchor, the positive sample, and the negative sample. The triple is determined as a sample in the training sample set. The sample form can be expressed as:
[0072] triplet(anchor,positive,negative)
[0073] S240: Based on the constructed training sample set, training the preset learning model to obtain a target model;
[0074] Based on the training sample set constructed above, the preset learning model can be trained to obtain the target model. The preset learning model can be selected from a learning model suitable for the field, such as a BERT pre-trained model or other similar models or improved models. In order to further improve the accuracy of the learning model and make the target model more accurately express the target query, a metric learning method can be used in the process of training the learning model.
[0075] When rewriting a query, recalling similar queries only by the similarity of feature vectors will cause false recalls. The insufficient distance between different categories in sample representation is a major cause of false query recalls. Therefore, this situation can be avoided by increasing the distance between different categories and reducing the distance between the same categories. When training a pre-set learning model, a metric learning method can be introduced to improve the accuracy of the target model. Based on the constructed training sample set, a metric learning method can be applied to train the pre-set learning model so that the learning model can better learn the differences between samples, so that the distance between the anchor and the positive sample in the target model is reduced, while the distance between the anchor and the negative sample is increased. In the result, samples of the same type can be better clustered together, and the distance between samples of different types is increased, so that the accuracy of the obtained model is better and the model is more reliable. For example, taking the method of using the BERT pre-trained model and combining it with tripletloss for fine-tuning as an example, semi-hard triplets are selected for training so that the distance between each object in the triplet satisfies:
[0076] L <margin;
[0077] That is, d(a,p) <d(a,n)<d(a,p)+margin
[0078] That is, the distance between anchor a and positive sample p is closer than the distance between anchor a and negative sample n, and meets the margin requirement, where margin is an adjustable parameter. The loss function of this method is:
[0079]
[0080] Of course, in practical applications, other metric learning loss methods can also be used instead of triplet loss.
[0081] When using the BERT pre-trained model as a learning model, the target model is a retrained model whose parameters can change as the training task progresses. Compared with a model that uses a static vocabulary and is put into use after only one training, this target model has higher accuracy and can obtain more accurate expression results for the target query. After obtaining the target model, the target model can be used to recalculate the feature vectors of each target query, that is, after obtaining the target model, the feature vectors of each target query can be determined based on the target model, and similar queries can be recalled for the query entered by the user based on the re-determined feature vectors of the target query.
[0082] After obtaining the target model and determining the feature vector of each target query as a recall vector based on the target model, the target model can be used to determine similar queries of the user query after receiving the user query to rewrite the user query. When recalling similar queries, the trained target model can be used to determine the feature vector of the user query, and similarity calculation can be performed in the feature vector of the previously re-determined target query based on the determined feature vector of the user query to determine similar queries of the user query. In practical applications, the feature vector representation of the target query often has a large amount of data. In order to speed up the search, after determining the feature vector of each target query based on the target model, a similarity index of the target query can be established based on the feature vector of each target query. When rewriting the user query, the feature vector of the user query can be determined, and the similarity index can be queried based on the feature vector of the user query, and similar queries of the user query can be determined in the target query, and the user query can be rewritten based on the obtained similar queries.
[0083] In order to reduce the occurrence of small or even no recall, in addition to using the re-determined feature vector of the target query, other feature vectors can also be introduced to establish a similarity index of the target query together with the feature vector of the target query. The other vectors introduced can include: a feature vector of the letter spelling of the target query, which can be used for recall when the letter spelling or spelling error is entered; a click behavior feature vector of the target query, which is a feature vector generated based on the click documents and the number of clicks in a continuous time slice, and can be used for recall of similar queries; a feature vector of the target document corresponding to the click behavior of the target query, which can add the feature vector of the click document corresponding to the target query to the semantic vector of the target query to avoid the problem of difficulty in recall due to too few words contained in the user query.
[0084] In addition, in order to further avoid generating invalid queries when similar queries are recalled, and to avoid recalling high-similarity queries of the same purpose, after determining similar queries to the user's query, similarity judgment can be performed on similar queries, and similar queries with similarities less than a first preset threshold can be removed, and similar queries with similarities greater than a second preset threshold can be removed.
[0085] The above is a detailed introduction to the method for generating the query processing model provided in the first embodiment of the present application. The method can determine the historical query data, perform session segmentation on the historical query data, determine the session segmentation data; perform screening based on the session segmentation data to extract the target query; determine the similarity relationship between the target queries, and construct a training sample set based on the similarity relationship; based on the constructed training sample set, train the preset learning model to obtain the target model. Through this method, the session segmentation data is screened, and the high-quality and high-contribution target queries therein are extracted. Based on the high-quality and high-contribution target queries, the accuracy of the sample data can be improved, so that better model training can be achieved and the accuracy of the query expression used for recall can be improved; the relevance of the similar queries recalled with the user query during query rewriting is improved, and search results that are more in line with the search intent are returned, thereby improving and enhancing the quality of the search results. The method can also automatically construct a training sample set based on the similarity relationship between the target queries, which improves the construction efficiency of the training samples compared to the traditional method of manually annotating the learning samples. Furthermore, historical query data can be segmented from a semantic and temporal perspective, which improves the accuracy of segmentation. The introduction of metric learning methods for learning model training improves the accuracy of the target model, which in turn allows for more accurate query recall in query rewriting. The use of multi-dimensional query vectors can further make recall queries richer and more accurate.
[0086] Embodiment 2
[0087] Embodiment 2 of the present application discloses a method for processing a query, such as Figure 3 As shown, the method may include the following steps:
[0088] S310: receiving a user query used by a user for search;
[0089] First, a user query used by a user for search may be received. The user query may be text content such as query terms provided by the user to the search engine using a web page, an app, etc. The search engine may receive the user query through a server, etc.
[0090] S320: using the target model to determine similar queries to the user query; wherein the target model is obtained by: performing session segmentation on the historical query data to determine session segmentation data; performing screening based on the session segmentation data to extract the target query; determining the similarity relationship between the target queries, constructing a training sample set based on the similarity relationship, and training a preset learning model based on the training sample set to obtain the target model;
[0091] After receiving a user query, the target model can be used to determine similar queries to the user query. The training and generation method of the target model can refer to the content provided in Example 1 of the present application, and will not be repeated here.
[0092] S330: rewrite the user query according to the similar query, so as to retrieve based on each of the similar queries, obtain the search results corresponding to each of the similar queries and return them. After obtaining the target model, the feature vector of the recall query can be determined based on the target model. After receiving the user query, the feature vector of the user query can be determined using the obtained target model, and then the similar query of the user query can be determined based on the feature vector of the user query, and the user query can be rewritten based on the obtained similar query. In practical applications, the feature vector representation of the target query often has a large amount of data. In order to speed up the search, after determining the feature vector of each target query based on the target model, the similarity index of the target query can be established based on the feature vector of each target query. When rewriting the user query, the feature vector of the user query can be determined, and the similarity index can be queried based on the feature vector of the user query. The similar query of the user query is determined in the target query, and the user query is rewritten based on the obtained similar query. The target model can be used to determine the feature vector of the recall query and the feature vector of the user query to improve the accuracy of the recall of similar queries.
[0093] The query processing method provided in the second embodiment of the present application is introduced in detail above. The method can receive the user query used by the user search, and use the target model to determine the similar query of the user query; wherein, the target model is obtained by the generation method of the query processing model provided in the first embodiment of the present application; and then the user query can be rewritten according to the similar query, so as to retrieve based on each similar query, obtain the corresponding search results of each similar query and return them. Through this method, the session segmentation data is screened, the target query is extracted, and higher quality sample data is obtained based on the target query, so as to achieve better model training and improve the accuracy of query expression used for recall, so as to obtain similar queries of the user query that are more in line with the search intent, so that the recall of similar queries is richer and more accurate, thereby providing a guarantee for providing more accurate and high-quality search results.
[0094] Embodiment 3
[0095] Embodiment 3 of the present application discloses a method for training a query rewriting model, such as Figure 4 As shown, the method may include the following steps:
[0096] S410: Performing session segmentation based on historical query data to determine session segmentation data;
[0097] S420: performing vector embedding on the historical query in the historical query data to determine a feature vector of the historical query;
[0098] S430: Filtering historical queries based on the session segmentation data to extract target queries;
[0099] S440: determining the similarity relationship between target queries according to the feature vectors of the target queries, and constructing a training sample set in the form of triplet according to the similarity relationship between the target queries;
[0100] S450: Based on the constructed training sample set, apply the metric learning method to train the preset BERT pre-training model to obtain the target model.
[0101] After obtaining the target model, the feature vector of each target query can be determined based on the target model, and the similarity index of the target query can be established based on the feature vector of each target query; the established similarity index can be used to determine similar queries of the user query during the query rewriting process.
[0102] The method for training the query rewriting model provided in the third embodiment of the present application is introduced above. The method can perform session segmentation based on historical query data to determine session segmentation data; perform vector embedding on historical queries in historical query data to determine the feature vector of historical queries; screen historical queries based on session segmentation data to extract target queries; determine the similarity relationship between target queries according to the feature vector of target queries, and construct a training sample set in the form of Triplet triples according to the similarity relationship between target queries; based on the constructed training sample set, apply the metric learning method to train the preset BERT pre-training model to obtain the target model. Through this method, the session segmentation data is screened, and high-quality and high-contribution target queries are extracted. Based on the screened target queries, the accuracy of the sample data can be improved, so that better model training can be achieved and the accuracy of query expression used for recall can be improved, and the quality of similar queries recalled during query rewriting can be improved. The method can also automatically construct a training sample set based on the similarity relationship between target queries, which improves the construction efficiency of training samples compared to the traditional method of manual labeling of learning samples. The model training method is used to improve the accuracy of the target model, thereby achieving more accurate recall of similar queries in query rewriting.
[0103] Corresponding to the method for generating a query processing model provided in the first embodiment of the present application, a device for generating a query processing model is also provided, such as Figure 5 As shown, the device may include:
[0104] The session processing unit 510 is used to perform session segmentation on the historical query data and determine the session segmentation data;
[0105] A high-quality query extraction unit 520, configured to perform screening based on the session segmentation data to extract a target query;
[0106] A sample set construction unit 530 is used to determine the similarity relationship between target queries and construct a training sample set according to the similarity relationship;
[0107] The model training unit 540 is used to train the preset learning model based on the constructed training sample set to obtain a target model.
[0108] In one implementation, the device may further include:
[0109] The vector embedding unit is used to embed the historical queries in the historical query data into vectors and determine the feature vectors of each historical query.
[0110] In one implementation, the historical query data may include the query time corresponding to each historical query, and the session processing unit 510 may be specifically used to:
[0111] According to the feature vectors of each historical query and the query time, the historical query data is semantically and temporally segmented to determine the session segmentation data.
[0112] In one implementation, the historical query data may include click behavior information, and the high-quality query extraction unit 520 may be specifically used to:
[0113] According to the click behavior information, it is determined whether the last query in the session segmentation data corresponds to a click behavior, and if so, the last query is determined to be the target query.
[0114] In this implementation, the device may further include:
[0115] The target query deduplication unit is used to deduplicate the target query according to whether the click behavior of the target query corresponds to the same target document.
[0116] In one implementation, the sample set construction unit 530 may be specifically configured to:
[0117] Calculate the similarity relationship between target queries based on the feature vectors of the target queries;
[0118] For a target query, determine the similarity between other target queries and the target query, sort the other target queries according to the similarity with the target query, and determine other target queries in a preset interval within the sorting as negative samples;
[0119] Taking the target query as an anchor and the historical queries in the same session segmentation data as the target query as positive samples, a triple of the anchor, the positive sample and the negative sample is constructed, and the triple is determined as a sample in the training sample set.
[0120] In this implementation, the model training unit 540 can be specifically used to:
[0121] Based on the constructed training sample set, a metric learning method is applied to perform training so as to reduce the distance between positive samples in the target model and increase the distance with negative samples.
[0122] In a preferred implementation, the device may further include:
[0123] The similarity index establishing unit is used to determine the feature vector of each target query based on the target model after obtaining the target model, and establish the similarity index of the target query based on the feature vector of each target query.
[0124] In this implementation, the device may further include:
[0125] The similar query determination unit is used to determine a feature vector of the user query after receiving the user query, query the similarity index according to the feature vector of the user query, and determine similar queries of the user query in the target query.
[0126] Including the feature vector of the target query, the similarity index building unit can also build the similarity index of the target query based on one or any of the following feature vectors:
[0127] feature vector of the alphabetic spelling of the target query;
[0128] Click behavior feature vector of target query;
[0129] The feature vector of the target document corresponding to the click behavior of the target query.
[0130] Corresponding to the query processing method provided in the second embodiment of the present application, a query processing device is also provided, such as Figure 6 As shown, the device may include:
[0131] A query receiving unit 610, configured to receive a user query used by a user for search;
[0132] A similarity query calculation unit 620 is used to determine similar queries of the user query using a target model, wherein the target model is obtained by: performing session segmentation on the historical query data to determine session segmentation data; performing screening based on the session segmentation data to extract the target query; determining a similarity relationship between the target queries, constructing a training sample set based on the similarity relationship, and training a preset learning model based on the training sample set to obtain the target model;
[0133] And, the search execution unit 630 is used to rewrite the user query according to similar queries, so as to perform search based on each similar query, obtain search results corresponding to each similar query and return them.
[0134] Corresponding to the method for training a query rewriting model provided in the third embodiment of the present application, a device for training a query rewriting model is also provided, such as Figure 7 As shown, the device may include:
[0135] A session segmentation unit 710, configured to perform session segmentation based on historical query data and determine session segmentation data;
[0136] A feature representation unit 720, configured to perform vector embedding on the historical query in the historical query data to determine a feature vector of the historical query;
[0137] A query screening unit 730, configured to screen historical queries based on the session segmentation data to extract a target query;
[0138] A training set construction unit 740 is used to determine the similarity relationship between target queries according to the feature vectors of the target queries, and to construct a training sample set in the form of triplet according to the similarity relationship between the target queries;
[0139] And, the model learning unit 750 is used to apply a metric learning method based on the constructed training sample set to train the preset BERT pre-training model to obtain a target model.
[0140] In addition, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods in the aforementioned method embodiments are implemented.
[0141] And an electronic device, comprising:
[0142] one or more processors; and
[0143] A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of the method described in any one of the aforementioned method embodiments.
[0144] in, Figure 8 The architecture of an electronic device is exemplarily shown. For example, device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, an aircraft, etc.
[0145] Reference Figure 8 , device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 818 .
[0146] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete the video playback method provided by the technical solution of the present disclosure, when the preset conditions are met, a traffic compression request is generated and sent to the server, wherein the traffic compression request records information for triggering the server to obtain the target focus area, and the traffic compression request is used to request the server to prioritize the bit rate of the video content in the target focus area; according to the bit stream file returned by the server, the video content corresponding to the bit stream file is played, wherein the bit stream file is the whole or part of the steps of the video file obtained by the server performing bit rate compression processing on the video content outside the target focus area according to the traffic compression request. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0147] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0148] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0149] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0150] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 818. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0151] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0152] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0153] The communication component 818 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 818 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 818 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0154] In an exemplary embodiment, the device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0155] In an exemplary embodiment, a non-temporary computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the above instructions can be executed by the processor 820 of the device 800 to complete the video playback method provided by the technical solution of the present disclosure, when the preset conditions are met, a traffic compression request is generated and sent to the server, wherein the traffic compression request records information for triggering the server to obtain the target focus area, and the traffic compression request is used to request the server to give priority to guaranteeing the bit rate of the video content in the target focus area; according to the bit stream file returned by the server, the video content corresponding to the bit stream file is played, wherein the bit stream file is a video file obtained by the server performing bit rate compression processing on the video content outside the target focus area according to the traffic compression request. For example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a tape, a floppy disk, an optical data storage device, etc.
[0156] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0157] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0158] Subject to the requirements of applicable laws and regulations of the country where you are located (for example, explicit consent from the user, effective notification to the user, etc.), user-specific personal data may be used in the scenarios described herein to the extent permitted by applicable laws and regulations.
[0159] The above is a detailed introduction to the query processing model generation method, device and electronic device provided by the present application. The principles and implementation methods of the present application are described in detail using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A method for generating a query processing model, characterized in that: include: Perform session segmentation on historical query data and determine session segmentation data to group queries with the same or similar search intent; Filtering based on the session segmentation data to extract target queries, wherein the target queries include verified queries that are capable of or more likely to recall accurate documents; Determine the similarity relationship between target queries, and construct a training sample set according to the similarity relationship; wherein, for a target query, determine the similarity between other target queries and the target query, sort the other target queries according to the similarity with the target query, and determine the other target queries in a preset interval within the sorting as negative samples; take the target query as an anchor, take the historical queries in the same session segmentation data as the target query as positive samples, construct a triple of the anchor, the positive sample and the negative sample, and determine the triple as a sample in the training sample set; Based on the constructed training sample set, the preset learning model is trained to obtain the target model.
2. The method according to claim 1, characterized in that Also includes: Vector embedding is performed on the historical queries in the historical query data to determine feature vectors of the historical queries.
3. The method according to claim 2, characterized in that The historical query data includes query time corresponding to each historical query, and the historical query data is segmented into sessions to determine the session segmentation data, including: According to the feature vector of each historical query and the query time, the historical query data is semantically and temporally segmented to determine the session segmentation data.
4. The method according to claim 1, characterized in that The historical query data includes click behavior information, and the filtering based on the session segmentation data to extract the target query includes: According to the click behavior information, it is determined whether the last query in the session segmentation data corresponds to a click behavior, and if so, the last query is determined to be the target query.
5. The method according to claim 4, characterized in that Also includes: Deduplication of the target query is performed according to whether the click behaviors of the target query correspond to the same target document.
6. The method according to claim 2, characterized in that The determining the similarity relationship between target queries and constructing a training sample set according to the similarity relationship includes: The similarity relationship between target queries is calculated according to the characteristic vectors of the target queries, and a training sample set is constructed according to the similarity relationship.
7. The method according to claim 1, characterized in that The step of training a preset learning model based on the constructed training sample set to obtain a target model includes: Based on the constructed training sample set, a metric learning method is applied to perform training so as to reduce the distance between positive samples in the target model and increase the distance with negative samples.
8. The method according to any one of claims 1 to 7, characterized in that: Also includes: After the target model is obtained, a feature vector of each target query is determined based on the target model, and a similarity index of the target query is established based on the feature vector of each target query.
9. The method according to claim 8, characterized in that Also includes: After receiving a user query, a feature vector of the user query is determined, and based on the feature vector of the user query, the similarity index is queried to determine similar queries to the user query in the target query.
10. The method according to claim 8, characterized in that A similarity index for the target query is also established based on one or any of the following feature vectors: feature vector of the alphabetic spelling of the target query; Click behavior feature vector of target query; The feature vector of the target document corresponding to the click behavior of the target query.
11. A method for processing a query, characterized in that: include: Receiving user queries for user search; Determine similar queries to the user query using a target model, wherein the target model is obtained by: Performing session segmentation on the historical query data to determine session segmentation data to group queries with the same or similar search intent; Filtering based on the session segmentation data to extract target queries, wherein the target queries include verified queries that are capable of or more likely to recall accurate documents; Determine the similarity relationship between target queries, construct a training sample set based on the similarity relationship, and train a preset learning model based on the training sample set to obtain a target model; wherein, for a target query, determine the similarity between other target queries and the target query, sort the other target queries according to the similarity with the target query, and determine other target queries in a preset interval within the sorting as negative samples; take the target query as an anchor, take the historical queries in the same session segmentation data as the target query as positive samples, construct a triple of the anchor, the positive sample and the negative sample, and determine the triple as a sample in the training sample set; The user query is rewritten according to the similar queries, so as to perform a search based on each of the similar queries, obtain search results corresponding to each of the similar queries and return them.
12. A method for training a query rewriting model, characterized in that: include: Performing session segmentation based on historical query data, determining session segmentation data to group queries with the same or similar search intent; Performing vector embedding on the historical queries in the historical query data to determine the feature vectors of the historical queries; Screening historical queries based on the session segmentation data to extract target queries, wherein the target queries include queries that are verified to be able to or more likely to recall accurate documents; Determine the similarity relationship between target queries based on the feature vectors of the target queries, and construct a training sample set in the form of triplet triples based on the similarity relationship between the target queries; wherein, for a target query, determine the similarity between other target queries and the target query, sort the other target queries according to the similarity with the target query, and determine the other target queries in a preset interval within the sorting as negative samples; take the target query as an anchor, take the historical queries in the same session segmentation data as the target query as positive samples, construct a triplet of the anchor, the positive sample and the negative sample, and determine the triplet as a sample in the training sample set; Based on the constructed training sample set, a metric learning method is applied to train the preset BERT pre-training model to obtain a target model.
13. An electronic device, characterized in that: include: one or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of the method according to any one of claims 1 to 12.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Method and device for establishing query rewriting judgement modules and query rewriting judgement method and device
CN107491447A
Disease pattern mining method and device based on word vector model
CN109360658A