A query statement processing method, a training model method, a device and equipment
A pre-trained binary classification model addresses inaccuracies in query statement rewriting by using historical data, providing accurate and efficient query statement processing.
Patent Information
- Application Number
- CN201910873941.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-17
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2040-10-31
AI Technical Summary
Existing query rewriting methods struggle with inaccurate determination of whether a user's query statement needs to be rewritten, often leading to over-rewriting or unnecessary rewriting due to reliance on large statistical dictionaries and complex language models.
A pre-trained binary classification model is used to determine whether a query statement needs to be rewritten, based on historical rewriting records and click logs, eliminating the need for large dictionaries and improving prediction performance.
The binary classification model accurately determines query statement rewriting needs, reducing computational overhead and enhancing prediction accuracy by leveraging historical data without requiring extensive feature accumulation.
Smart Images

Figure CN111831685B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of retrieval technology, and in particular to a method for processing query statements, a method, device and equipment for training models. Background Art
[0002] During the retrieval process, the query statement Query entered by the user is used to search the database for the target document corresponding to the query statement. If the query statement entered by the user is inconsistent with the target document expression in the database, the query statement needs to be rewritten. For example, if the query statement entered by the user is wrong, the query statement entered by the user needs to be rewritten to provide a query result that meets the user's needs.
[0003] However, in the above-mentioned query rewriting process, it may happen that the query statement input by the user does not need to be rewritten, but is actually rewritten, or the query statement may be over-rewritten. Therefore, the existing method at least has the problem of poor accuracy in determining whether the query statement input by the user is rewritten. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a query statement processing method, a model training method, an apparatus and a device, which can accurately determine whether the query statement input by the user is rewritten.
[0005] The technical solution of this application is implemented as follows:
[0006] According to one aspect of the present application, a method for processing a query statement is provided, the processing method comprising: obtaining a query statement input by a user; determining whether the input query statement needs to be rewritten through a pre-trained binary classification model, wherein the pre-trained binary classification model is obtained based on historical rewriting records, and the historical rewriting records include multiple historical query statements and rewriting identification information of each historical query statement.
[0007] In the above implementation process, the embodiment of the present application determines whether the query statement input by the user needs to be rewritten through a pre-trained binary classification model, and the binary classification model is obtained based on historical rewriting records including multiple historical query statements and rewriting identification information of each historical query statement, so that the trained binary classification model can accurately determine whether the query statement input by the user needs to be rewritten.
[0008] Optionally, the processing method further includes: obtaining historical rewriting records; and using the historical rewriting records as samples for training to obtain a pre-trained binary classification model.
[0009] In the above implementation process, the embodiment of the present application pre-trains a binary classification model, so that it can directly determine whether the query statement input by the user is rewritten, without having to establish a new model before each process of determining whether the query statement input by the user is rewritten.
[0010] Optionally, obtaining the historical rewriting record includes: obtaining a user's click log, wherein the click log records a plurality of historical query statements and a clicked search result corresponding to each historical query statement; and obtaining rewriting identification information of each historical query statement according to the clicked search result.
[0011] In the above implementation process, the embodiment of the present application determines the rewrite identification information by accurately recording the historical query statements of multiple users and the click log of the clicked search results corresponding to each historical query statement, so that the rewrite identification information can be determined quickly and accurately.
[0012] Optionally, historical rewriting records are used as samples for training to obtain a pre-trained binary classification model, including: inputting historical query statements in the historical rewriting records into the established binary classification model to obtain initial rewriting results; adjusting parameters in the established binary classification model according to the difference between the initial rewriting results and the rewriting identification information to obtain a pre-trained binary classification model.
[0013] In the above implementation process, the embodiment of the present application uses historical query statements as input to train the established binary classification model, so as to accurately predict whether the query statements input by subsequent users need to be rewritten through historical query statements, so as to avoid problems caused by the model trained by using search results as input.
[0014] Optionally, the pre-trained binary classification model is a text classifier.
[0015] In the above implementation process, the embodiment of the present application can quickly determine whether the query statement input by the user needs to be rewritten through the text classifier.
[0016] According to another aspect of the present application, a method for training a model is provided, the method comprising: obtaining historical rewriting records, wherein the historical rewriting records include multiple historical query statements and rewriting identification information of each historical query statement; using the historical rewriting records as samples for training to obtain a trained binary classification model, wherein the trained binary classification model is used to determine whether a query statement input by a user needs to be rewritten.
[0017] Optionally, obtaining the historical rewriting record includes: obtaining a user's click log, wherein the click log records a plurality of historical query statements and a clicked search result corresponding to each historical query statement; and obtaining rewriting identification information of each historical query statement according to the clicked search result.
[0018] Optionally, the historical rewriting records are used as samples for training to obtain a trained binary classification model, including: inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; adjusting the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain the trained binary classification model.
[0019] Optionally, the trained binary classification model is a text classifier.
[0020] According to another aspect of the present application, a query statement processing device is provided, which includes: a first acquisition module, used to obtain a query statement input by a user; a determination module, used to determine whether the input query statement needs to be rewritten through a pre-trained binary classification model, wherein the pre-trained binary classification model is obtained based on historical rewriting records, and the historical rewriting records include multiple historical query statements and rewriting identification information of each historical query statement.
[0021] Optionally, the processing device further includes: a second acquisition module, used to acquire the historical rewriting records; and a training module, used to train the historical rewriting records as samples to obtain a pre-trained binary classification model.
[0022] Optionally, the second acquisition module includes: a first acquisition sub-module, used to obtain the user's click log, wherein the click log records multiple historical query statements and the clicked search results corresponding to each historical query statement; a second acquisition sub-module, used to obtain the rewrite identification information of each historical query statement based on the clicked search results.
[0023] Optionally, the training module includes: an input module, used to input historical query statements in historical rewriting records into the established binary classification model to obtain initial rewriting results; an adjustment module, used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting results and the rewriting identification information to obtain a pre-trained binary classification model.
[0024] Optionally, the pre-trained binary classification model is a text classifier.
[0025] According to another aspect of the present application, a device for training a model is provided, the device comprising: an acquisition module for acquiring historical rewriting records, wherein the historical rewriting records include multiple historical query statements and rewriting identification information of each historical query statement; a training module for training the historical rewriting records as samples to obtain a trained binary classification model, wherein the trained binary classification model is used to determine whether a query statement input by a user needs to be rewritten.
[0026] Optionally, the acquisition module includes: a first acquisition sub-module, used to acquire the user's click log, wherein the click log records multiple historical query statements and the clicked search results corresponding to each historical query statement; a second acquisition sub-module, used to acquire the rewrite identification information of each historical query statement based on the clicked search results.
[0027] Optionally, the training module includes: an input module, used to input historical query statements in historical rewriting records into the established binary classification model to obtain initial rewriting results; an adjustment module, used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting results and the rewriting identification information to obtain a trained binary classification model.
[0028] Optionally, the trained binary classification model is a text classifier.
[0029] According to another aspect of the present application, an electronic device is provided, which may include a storage medium and a processor communicating with the storage medium. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via a bus, and the processor executes the machine-readable instructions to execute the steps of the query statement processing method.
[0030] According to another aspect of the present application, a computer medium is provided, on which a computer program is stored. When the computer program is run by a processor, the method described in any optional implementation of the method for processing a query statement is executed.
[0031] According to another aspect of the present application, an electronic device is provided, which may include a storage medium and a processor communicating with the storage medium. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via a bus, and the processor executes the machine-readable instructions to perform the steps of the method for training a model.
[0032] According to another aspect of the present application, a computer medium is provided, on which a computer program is stored, and the computer program is executed by a processor to perform the steps of the method for training a model. The method described in any optional implementation manner.
[0033] In order to make the above-mentioned objectives, features and advantages to be achieved by the embodiments of the present application more obvious and understandable, the following specifically cites preferred embodiments and describes them in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application 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 paying creative work.
[0035] Figure 1 A schematic diagram showing an architecture of exemplary hardware and software components of an electronic device provided in an embodiment of the present application;
[0036] Figure 2 A flowchart of a method for processing a query statement provided in an embodiment of the present application is shown;
[0037] Figure 3 A flowchart of a query statement retrieval method provided in an embodiment of the present application is shown;
[0038] Figure 4 A flow chart of a method for training a model provided in an embodiment of the present application is shown;
[0039] Figure 5 A schematic diagram of the structure of a query statement processing device provided in an embodiment of the present application is shown;
[0040] Figure 6 A schematic diagram of the structure of a device for training a model provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0041] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0042] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0043] In order to enable those skilled in the art to use the content of this application, the following implementation is provided in conjunction with a specific application scenario "retrieval system". For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is mainly described around the retrieval system, it should be understood that this is only an exemplary embodiment.
[0044] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0045] At present, in the process of information retrieval, the user inputs a query statement, and the background searches the database for the target document corresponding to the query statement through the query statement. Among them, different systems correspond to different databases. For example, when the system is a map information system, the database is a POI (Point of Interest) library, which records the information of points of interest in a preset area. The user enters a query statement to search the destination the user wants to go to in the point of interest library, and the destination is the point of interest. Among them, a point of interest can be a house, a shop, a mailbox, a bus stop, a shopping mall, a company, a tourist attraction, etc., and each point of interest can include information such as address, name, longitude and latitude. In other words, points of interest refer to the most core data based on location services, which are widely used in electronic maps.
[0046] In addition, when the target document in the database and the query statement input by the user are not expressed in the same way, the query statement input by the user needs to be rewritten. The rewriting of the query statement includes: when the query statement input by the user is wrong, the query statement input by the user needs to be rewritten into a pair.
[0047] For example, when the query sentence input by the user is "KFC", the query sentence input by the user is modified into "KFC" through the error correction rewriting model.
[0048] The rewriting of the query statement also includes: when the query statement input by the user is synonymous, the query statement input by the user needs to be rewritten into a corresponding synonymous word.
[0049] For example, when the query sentence input by the user is "BJ Beijing", since "BJ" is the abbreviation of "Beijing", it actually represents the same meaning, so the query sentence input by the user is modified to "Beijing" through the synonym rewriting model.
[0050] The rewriting of the query statement also includes: when the query statement input by the user is long, it is necessary to omit some words in the query statement input by the user.
[0051] For example, when the query sentence input by the user is "destination Chengdu", the query sentence input by the user is modified to "Chengdu" by omitting the rewriting model.
[0052] In addition, in addition to the above three types of query statement rewriting, query statement rewriting also includes other types of rewriting, which are not listed here one by one.
[0053] The existing method generally calculates the score of whether the query statement input by the user needs to be rewritten based on the language model of the interest point corpus statistics, and finally determines whether to rewrite the query statement input by the user based on the final score.
[0054] For example, if a query sentence input by a user is "Beijing West Railway Station", it is necessary to split "Beijing West Railway Station" into two words, "Beijing" and "West Railway Station", and then query the probability of "Beijing" and the probability of "West Railway Station" under the condition of "Beijing". In addition, it is also necessary to calculate the probability of "Beijing" appearing in this training corpus through a training corpus in the interest point corpus in an offline environment, and to count the probability of "West Railway Station" under the condition of "Beijing" through this training corpus, where a training corpus may include multiple data. Then, when applied online, the probability of "Beijing" and the probability of "West Railway Station" under the condition of "Beijing" are determined through the offline training corpus, and then multiplied to finally determine the rewriting score of "Beijing West Railway Station", so as to determine whether to rewrite it through the final score. In other words, the offline training corpus can be regarded as a dictionary file, which records the probability of each word and the probability of each word under the condition of related words. In the process of determining whether the query statement input by the user needs to be rewritten, the probability of the words in the required query statement is taken out through the dictionary file, and then multiplied to finally determine the score of whether the query statement input by the user needs to be rewritten, and the score is used to determine whether the query statement needs to be rewritten.
[0055] However, the above existing solutions have at least the following defects: 1. In order to meet the needs of use, a large number of statistics are required for the probability of each word and the conditional probability of each word between at least two words, so the statistical dictionary file is very large, and then the performance is very poor and time-consuming when used online; 2. The above dictionary file is established based on the target document, but the expression of the target document and the query statement are different, which makes the dictionary file cause some problems during use, such as the threshold value of the score for whether the query statement is rewritten is difficult to determine; 3. In the process of using the dictionary file to determine the score of whether the query statement is rewritten, in addition to knowing the query statement, it is also necessary to understand some characteristics of the query statement, such as whether the query statement is in Chinese or English, how many words the query statement contains, etc., which makes the above determination process also cumbersome.
[0056] Therefore, the embodiment of the present application determines whether the query statement input by the user needs to be rewritten through a pre-trained binary classification model. Compared with the existing solution of determining whether the query statement needs to be rewritten through traditional dictionary files, the solution of the present application can not only eliminate large-scale dictionary files, but also greatly improve the prediction performance. The finally trained binary classification model can reflect the characteristics of whether the query statement can be rewritten or not. Therefore, the clever use of a binary classification model can not only reflect the characteristics of the existing language model, but also obtain a binary classification function of whether the query statement needs to be rewritten. At the same time, it does not need to accumulate many features of the query statement, and can quickly determine whether the query statement input by the user needs to be rewritten.
[0057] Please refer to Figure 1 , Figure 1 A schematic diagram of exemplary hardware and software components of an electronic device 100 provided in an embodiment of the present application. For example, a processor 120 can be used on the electronic device 100 and used to perform the functions in the present application. Exemplarily, the above-mentioned processor 120 can be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the embodiments of the present application are not limited thereto.
[0058] The electronic device 100 may refer to a user terminal, or a server, or may also be a general-purpose computer or a special-purpose computer, which may be used to implement the query statement processing method or model building method of the present application. Although only one computer is shown in the present application, for convenience, the functions described in the present application may be implemented in a distributed manner on multiple similar platforms to balance the processing load.
[0059] For example, the electronic device 100 may include a network port 110 connected to a network, one or more processors 120 for executing program instructions, a communication bus 130, and storage media 140 in different forms, such as a disk, ROM, or RAM, or any combination thereof. Exemplarily, the computer platform may also include program instructions stored in ROM, RAM, or other types of non-temporary storage media, or any combination thereof. The method of the present application may be implemented according to these program instructions. The electronic device 100 also includes an input / output (I / O) interface 150 between the computer and other input / output devices (e.g., a keyboard, a display screen).
[0060] For ease of explanation, only one processor is described in the electronic device 100. However, it should be noted that the electronic device 100 in the present application may also include multiple processors, so the steps performed by one processor described in the present application may also be performed jointly or individually by multiple processors. For example, if the processor of the electronic device 100 performs step A and step B, it should be understood that step A and step B may also be performed jointly by two different processors or individually in one processor. For example, the first processor performs step A, the second processor performs step B, or the first processor and the second processor perform steps A and B together.
[0061] Furthermore, it should be understood that Figure 1 The electronic device 100 shown can be an electronic device for executing a method for processing query statements, an electronic device for executing a method for training models, or an electronic device for executing a method for processing query statements and a method for training models. The embodiments of the present application are not limited to this.
[0062] Please refer to Figure 2 , Figure 2 A flowchart of a method for processing a query statement provided in an embodiment of the present application is provided. The method is executed by the electronic device 100 described above, and the method includes the following steps:
[0063] Step S210: Obtain a historical rewrite record, wherein the historical rewrite record includes a plurality of historical query statements and rewrite identification information of each historical query statement.
[0064] It should be understood that the above-mentioned historical rewriting records can be obtained by collecting the user's click logs, or by direct input from the user, and the embodiments of the present application are not limited to this.
[0065] In order to facilitate understanding of the technical solution of the present application, the solution of step S210 is described below by collecting the user's click log to obtain the historical rewrite record.
[0066] Step S210 may include: step a, collecting click logs of different users, wherein the click logs record multiple historical query statements and the clicked search results corresponding to each historical query statement; step b, obtaining rewriting identification information of each historical query statement according to the clicked search results.
[0067] It should be understood that the above-mentioned rewrite identification information can be set according to actual needs. For example, when the historical query statement needs to be rewritten, the rewrite identification information corresponding to the historical query statement is "1", and the embodiments of the present application are not limited to this. For another example, when the historical query statement does not need to be rewritten, the rewrite identification information corresponding to the historical query statement is "0", and the embodiments of the present application are not limited to this.
[0068] Among them, in the above step a, optionally, the user can enter the points of interest that he wants to query on the software APP on the user terminal or other software APP on the terminal that can be used to input query statements. Specifically, it can be applied to the taxi scene. For example, when the user wants to enter the corresponding destination address, the user can enter the corresponding destination address on the relevant display interface of the software APP of the user terminal. The user terminal displays multiple matching addresses to be selected for the user based on the destination address entered by the user. The user can select or click on a corresponding address as the final destination address based on the displayed multiple addresses to be selected, wherein the multiple addresses to be selected are multiple points of interest, the final destination address is the clicked point of interest, and the destination address entered by the user is the query statement.
[0069] In addition, when a user uses the software APP to take a taxi, the process of the user taking the taxi is saved in the click log, that is, the click log records multiple historical query statements and the points of interest clicked corresponding to each historical query statement. Subsequently, the historical query statements entered by the user and the points of interest clicked are obtained by aggregating the click logs of multiple users to obtain the historical rewrite record.
[0070] In addition, after aggregating the user's click logs, one query statement can correspond to multiple clicked points of interest.
[0071] For example, for the same user A, the query statement entered by user A at position F is "supermarket", and the query statement entered by user A at position E is "supermarket", then the final points of interest clicked may be different, and the embodiments of the present application are not limited to this.
[0072] For another example, for different users B and C, the query statement entered by user B at position M is "supermarket", and the query statement entered by user C at position N is "supermarket", then the points of interest clicked by user B and user C may also be different. The embodiments of the present application are not limited to this.
[0073] In addition, by establishing a mapping relationship between different historical query statements and the clicked points of interest corresponding to each historical query statement, it is possible to find out how many clicked points of interest there are or the number of clicked points of interest under the same historical query statement, which makes it easier to judge whether the historical query statement needs to be rewritten or not based on the clicked points of interest.
[0074] Of course, the application scenarios of the present application may not be limited to the above-mentioned taxi-hailing scenarios, but may also be users' queries for any points of interest. For example, in a map search scenario, if a user wants to query a certain location, the user can also enter a certain location on the relevant interface of the terminal software APP, so that the electronic device can display multiple locations matching the location entered by the user based on the location entered by the user. For example, if the query statement entered by the user is "Beijing", the electronic device will display the three locations of "Beijing", "Bird's Nest" and "Beijing West Railway Station" to the user based on the retrieval match. These three locations can be presented to the user as three points of interest. The embodiments of the present application are not limited to this.
[0075] Therefore, it can be understood that the query statement can be a statement that the user wants to query input, and the search results can be multiple points of interest obtained based on the statement that the user wants to query input.
[0076] It should be understood that although the embodiment of the present application shows a case where the search results are points of interest, in different scenarios, the search results may correspond to different names, and the embodiment of the present application is not limited to this.
[0077] In addition, in the above step b, in order to facilitate understanding of the technical solution of step b of the embodiment of the present application, the following description is given by taking the scenario of online taxi-hailing as an example. Of course, it can be understood that the technical solution of step b of the present application described below is also applicable to other scenarios, and the embodiment of the present application is not limited thereto.
[0078] In step b, the user can calculate the probability that the historical query statement appears in the clicked point of interest.
[0079] Here, it is necessary to determine whether the historical query statement should be rewritten. The basis for the determination is the point of interest clicked by the user. If all the words in the historical query statement entered by the user appear in the clicked point of interest, it is considered that the historical query statement does not need to be rewritten.
[0080] For example, when the historical query sentence input by the user is "Nankai", and the clicked point of interest corresponding to the historical query sentence is "Tianjin Nankai", it is considered that the historical query sentence does not need to be rewritten.
[0081] For another example, when the historical query sentence input by the user is "Peking University", and the clicked point of interest corresponding to the historical query sentence is "Peking University", it is considered that the historical query sentence needs to be rewritten.
[0082] In addition, the clicked point of interest here includes information such as name, address, longitude and latitude, so the historical query statement can appear in the name or in the address, and when the historical query statement appears in the name or address, it is considered that the historical query statement appears in the clicked point of interest. The embodiments of the present application are not limited to this.
[0083] For example, when the historical query sentence input by the user is "mall", and there are 6 clicked points of interest corresponding to the historical query sentence, the "mall" appears in the names of 2 clicked points of interest, and the "mall" appears in the address of one of the clicked points of interest. When the word "mall" appears in all 3 clicked points of interest, the probability that the "mall" appears in all the clicked points of interest is 3 / 6, and the embodiments of the present application are not limited to this.
[0084] In addition, the historical query sentence input by the user includes multiple words in addition to the above-mentioned single word case, so here the words in the historical query sentence can be split first, and then the probability of all the words after the split appearing in the clicked point of interest is calculated. In addition, the words after the split of the historical query sentence all appear in the clicked point of interest, including part of the words appearing in the name and the other part appearing in the address; or, all the words appear in the name; or, all the words appear in the address, and the embodiments of the present application are not limited to this.
[0085] For example, when the historical query sentence input by the user is "Beijing West Railway Station", and there are 5 clicked points of interest corresponding to the historical query sentence. After splitting "Beijing West Railway Station" into two words "Beijing" and "West Railway Station", it is determined that the two words "Beijing" and "West Railway Station" all appear in the three clicked points of interest (that is, each of the three clicked points of interest includes the two words "Beijing" and "West Railway Station"), then the probability of determining that "Beijing West Railway Station" appears in all the clicked points of interest is 3 / 5, and the embodiments of the present application are not limited to this.
[0086] In addition, after obtaining the probability of the historical query statement appearing in the clicked point of interest, the rewriting identification information of each historical query statement is determined by setting a threshold.
[0087] Optionally, the rewrite identification information of each historical query statement can be obtained by setting a probability threshold. Specifically, the user can set the rewrite identification information that does not need to be rewritten when the probability is equal to the first probability threshold, and can also set the rewrite identification information that needs to be rewritten when the probability is less than or equal to the second probability threshold.
[0088] For example, if the first probability threshold is 100%, the rewriting identification information of the historical query statement with a probability of 100% is set to "1", where "1" indicates that rewriting is not required.
[0089] For another example, if the second probability threshold is 60%, the rewrite identification information of the historical query statements with probabilities between 0% and 60% is set to "0", where "0" indicates that rewrite is required.
[0090] In addition, for historical query statements whose probabilities are between the first probability threshold and the second probability threshold, the probability of rewriting these historical query statements is relatively high, and it is difficult to determine whether these historical query statements need to be rewritten.
[0091] For example, when the historical query statement input by the user is "Beijing market", this historical query statement indicates a search for the market in Beijing. Although the final clicked point of interest does not include "Beijing", the clicked point of interest is within the range of "Beijing". Therefore, the method based on the above threshold determination cannot determine whether the historical query statement is rewritten.
[0092] Step S220: Use the historical rewriting records as samples for training to obtain a pre-trained binary classification model.
[0093] It should be understood that the specific model type of the binary classification model can be set according to actual needs. For example, the binary classification model can be a text classifier fasttext, which has the advantage of very fast training, and it is equivalent to expressing or mapping the query statement into a vector, and classifying the result obtained by the vector. This vector reflects the characteristics of the words in a query statement, so this vector expresses the language characteristics of the query statement, which is the characteristics of the language model. Therefore, the model obtained by the text classifier fasttext model based on the query statement learning reflects the language model based on the query statement, and the embodiments of the present application are not limited to this.
[0094] In step S220, the training process of the binary classification model includes:
[0095] Step (A): inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result, wherein the established binary classification model may be an untrained model.
[0096] Step (B), adjusting the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain a pre-trained binary classification model.
[0097] Step (C), repeat the above steps (A) and (B) until the difference between the output of the binary classification model and the rewriting identification information is less than the preset threshold, then convergence is determined and the training is completed. Subsequently, the trained preset model is used to determine whether the query statement input by the user needs to be rewritten.
[0098] Step S230: obtaining a query statement input by the user.
[0099] It should be understood that the query statement input by the user may be the destination entered by the user in a taxi-hailing scenario, or a location entered by the user in a map search scenario, or a word entered by the user in a search scenario, and the embodiments of the present application are not limited to this.
[0100] Step S240: Determine whether the input query statement needs to be rewritten by using a pre-trained binary classification model.
[0101] In step S240, the query statement input by the user is input as input to the trained binary classification model, and the binary classification model outputs the probability that the query statement needs to be rewritten and the probability that the query statement needs to be rewritten. Subsequently, a preset third probability threshold is used to determine whether the query statement input by the user needs to be rewritten.
[0102] For example, when the preset third probability threshold is 50%, and the binary classification model outputs that the probability that the query statement needs to be rewritten is 45% and the probability that it needs to be rewritten is 55%, since the probability of needing to be rewritten is greater than the preset third probability threshold, it is ultimately determined that the query statement needs to be rewritten. The embodiments of the present application are not limited to this.
[0103] In addition, the present application can train a binary classification model through a large number of query statements, so the corresponding rewrite result can be obtained for the query statement input by the user. Since the query statement used for training is large, it is applicable to basically all query statements. Even if the query statement input by the user is a query statement that has never appeared before, it can determine whether the corresponding word segmentation needs to be rewritten by determining the probability of each word in the query statement.
[0104] For example, when a query statement contains two words, a binary classification model can be used to determine whether each word needs to be rewritten. When one of the two words needs to be rewritten, it is considered that the query statement needs to be rewritten; when neither of the two words needs to be rewritten, it is considered that the query statement does not need to be rewritten, that is, when there is at least one word that needs to be rewritten among all the words after the query statement is divided, it is considered that the current query statement needs to be rewritten; when all the words in the query statement do not need to be rewritten, it is considered that the current query statement does not need to be rewritten. The embodiments of the present application are not limited to this.
[0105] In the above embodiment, the embodiment of the present application determines whether the query statement input by the user needs to be rewritten through a pre-trained binary classification model, and the binary classification model is obtained based on historical rewriting records including multiple historical query statements and rewriting identification information of each historical query statement, so that the trained binary classification model can accurately determine whether the query statement input by the user needs to be rewritten.
[0106] In addition, compared with the existing solutions that use traditional dictionary files to determine whether a query statement needs to be rewritten, the solution of the present application can not only eliminate large-scale dictionary files, but also greatly improve the prediction performance, and finally train a binary classification model that can reflect the characteristics of whether a query statement can be rewritten or not. Therefore, the clever use of a binary classification model can not only reflect the characteristics of the existing language model, but also obtain a binary classification function of whether the query statement needs to be rewritten. At the same time, it does not need to accumulate many features of the query statement, and can quickly determine whether the query statement input by the user needs to be rewritten.
[0107] In order to facilitate understanding of the technical solution of the present application, the solution of the present application is described below through a specific solution.
[0108] Please parameter Figure 3 , Figure 3 A flowchart of a query statement retrieval method provided in an embodiment of the present application is shown, and the method comprises the following steps:
[0109] Step S310, obtaining a query statement input by a user;
[0110] Step S320, inputting the query sentence input by the user as input into the trained binary classification model;
[0111] Step S330, determining whether the query sentence input by the user needs error correction by using the trained binary classification model, wherein the error correction may also be called rewriting, but the embodiment of the present application is not limited thereto;
[0112] The error correction is implemented by using the HMM error correction of step S341 and the deep error correction of step S342, wherein the HMM error correction represents an error correction model made by a statistical model, and the deep error correction represents an error correction model made by a deep model;
[0113] In addition, the above-mentioned HMM error correction and deep error correction can both be referred to as error correction rewriting models, but the embodiments of the present application are not limited to this.
[0114] For example, when the query sentence input by the user is "KFC", the query sentence input by the user is modified to "KFC" through the error correction rewriting model, but the embodiments of the present application are not limited to this.
[0115] It should be understood that in addition to the above-mentioned error correction rewriting model, it may also include a synonymous rewriting model, an omission rewriting model, etc., and the embodiments of the present application are not limited to this.
[0116] For example, when the query sentence input by the user is "KFC Kentucky Fried Chicken", since "KFC" and "Kentucky Fried Chicken" have the same meaning, the query sentence input by the user is modified to "Kentucky Fried Chicken" through the synonym rewriting model, but the embodiments of the present application are not limited to this.
[0117] For another example, when the query statement input by the user is "destination Beijing", the query statement input by the user is modified to "Beijing" by omitting the rewriting model, but the embodiments of the present application are not limited to this.
[0118] In addition, although the rewriting model is exemplified above, those skilled in the art should understand that in addition to the two rewriting models exemplified above, other rewriting models may be set according to actual needs, and the embodiments of the present application are not limited thereto.
[0119] Step S350, merge the results of multiple error corrections, wherein rewriting may be divided into multiple rewritings (for example, error correction rewriting, synonymous rewriting, and omitted rewriting, etc.). For different rewriting models, the rewriting results of different rewriting models may be the same, and multiple rewriting results need to be merged. Since not all results are returned, the final rewriting result is determined by a probability, and a value with a relatively high probability value is used for retrieval.
[0120] Step S360, performing a search based on the result of the result fusion, and outputting the search result.
[0121] Please continue to see Figure 4 , Figure 4 A flowchart of a method for training a model provided in an embodiment of the present application is shown. It should be understood that Figure 4 The methods and Figure 2 The method embodiment corresponds to the embodiment of the invention. For details, please refer to Figure 2 In order to avoid repetition, the description is appropriately omitted here. The method includes:
[0122] Step S410, obtaining a historical rewriting record, wherein the historical rewriting record includes a plurality of historical query statements and rewriting identification information of each historical query statement;
[0123] Step S420: Use the historical rewriting records as samples to train a trained binary classification model, wherein the trained binary classification model is used to determine whether the query statement input by the user needs to be rewritten.
[0124] Optionally, obtaining the historical rewriting record includes: obtaining a user's click log, wherein the click log records a plurality of historical query statements and a clicked search result corresponding to each historical query statement; and obtaining rewriting identification information of each historical query statement according to the clicked search result.
[0125] Optionally, the historical rewriting records are used as samples for training to obtain a trained binary classification model, including: inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; adjusting the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain the trained binary classification model.
[0126] Optionally, the trained binary classification model is a text classifier.
[0127] Please continue to see Figure 5 , Figure 5 FIG. 5 is a schematic diagram showing a structure of a query statement processing device provided in an embodiment of the present application. The device 500 may be a module, a program segment or a code running on the electronic device 100. It should be understood that the device 500 and the above Figure 2 The method embodiment corresponds to and can be executed Figure 2 The various steps involved in the method embodiment and the specific functions of the device 500 can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.
[0128] Optionally, the device 500 includes: a first acquisition module 510, used to obtain a query statement input by a user; a determination module 520, used to determine whether the input query statement needs to be rewritten through a pre-trained binary classification model, wherein the pre-trained binary classification model is obtained based on historical rewriting records, and the historical rewriting records include multiple historical query statements and rewriting identification information of each historical query statement.
[0129] Optionally, the processing device further includes: a second acquisition module (not shown), used to acquire historical rewriting records; and a training module (not shown), used to train the historical rewriting records as samples to obtain a pre-trained binary classification model.
[0130] Optionally, the second acquisition module includes: a first acquisition sub-module (not shown), used to obtain the user's click log, wherein the click log records multiple historical query statements and the clicked search results corresponding to each historical query statement; a second acquisition sub-module (not shown), used to obtain the rewrite identification information of each historical query statement based on the clicked search results.
[0131] Optionally, the training module includes: an input module (not shown), used to input historical query statements in historical rewriting records into the established binary classification model to obtain initial rewriting results; an adjustment module (not shown), used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting results and the rewriting identification information to obtain a pre-trained binary classification model.
[0132] Optionally, the pre-trained binary classification model is a text classifier.
[0133] Please continue to see Figure 6 , Figure 6 FIG. 6 is a schematic diagram showing a structure of a training model apparatus 600 provided in an embodiment of the present application. The apparatus 600 may be a module, a program segment or a code running on the electronic device 100. It should be understood that the apparatus 600 is similar to the above-mentioned Figure 4 The method embodiment corresponds to and can be executed Figure 4 The various steps involved in the method embodiment and the specific functions of the device 600 can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.
[0134] Optionally, the device 600 includes: an acquisition module 610, used to obtain historical rewrite records, wherein the historical rewrite records include multiple historical query statements and rewrite identification information of each historical query statement; a training module 620, used to train the historical rewrite records as samples to obtain a trained binary classification model, wherein the trained binary classification model is used to determine whether the query statement input by the user needs to be rewritten.
[0135] Optionally, the acquisition module 610 includes: a first acquisition sub-module (not shown), used to acquire the user's click log, wherein the click log records multiple historical query statements and the clicked search results corresponding to each historical query statement; a second acquisition sub-module (not shown), used to acquire the rewrite identification information of each historical query statement based on the clicked search results.
[0136] Optionally, the training module 620 includes: an input module (not shown), used to input historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; an adjustment module (not shown), used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain a trained binary classification model.
[0137] Optionally, the trained binary classification model is a text classifier.
[0138] The embodiment of the present application also provides a readable storage medium, when the computer program is executed by a processor, Figure 2 The method process in the method embodiment shown is executed by the electronic device.
[0139] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.
[0140] The embodiment of the present application also provides a readable storage medium, when the computer program is executed by a processor, Figure 4 The method process in the method embodiment shown is executed by the electronic device.
[0141] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.
[0142] In summary, the embodiments of the present application provide a method for processing query statements, a method for training models, an apparatus and a device. In the processing method, a pre-trained binary classification model is used to determine whether the query statement input by the user needs to be rewritten. Compared with the existing solution of determining whether the query statement needs to be rewritten through traditional dictionary files, the solution of the present application can not only eliminate large-scale dictionary files, but also greatly improve the prediction performance, and the finally trained binary classification model can reflect the characteristics of whether the query statement can be rewritten or not. Therefore, the clever use of a binary classification model can not only reflect the characteristics of the existing language model, but also obtain a binary classification function of whether the query statement needs to be rewritten. At the same time, it does not need to accumulate many features of the query statement, and can quickly determine whether the query statement input by the user needs to be rewritten.
[0143] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely 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 application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a 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.
[0144] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0145] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including 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 described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0146] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0147] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0148] 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 "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for processing a query statement, characterized in that: include: Get the query statement entered by the user; Determine whether the input query statement needs to be rewritten by using a pre-trained binary classification model, wherein the pre-trained binary classification model is obtained according to a historical rewriting record, wherein the historical rewriting record includes a plurality of historical query statements and rewriting identification information of each of the historical query statements, wherein obtaining the historical rewriting record includes: Obtaining a click log of the user, wherein the click log records the multiple historical query statements and the clicked search results corresponding to each of the historical query statements; According to the clicked search results, obtaining rewriting identification information of each of the historical query statements; and By aggregating the click logs, a mapping relationship between the multiple historical query statements and the clicked search results corresponding to each of the historical query statements is established.
2. The processing method according to claim 1, characterized in that: The processing method also includes: Obtaining the historical rewriting record; The historical rewriting records are used as samples for training to obtain the pre-trained binary classification model.
3. The processing method according to claim 2, characterized in that: The step of training the historical rewriting records as samples to obtain the pre-trained binary classification model includes: Inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; The parameters in the established binary classification model are adjusted according to the difference between the initial rewriting result and the rewriting identification information to obtain the pre-trained binary classification model.
4. The processing method according to claim 1, characterized in that: The pre-trained binary classification model is a text classifier.
5. A method for training a model, characterized in that: include: Acquire a historical rewrite record, wherein the historical rewrite record includes a plurality of historical query statements and rewrite identification information of each of the historical query statements; The historical rewriting records are used as samples for training to obtain a trained binary classification model, wherein the trained binary classification model is used to determine whether the query statement input by the user needs to be rewritten, wherein obtaining the historical rewriting records includes: Obtaining a click log of the user, wherein the click log records the multiple historical query statements and the clicked search results corresponding to each of the historical query statements; According to the clicked search results, rewriting identification information of each of the historical query statements is obtained, and By aggregating the click logs, a mapping relationship between the multiple historical query statements and the clicked search results corresponding to each of the historical query statements is established.
6. The method according to claim 5, characterized in that The training of the historical rewriting records as samples to obtain a trained binary classification model includes: Inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; The parameters in the established binary classification model are adjusted according to the difference between the initial rewriting result and the rewriting identification information to obtain the trained binary classification model.
7. The method according to claim 5, characterized in that The trained binary classification model is a text classifier.
8. A query statement processing device, characterized in that: include: A first acquisition module, used to acquire a query statement input by a user; A determination module, used to determine whether the input query statement needs to be rewritten by using a pre-trained binary classification model, wherein the pre-trained binary classification model is obtained based on a historical rewriting record, and the historical rewriting record includes a plurality of historical query statements and rewriting identification information of each of the historical query statements; The processing device also includes: A first acquisition submodule is used to acquire a user's click log, wherein the click log records the multiple historical query statements and the clicked search results corresponding to each of the historical query statements; A second acquisition submodule is used to acquire rewriting identification information of each of the historical query statements according to the clicked search results, and The first aggregation module is used to establish a mapping relationship between the multiple historical query statements and the clicked search results corresponding to each of the historical query statements by aggregating the click logs.
9. The processing device according to claim 8, characterized in that The processing device also includes: A second acquisition module, used to acquire the historical rewriting record; The training module is used to train the historical rewriting records as samples to obtain the pre-trained binary classification model.
10. The processing device according to claim 9, characterized in that The training module includes: An input module, used for inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; An adjustment module is used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain the pre-trained binary classification model.
11. The processing device according to claim 8, characterized in that The pre-trained binary classification model is a text classifier.
12. A device for training a model, characterized in that: include: An acquisition module, configured to acquire a historical rewriting record, wherein the historical rewriting record includes a plurality of historical query statements and rewriting identification information of each of the historical query statements; A training module is used to train the historical rewriting records as samples to obtain a trained binary classification model, wherein the trained binary classification model is used to determine whether the query statement input by the user needs to be rewritten, wherein the acquisition module includes: A first acquisition submodule is used to acquire a user's click log, wherein the click log records the multiple historical query statements and the clicked search results corresponding to each of the historical query statements; A second acquisition submodule is used to acquire rewriting identification information of each of the historical query statements according to the clicked search results, and The first aggregation module is used to establish a mapping relationship between the multiple historical query statements and the clicked search results corresponding to each of the historical query statements by aggregating the click logs.
13. The device according to claim 12, characterized in that The training module includes: An input module, used for inputting the historical query statements in the historical rewriting records into the established binary classification model to obtain an initial rewriting result; An adjustment module is used to adjust the parameters in the established binary classification model according to the difference between the initial rewriting result and the rewriting identification information to obtain the trained binary classification model.
14. The device according to claim 12, characterized in that The trained binary classification model is a text classifier.
15. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate via the bus, and the processor executes the machine-readable instructions to perform the steps of the query statement processing method as described in any one of claims 1 to 4.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for processing a query statement according to any one of claims 1 to 4 are executed.
17. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the method for training a model as described in any one of claims 5 to 7.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for training a model as described in any one of claims 5 to 7 are executed.
