CN109857845B - Model training and data retrieval method, device, terminal and computer-readable storage medium - Google Patents

Model training and data retrieval method, device, terminal and computer-readable storage medium Download PDF

Info

Publication number
CN109857845B
CN109857845B CN201910005290.1A CN201910005290A CN109857845B CN 109857845 B CN109857845 B CN 109857845B CN 201910005290 A CN201910005290 A CN 201910005290A CN 109857845 B CN109857845 B CN 109857845B
Authority
CN
China
Prior art keywords
query
rewrite
training
model
text
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910005290.1A
Other languages
Chinese (zh)
Other versions
CN109857845A (en
Inventor
符文君
吴友政
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201910005290.1A priority Critical patent/CN109857845B/en
Publication of CN109857845A publication Critical patent/CN109857845A/en
Application granted granted Critical
Publication of CN109857845B publication Critical patent/CN109857845B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a model training and data retrieval method, a device, a terminal and a computer readable storage medium, wherein the training method comprises the following steps: acquiring a first training set, wherein the first training set comprises a first original query and a first rewritten query which are matched with the same query result; pre-training the rewrite pair generation model according to a first training set; acquiring a second training set, wherein the second training set comprises a plurality of first positive samples and a plurality of first negative samples, the first positive samples comprise a second original query and a second rewritten query which are matched with the same query result, and the first negative samples comprise a third original query and a second rewritten query which are matched with different query results; pre-training the rewrite pair discrimination model according to a second training set; according to the method of the confrontational training, the two pre-trained models are confrontational trained. The rewrite pair generation model after the confrontation training can be used for inquiring the input user text to generate the optimal rewrite inquiry text, so that the accuracy of data search can be improved.

Description

Model training and data retrieval method, device, terminal and computer-readable storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a model training and data retrieval method, a model training and data retrieval device, a terminal and a computer readable storage medium.
Background
Currently, when a user queries content on a search engine, query sentences input by the user have diversity, ambiguity and randomness. For example, the user enters "who is the director of the crayon novice" to make a query, wherein the user enters one more word "pull"; and if the user inputs 'Tegong imperial concubine broadcasting time' for query, wherein the input text comprises the alias 'Tegong imperial concubine' of 'Chuqiao', the similar user query sentences can cause that the query sentences cannot be converted into structured query languages, and the content required by the user is difficult to be accurately hit.
Therefore, it is necessary to rewrite the natural language query input by the user and rewrite the original query sentence input by the user to a semantically accurate query sentence.
Disclosure of Invention
The invention provides a model training and data retrieval method, a model training and data retrieval device, a terminal and a computer readable storage medium, which are used for solving the problem that inaccurate original query sentences input by a user are difficult to accurately search data in the related technology.
In order to solve the above problem, according to an aspect of the present invention, there is disclosed a model training method including:
acquiring a first training set, wherein the first training set comprises a first original query and a first rewritten query which are matched with the same query result;
pre-training a rewrite pair generation model according to the first training set, wherein the pre-trained rewrite pair generation model is used for generating a rewrite query text for an input user query text;
obtaining a second training set, wherein the second training set comprises a plurality of first positive samples and a plurality of first negative samples, the first positive samples comprise a second original query and a second rewritten query which match the same query result, and the first negative samples comprise a third original query and a second rewritten query which match different query results;
pre-training a rewrite pair discrimination model according to the second training set, wherein the pre-trained rewrite pair discrimination model is used for judging whether the rewrite query text is the best rewrite query of the user query text or not and outputting a judgment result for the input user query text and the rewrite query text;
according to the method of the countermeasure training, the generated model of the rewrite pair which is trained in advance and the discrimination model of the rewrite pair which is trained in advance are subjected to the countermeasure training, and the generated model of the rewrite pair which is trained in advance is used for generating the optimal rewrite query text for any input user query text.
According to another aspect of the present invention, the present invention also discloses a model training apparatus, comprising:
the first acquisition module is used for acquiring a first training set, wherein the first training set comprises a first original query and a first rewritten query which are matched with the same query result;
the first pre-training module is used for pre-training a rewrite pair generation model according to the first training set, and the rewrite pair generation model after the pre-training is used for generating a rewrite query text for an input user query text;
a second obtaining module, configured to obtain a second training set, where the second training set includes multiple first positive samples and multiple first negative samples, the first positive samples include a second original query and a second rewritten query that match a same query result, and the first negative samples include a third original query and a second rewritten query that match different query results;
the second pre-training module is used for pre-training a rewrite pair discrimination model according to the second training set, and the rewrite pair discrimination model after the pre-training is used for judging whether the rewrite query text is the best rewrite query of the user query text or not and outputting a judgment result for the input user query text and the rewrite query text;
and the countermeasure training module is used for carrying out countermeasure training on the pre-trained rewrite pair generation model and the pre-trained rewrite pair judgment model according to a countermeasure training method, and the rewrite pair generation model after the countermeasure training is used for generating the optimal rewrite query text for any input user query text.
According to another aspect of the present invention, the present invention also discloses a data retrieval method, including:
receiving a user query text;
inputting the user query text into a rewrite pair generation model which is trained in advance to obtain an optimal rewrite query text;
searching a preset knowledge icon according to the optimal rewriting query text to obtain a search result;
wherein the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
According to another aspect of the present invention, the present invention also discloses a data retrieving apparatus, comprising:
the receiving module is used for receiving a user query text;
the input module is used for inputting the user query text into a rewrite pair generation model which is trained in advance to obtain an optimal rewrite query text;
the retrieval module is used for retrieving a preset knowledge icon according to the optimal rewriting query text to obtain a retrieval result;
wherein the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
According to another aspect of the present invention, the present invention also discloses a terminal, comprising: a memory, a processor, and a model training program stored on the memory and executable on the processor, the model training program when executed by the processor implementing the steps of the model training method as in any one of the above.
According to yet another aspect of the present invention, the present invention also discloses a computer readable storage medium having stored thereon a model training program, which when executed by a processor implements the steps of the model training method as described in any one of the above.
According to still another aspect of the present invention, the present invention also discloses a terminal, comprising: a memory, a processor and a data retrieval program stored on the memory and executable on the processor, the data retrieval program when executed by the processor implementing the steps of the data retrieval method as described above.
According to still another aspect of the present invention, the present invention also discloses a computer readable storage medium, on which a data retrieval program is stored, which when executed by a processor implements the steps in the data retrieval method described above.
Compared with the prior art, the invention has the following advantages:
therefore, the embodiment of the invention respectively pre-trains the rewrite pair generation model and the rewrite pair discrimination model and performs countermeasure training on the two pre-trained models, so that the rewrite pair generation model can be automatically and iteratively updated according to the judgment result from the rewrite pair discrimination model in the countermeasure training process, the rewrite pair generation model after the countermeasure training can be used for querying any input user text to generate the optimal rewrite query text, and then the rewrite query text obtained by rewriting the generation model is utilized to perform data search, so that the accuracy of data search can be improved.
Drawings
FIG. 1 is a flow chart of the steps of one embodiment of a model training method of the present invention;
FIG. 2 is a flow chart of steps in another embodiment of a model training method of the present invention;
FIG. 3 is a schematic diagram of a syntax tree embodiment of the present invention;
FIG. 4 is a partial schematic view of a knowledge-graph of the present invention;
FIG. 5 is a flow chart of steps of yet another embodiment of a model training method of the present invention;
FIG. 6 is a flow chart of the steps of one embodiment of a data retrieval method of the present invention;
FIG. 7 is a block diagram of a model training apparatus according to an embodiment of the present invention;
fig. 8 is a block diagram of an embodiment of a data retrieval apparatus according to the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
The embodiment of the invention provides a model training method, and the rewrite pair generated model trained by the method can rewrite any input user query text into the optimal rewrite query text with accurate semantics, thereby being capable of utilizing the optimal rewrite query text after rewriting to search data and improving the hit accuracy of the query result of the user query sentence.
In training the rewrite pair generator model, it is necessary to perform a countermeasure training by means of the rewrite pair discriminant model, so that the rewrite pair generator model after the countermeasure training can generate an optimal rewrite query for an input user query.
Before the countermeasure training, the method of the embodiment of the invention needs to respectively perform pre-training based on reinforcement learning on the rewrite pair generation model and the rewrite pair discriminant model.
When the two models are pre-trained based on reinforcement learning, the following technical principles can be referred to:
regarding the search engine as an agent, regarding the user as an Environment (Environment), taking the original query (query) input by the user as m, regarding the new terms generated at the first k-1 moments as y1, … … yk-1, and regarding the generated terms as an overwrite query or a partial overwrite query, where the moments can be understood as steps, the state (state) at the k-th moment can be expressed as (m, { y1, … …, yk-1 }). Therefore, the query rewrite problem can be converted into a sequential decision problem, and the agent's execution action (action) at time k can generate a new term yk for the original query m until the optimal rewrite query (consisting of a plurality of terms generated) is generated.
The selection of the rewriting strategy theta of the search engine during each query can be regarded as one trial and error, and the search engine can output one rewriting query under one rewriting strategy theta for the same original query; and the rewrite pair judgment model can judge whether the rewrite query is the optimal rewrite query of the original query or not based on the feedback of the user and the quality of the query result of the knowledge base. The search engine can give the decision result of the discriminant model with this rewrite as a reward (reward) obtained from the environment, and during interactive trial and error, the search engine will gradually learn the optimal query rewrite strategy θ, i.e., maximize the accumulated reward. Therefore, the search engine can output the optimal rewrite query to the original query input by the user.
When the method provided by the embodiment of the invention is used for model training, two models, namely the model 1 and the model 2, can be pre-trained respectively. The present invention does not limit the order of execution of the pre-training steps for the two models.
Model 1 is a rewrite pair generation model for generating a corresponding rewrite query for an original query (e.g., m) input by a user. After the model 1 is trained, when the model 1 is used for prediction, the input parameter is m, and the output result is the rewrite query.
The model 2 is a rewrite pair judgment model, and is used for predicting whether the rewritten query is the optimal rewritten query prefix substring of the original query for the input original query and the rewritten query. The optimal rewrite query is defined as the semantic similarity between the rewrite query and the original query, the user intention can be expressed more accurately, and the accuracy and the recall rate of the search result can be improved after the rewrite. In the process of confrontation training, the output value of the model 2 can be used as an auxiliary input signal during the training of the model 1, and is used for helping the model 1 to adjust parameters and reasonably generate the rewritten terms word by word.
After the model 2 is trained (referring to pre-training and countertraining), when the model 2 is used for prediction, the input parameters are original query and rewritten query, and the output result is 0 or 1. For example: the original query is: "Langya leader", rewrite query: "Langya director", model 2 outputs a result of 1, and the original query is: "who the Langya leader" means that the rewritten query is "Langya leader", and the output result of model 2 is 0, which indicates that the rewritten query is not the best rewritten query of the original query.
Referring to fig. 1, a flow chart of the steps of a model training method according to an embodiment of the present invention is shown, the method comprising the steps of:
step 101, a first training set is obtained, wherein the first training set comprises a plurality of second positive samples.
The first training set is training samples when the generated model is pre-trained by the rewriting pair, and the training data only comprises positive samples and does not need to construct negative samples. In order to distinguish the positive samples used in the pre-training of the overwrite pair generation model and the overwrite pair discrimination model, the positive sample used in the pre-training of the model 1 is named as the second positive sample, and the positive sample used in the pre-training of the model 2 is named as the first positive sample.
Wherein the second positive sample comprises a first original query and a first rewritten query that match the same query result;
in one example, when the first training set is obtained, user input statements corresponding to the same query result may be extracted from the log data to form a set of positive samples, i.e., a set of candidate rewrite pairs.
For example: the query text entered by the user is "who is the child of king X? "what name the child of king X called" and the query results returned by the system are "sinus XX, lie X". The two user query texts may constitute a set of candidate rewrite pairs, i.e. a pair of positive samples. And which query text in the two query texts is marked as the original query and which query text is marked as the rewritten query, which is not limited by the present invention.
In addition, the user query text extracted from the log data can be transformed (for example, by adding redundant terms, removing stop words, disordering word orders, performing synonym replacement based on a synonym dictionary, and the like) based on a data enhancement method to generate more candidate rewrite pairs.
For example, the first training set includes positive sample 1 (original query1, rewritten query1), positive sample 2 (original query2, rewritten query 2), positive sample 3 (original query1, rewritten query 3) … positive sample n (original query n, rewritten query m).
Wherein the original query2, the rewritten query2, and the rewritten query3 are query statements obtained by transforming the original query1 and the rewritten query 1.
That is, in the first training set, the query results corresponding to different positive samples may be the same or different.
102, pre-training a rewriting pair generation model according to the first training set;
wherein the pre-trained rewrite pair generation model is to generate rewrite query text for an input user query text;
in one example, the rewrite pair generation model is a sequence-to-sequence (seq 2seq) model, and a basic architecture of the model adopts an encoder-decoder architecture.
In one embodiment, a bidirectional recurrent neural network (LSTM) (Long Short-Term Memory) can be used as an encoder, and an LSTM based on an attribute mechanism can be used as a decoder. In other embodiments, sequence-to-sequence models of acyclic neural network architectures may also be employed, including convolution-based sequence-to-sequence models (convolutional sequence-to-sequence models), or multi-head attention-based (Transformer architectures).
During pre-training, the second positive sample in the first training set obtained in step 101 may be input to the seq2seq model to pre-train the seq2seq model, wherein Adam optimization algorithm may be adopted for training, and the training target is maximum likelihood estimation.
It should be noted that, since the model 1 is a seq2seq model, when the first training set is obtained, each second positive sample includes two query statements, that is, each positive sample is a set of candidate rewrite pairs corresponding to the same query result (including an original query and a rewrite query, for example, "who is child of king X.
Step 103, obtaining a second training set, wherein the second training set comprises a plurality of first positive samples and a plurality of first negative samples;
the second training set obtained here is used for training the rewrite pair discriminant model, and since the rewrite pair discriminant model is used for judging whether the two input query sentences are semantically close to each other and can express the user intention more accurately, the second training set here includes positive samples and negative samples.
Wherein the first positive sample comprises a second original query and a second rewritten query that match the same query result, and the first negative sample comprises a third original query and the second rewritten query that match different query results.
That is, the first positive sample includes two query statements, the two query statements correspond to the same query result, and the first negative sample also includes two query statements, but the two query statements correspond to different query results, but there is the same one query statement between the same set of positive and negative samples, i.e., the second rewritten query.
When the first positive sample in the second training set is obtained, any one user query statement (such as query1), namely a second rewritten query, is obtained from the user log data, and another query2 which is the same as the search result of the user query statement is mined from the user log data; correcting the query1 to obtain a query3, and acquiring a query4 of which the edit distance to the query1 is smaller than a preset distance threshold; then, the query2, the query3 and the query4 obtained by mining can be used as normal example samples (all being the second original query) of the query1, so as to construct three groups of normal samples, where the normal samples are in the form of (second original query, second rewritten query), specifically, (query2, query1), (query3, query1), (query4 and query 1);
in addition, other queries with different search results corresponding to query1 can be randomly selected from the user log data as negative examples of the query1 (all are third original queries), so that a plurality of groups of first negative examples are respectively formed with the query 1.
Wherein, in order to distinguish between positive and negative examples in the second training set, and which of the respective examples is the original query and which is the rewritten query. Each sample can have label data, and the label form of each sample in the second training set is < original query, rewritten query, and the rewritten query is used as the probability value of the best rewritten query of the original query >.
Wherein, the probability value marked in the negative sample is 0, and the probability value marked in the positive sample is 1.
For example: for the rewritten query "Langya leaders", the original query corresponding to the rewritten query may be found to include: "Langya leaders", "which Langya leaders" so that three positive samples can be formed, the positive sample 1< Langya leaders-labeled second original query, Langya leaders-labeled second rewritten query, 1>, the positive sample 2< Langya leaders, 1>, the positive sample 3< Langya leaders who leads, Langya leaders, 1 >; the negative examples corresponding to the rewriting query "reed board director" may include, but are not limited to: negative sample 1< seniority of the Yanxi strategy, Langya leader-leader, 0 >; negative sample 2< exemplary lead actor, Langya guide, 0 >.
In the above example, only the annotation data of the second original query and the second rewritten query are described for the positive sample 1, and the annotation data of other samples are similar and are not described here.
Since the user inputs various original queries in the query sentence, a variety of original queries are constructed in the training sample when the model 2 is pre-trained.
104, pre-training a rewriting discrimination model according to the second training set;
the pre-trained rewrite pair judgment model is used for judging whether the input user query text and the input rewrite query text are the best rewrite query of the user query text or not and outputting a judgment result;
wherein the rewrite query text is generated and output for the input user query text by the rewrite pair generation model;
in an example, the rewriting pair discrimination model may adopt a GBDT (Gradient Boosting Decision Tree) model, and may also be other neural network models in other embodiments, which is not described herein again.
During pre-training, any positive sample or negative sample in the second training set obtained in step 103 may be used to pre-train the GBDT model, so that the pre-trained GBDT model can determine whether the rewritten query text is the best rewritten query of the user query text for the input user query text and the rewritten query text, and output a determination result.
The pre-trained seq2seq model can query the input text of the user and output the rewritten query text. Then, the method of the embodiment of the present invention may utilize the pre-trained GBDT model to distinguish the user query text from the rewrite query text, distinguish whether the rewrite query text is the best rewrite query of the user query text, and output a 0 or 1 judgment result, where when the output result is 0, it indicates that the rewrite query text is not the best rewrite query of the user query text; when the output result is 1, it indicates that the rewritten query text is the best rewritten query of the user query text.
105, carrying out countermeasure training on the pre-trained rewrite pair generation model and the pre-trained rewrite pair judgment model according to a countermeasure training method;
wherein the rewrite pair generation model after the countermeasure training is used to generate an optimal rewrite query text for any one of the user query texts inputted.
In the above-mentioned countercheck training, the determination result output by the rewrite pair identification model may be used to guide the training of the rewrite pair generation model, so that the rewrite pair generation model after countercheck training can generate an optimal rewrite query text for any input user query text.
In the embodiment of the present invention, after the rewrite pair generation model and the rewrite pair discrimination model are pre-trained respectively, the rewrite pair generation model and the rewrite pair discrimination model after the pre-training can be trained simultaneously by using a countermeasure training method. Due to the strong robustness of the method for resisting training, the method can be suitable for the condition of unbalanced distribution of training data, such as: too few positive samples and too many negative samples. In a general application scenario, sample data collected during model training cannot necessarily reflect the distribution situation of real data due to time and scale limitations, and through a countertraining method, the model can better simulate the distribution of the real data and learn from the distribution, and the two trained models can more accurately process the real data during online prediction.
In the countermeasure training process, after the rewrite pair judgment model outputs the rewrite query text to the user query text, the rewrite pair judgment model can judge whether the user query text and the rewrite query text are the best rewrites, and the judgment result is used as the reward of the rewrite pair generation model to guide the rewrite pair generation model to carry out the next round of training, so that the rewrite pair generation model can be guided to generate the best rewrite query.
Therefore, the embodiment of the invention respectively pre-trains the rewrite pair generation model and the rewrite pair discrimination model and performs countermeasure training on the two pre-trained models, so that the rewrite pair generation model can be automatically and iteratively updated according to the judgment result from the rewrite pair discrimination model in the countermeasure training process, the rewrite pair generation model after the countermeasure training can be used for querying any input user text to generate the optimal rewrite query text, and then the rewrite query text obtained by rewriting the generation model is utilized to perform data search, so that the accuracy of data search can be improved.
Optionally, in an embodiment, when the step 104 is executed, that is, when each sample in the second training set and the label data of each sample are used for pre-training the discriminative model for rewriting, the method shown in fig. 2 may be adopted to implement:
three types of feature data, namely the data acquired from S201 to S203, can be extracted by using each sample and its labeled data in the second training set, and then the three types of data are input to rewrite and pre-train the discriminant model by using S204. The three types of data may be labeled with probability values corresponding to the samples (for example, the probability value labeled by the positive sample is 1, and the probability value labeled by the negative sample is 0).
S201, obtaining a pattern matching degree between the second rewrite query in the second training set and a preset atlas query pattern set;
optionally, for any sample (a second positive sample or a second negative sample) in the second training set to be used for training, when S201 is executed, first, the semantics of the second rewritten query may be obtained; then, semantic reduction is carried out on the semantics based on the context-free grammar to generate a syntax tree; and finally, matching the grammar tree with a pattern tree in a preset map query pattern set, and taking the matched node proportion as the pattern matching degree between the second rewrite query and the preset map query pattern set.
The embodiment of the invention calculates the pattern matching degree by using a matching node proportion method based on the grammar tree, the grammar tree after semantic reduction can better depict the semantic expression of the query, and the pattern matching degree based on the knowledge graph is used as a characteristic, so that whether the rewritten query is the optimal rewritten query of the original query can be more effectively judged, and the method is more applicable to a search scene based on the knowledge graph.
When the semantics are obtained, performing semantic analysis on the second rewritten query in the sample to obtain the semantics of the second rewritten query;
the preset map query mode set can be a self-defined group of grammar sets; the syntax tree is a graphical representation of the sentence structure and represents the derivation of the sentence according to the given grammar rules; semantic reduction is the gradual conversion of the pattern structure of a sentence based on a set of context-free grammars which are defined in advance.
For example, the second rewritten query here is "daughter of king X", which is first semantically parsed to obtain "daughter of king X"; then, semantic reduction is carried out on the semantics based on the context-free grammar, and a directed grammar tree shown in FIG. 3 is generated, wherein NR represents a person name, REL represents a relationship, and NRP represents a person relationship; and matching the directed syntax tree shown in fig. 3 with the pattern tree in the preset map query pattern set. For example, if the corresponding pattern tree having the same structure as that shown in fig. 3 is matched in the preset map query pattern set, the ratio of the nodes matched in the preset map query pattern set is determined to be 1. Therefore, the second rewrite query "daughter of king X" and the preset atlas query pattern set have a pattern matching degree of 1.
Elements in the syntax tree include, but are not limited to, person Name (NR), drama (CHANNEL), show (V _ ACTOR), role (ACTOR), Relationship (REL), drama name (ALBUM), attribute (PROPERTY), VRP (role play), NRP (personal relationship), and the like.
When semantic reduction is performed on the semantics of the second rewrite query based on the context-free grammar and a grammar tree is generated, the second rewrite query is participled, and then entity recognition is performed on each participle (such as "X king", "daughter", and "daughter") (such as "X king" corresponding to the entity is NR, "daughter" corresponding to the entity is REL, "and" has no entity); then, entity disambiguation is carried out on the identified entities (for example, after the apple is identified as the fruit entity, the fruit entity is disambiguated according to the context and is corrected as the company name); then, mode node labeling is carried out based on a mode node mapping dictionary (wherein the mode node mapping dictionary configures the mapping relation between an entity type and a mode node type, for example, the entity type is person, and the mode node type is NR), for example, if an entity corresponding to a word segmentation of 'king X' is NR, the pattern node can be labeled NR for the word segmentation of 'king X' through matching of the mode node mapping dictionary; then, the mode nodes of each participle are reduced (for example, the reduction result of the mode node corresponding to "daughter of king X" is NR- > NRP, REL- > NRP), so that the directional syntax tree corresponding to "daughter of king X" can be obtained as the syntax tree shown in fig. 3.
In addition, when matching the syntax tree with the pattern tree in the preset map query pattern set, the following scheme may be referred to when calculating the matched node ratio:
for example, if the second rewritten query is "wang xix", the corresponding syntax tree is GAME, and the syntax tree is matched with the pattern tree in the preset graph query pattern set, and there are 2 nodes (GAME- > GAME _ component) in the pattern tree matched in the preset graph query pattern set, the directed syntax tree GAME corresponds to only one node in the pattern, and therefore, the ratio of the nodes matched in the preset graph query pattern set is 1/2 ═ 0.5, that is, the pattern matching degree is 0.5.
The node proportion calculation method comprises the following steps: hit node number/total node number of the matched pattern tree, where the pattern tree includes two nodes "GAME" and "GAME _ COMMENTATOR", and the syntax tree corresponding to the second rewritten query is "GAME", so only one node is hit, so 1/2 is 0.5.
S202, retrieving a preset knowledge graph according to the second rewritten query to obtain retrieval results, and acquiring the number of the retrieval results;
the preset knowledge graph may include a plurality of types of entities and relationships between different types of entities, where each entity has a name and an attribute.
The second rewritten query may be parsed into a structured first sub-graph, whether there is a second sub-graph matching the first sub-graph is retrieved in a preset knowledge graph, where the number of the second sub-graphs is the number of the retrieval results, and if there is no matching sub-graph, the number of the retrieval results is 0.
Specifically, if the second rewritten query is an entity, then whether the same-name entity exists is retrieved in the preset knowledge graph, and the number of the retrieved same-name entities is identified as the number of the retrieval results (for example, if the second rewritten query is "actor pottery XX", then two entities with the same name "actor pottery XX" can be retrieved in the knowledge graph, so that the number of the retrieval results is 2); if the second rewritten query is the relationship of a certain entity, retrieving sub-graph nodes corresponding to the relationship of the entity in a preset knowledge graph, wherein the number of the sub-graph nodes is the number of retrieval results; if the second rewritten query is an attribute of an entity, sub-graph nodes corresponding to the attribute of the entity are retrieved from the preset knowledge graph, and the number of the sub-graph nodes is the number of retrieval results.
In one example, as shown in FIG. 4, a partial diagram of a preset knowledge graph is shown, wherein Property represents a Property and relationship represents a relationship. For example, if the second rewritten query is "spouse of dun XX", the second rewritten query expresses "relationship between actors and dun XX", so that a sub-graph node corresponding to the relationship can be retrieved from the preset knowledge graph shown in fig. 4, and as can be seen from fig. 4, the returned sub-graph node result is a name entity "grand XX", and therefore, the number of the retrieval results is 1.
S203, obtaining the semantic matching degree between the second rewritten query and the second original query or the third original query;
that is, this step may obtain a semantic matching degree between two queries in any sample in the second training set, and when this embodiment uses one second positive sample in the second training set to pre-train the rewrite pair discriminant model, a semantic matching degree between the second original query and the second rewritten query in the second positive sample is obtained here. When the embodiment is pre-training the rewrite pair discriminant model by using a second negative sample in the second training set, the semantic matching degree between the third original query and the second rewritten query in the second negative sample is obtained here.
For the way of obtaining the semantic matching degree between two texts, any method for calculating the semantic matching degree can be adopted, which is not described herein again.
In the embodiment of the invention, the semantic matching degree between the original query and the rewritten query can be calculated by utilizing a semantic matching degree model.
Specifically, a semantic matching degree model, such as an attention-based semantic matching model, which is divided into an atten layer (attention layer), a compare layer (comparison layer), and an aggregation layer, may be modeled based on a neural network model, and cross entropy is used as a loss function for training the semantic matching degree model.
The training data of the semantic matching degree model is the same group of query pairs (positive samples) with the same query result, and the query pairs (negative samples) with different query results.
After the training of the semantic matching degree model by using the training data is finished, when the semantic matching degree model is used for prediction, the input of the semantic matching degree model is the second original query and the second rewritten query in S203, and the output is the semantic matching degree between the second original query and the second rewritten query; or, the input of the semantic matching degree model is the third original query and the second rewritten query described in S203, and the output is the semantic matching degree between the third original query and the second rewritten query.
S204, inputting the pattern matching degree, the number of the retrieval results and the semantic matching degree corresponding to any sample in the second training set into a rewriting and pre-training discriminant model.
The rewrite pair decision model subjected to the pre-training process shown in fig. 2 can determine whether the rewrite query text is the best rewrite query of the user query text for the input user query text and the rewrite query text, and output the determination result.
Three types of feature data are extracted from any sample in the second training set in a manner of S201 to S203, and the three types of feature data and the labeled probability value are input to, for example, a GDBT model to pre-train the GDBT model, so that the pre-trained GDBT model can determine whether the rewritten query text is the best rewritten query of the user query text and output a determination result for the input user query text and determine whether the rewritten query text is the best rewritten query of the user query text, wherein if so, the determination result is 1, and if not, the determination result is 0.
When the rewrite pair discriminant model is trained, the method and the device have the advantages that by means of the mode matching degree of the rewrite query and the preset map query mode set, the rewrite query is used for searching the preset knowledge map, the number of search results is obtained, the matching degree of the rewrite query and the preset knowledge map is comprehensively considered, in addition, the semantic matching degree of the original query and the rewrite query is also utilized, so that the matching degree between the original query and the rewrite query can be considered from the user perspective, the rewrite pair discriminant model after being pre-trained can accurately carry out the input original query and the rewrite query, and whether the rewrite query is the optimal rewrite query of the original query or not is judged. In addition, when the rewriting pair discriminant model is trained, the dynamic features (the three types of feature data) of the text input by the user can be captured, so that the risk of failure of the rewriting pair discriminant model along with the time is reduced.
Alternatively, when step 105 is performed, it may be implemented by the method shown in fig. 5:
as shown in fig. 5, the pair-of-overwrite generation model may be referred to as a model G, and the pair-of-overwrite discrimination model may be referred to as a model D.
In the countermeasure training process, the training target for the model G is reward maximization, i.e., the result OBJECT of equation 1 belowG(θ) maximize:
Figure BDA0001935187220000151
when the rewrite pair generation model generates a rewrite query for an original query, a vocabulary can be selected from a preset vocabulary table to generate a rewrite query. Generating terms in the rewritten query, for example, using a vocabulary of the entertainment domain;
in the countermeasure training process, the training target for the model D is the result of equation 2 below
Figure BDA0001935187220000152
And (3) minimizing:
Figure BDA0001935187220000153
therefore, during the confrontational training process, the objective function of the embodiment of the present invention is shown in equation 3:
Figure BDA0001935187220000154
wherein the training target in formula 3 is OBJECTG(theta) minimizing the negative result, and
Figure BDA0001935187220000155
the result of taking the negative number is maximized, which may cause the objective function shown in equation 3 to converge.
In the confrontation training process, the training set of the rewrite pair generation model may be a plurality of first positive samples in the second training set, where each first positive sample includes a second original query and a second rewritten query. Because, in the first positive sample, the second rewritten query is an exact rewritten text of the second original query;
the positive samples in the third training set for rewriting the discrimination model are also the plurality of first positive samples in the second training set, but the negative samples in the negative samples to be used are selected from a third target rewriting query whose rewriting result on the output of the generative model is not good, that is, a negative sample in the countertraining in which the rewriting pair discrimination model is composed of the second original query and the third target rewriting query whose rewriting result on the output of the generative model is poor. Thus, the third training set includes a plurality of first positive samples, and a second negative sample of a second original query and a third target rewrite query of the first positive samples.
The discrimination model of the rewrite pair is trained by rewriting the bad rewrite result output by the generation model, so that the discrimination accuracy of the trained rewrite pair discrimination model can be improved, and when the generation model of the rewrite pair is trained, parameters can be updated based on the more accurate judgment result given by the rewrite pair discrimination model, thereby achieving the training target.
Prior to the countertraining, the parameters θ of the pre-trained rewrite pair generation model and the parameters of the rewrite pair discriminant model may be initialized randomly
Figure BDA0001935187220000161
The flow of the countermeasure training is described in detail below with reference to the steps shown in fig. 5:
s301, performing first iterative updating on the parameter theta of the pre-trained rewrite pair generation model G by using a strategy gradient method based on formula 4 according to the plurality of first positive samples;
Figure BDA0001935187220000162
wherein, G (y)k|y1:k-1) To overwrite the parameters, y, that need to be estimated for the generative model G in the training of the confrontation1:k-1Representing k-1 terms, y generated by the rewrite pair Generation model G for said second original query m inputkRepresents a third rewritten query, G (y), composed of k terms generated by rewriting the second original query m input to the generation model Gk|y1:k-1) Representing rewrite vs. Generation model G on already generated terms y1:k-1When a third rewrite query y is generatedkThe probability of (d);
Qθ(sk-1,yk) The second original query m and the third rewritten query y input by the rewritten pair discrimination model D are represented by the parameter theta of the rewritten pair generation model GkAnd judging the optimal rewrite inquiry, and outputting a judgment result, wherein the judgment result is 0 or 1. Wherein s isk-1Representing the state of model G at time k-1.
For example, when the second original query m is input to the model G, and the new term generated at the first k-2 moments is { y1, … … yk-2}, the state (state) s of the model G at the k-1 moment isk-1Can be expressed as (m, { y1, … …, yk-2 });
after the parameter theta of the model G is initialized randomly, a first positive sample can be input into the model G which is pre-trained for training, a strategy gradient method is adopted for training during training, and a judgment result Q output by the model D can be referred to during the training processθ(sk-1,yk) And updating the parameter theta to achieve the purpose of updating and iterating the model G, wherein the updating iteration number can be determined empirically.
S302, inputting the second original query in the plurality of first positive samples into the rewrite pair generation model updated by the first iteration, and acquiring a third rewrite query generated by the rewrite pair generation model for the second original query;
after the model G is updated, a second original query for any one of the first positive samples may be input to the updated iterated model G, and then the model G may output a rewritten result for the second original query, here named a third rewritten query.
S303, inputting the second original query and the third rewritten query into the pre-trained rewritten pair judgment model to obtain a judgment result of whether the third rewritten query is the best rewritten query of the second original query;
the second original query input to the model G after the update iteration and the third rewritten query output by the model G may be input to the model D after the pre-training, and the model D determines whether the third rewritten query is the best rewritten query of the second original query, so as to output a determination result, and if so, determines the result Qθ(sk-1,yk) Is 1, otherwise is 0.
S304, acquiring a third target rewrite query of which the corresponding judgment result is that the third rewrite query is not the optimal rewrite query of the second original query in the third rewrite query;
in this step, it can be identified, according to the determination result given by the model D, which third rewritten queries output by the iteratively updated model G for which second original queries are inaccurate, that is, the third rewritten query whose determination result is 0, that is, the third target rewritten query here is identified.
S305, generating a third training set, where the third training set includes the plurality of first positive samples and a plurality of second negative samples, where the second negative samples include the second original query and the third target rewrite query;
the third training set for training the model D may be generated, where the positive samples in the third training set are still the first positive samples in the second training set, but the second negative samples are selected from results with insufficient accuracy output by the iteratively updated model G, that is, a third target rewrite query with a determination result of 0 by the model G, and a second original query input to the model G when generating the third target rewrite query, so as to form a second negative sample, so that a bad rewrite result output by the model G is used as a negative sample of the model D in the countermeasure training to train, thereby further improving the determination accuracy of the model D.
S306, according to the third training set, the parameters of the pre-trained rewrite pair discriminant model
Figure BDA0001935187220000184
Performing a second iterative update;
the step of training the pre-trained model D using the third training set is similar to the method of training the original model D using the second training set, and the specific process may refer to the above, which is not described herein again. In the step, when the model D is iteratively updated, the number of iterative updates is also determined according to an empirical value.
Then after the above-mentioned step of first iterative update of the model G and the step of second iterative update of the model D, it can be determined whether the above-mentioned training target, i.e. the training target shown in equation 3, is reached.
If the above training target is not reached, S307, circularly executing the first iterative updating step and the second iterative updating step until the target function converges;
namely, the above S301 to S306 are executed in a loop until the objective function converges.
Wherein the objective function is:
Figure BDA0001935187220000181
wherein the content of the first and second substances,
Figure BDA0001935187220000182
Figure BDA0001935187220000183
wherein, G (y)k|y1:k-1) To overwrite the parameters, y, that need to be estimated for the generative model G in the training of the confrontation1:k-1Generating said second original query m for input representing the rewrite pair Generation model GK-1 terms of (y)kRepresents a third rewritten query, G (y), composed of k terms generated by rewriting the second original query m input to the generation model Gk|y1:k-1) Representing rewrite vs. Generation model G on already generated terms y1:k-1When a third rewrite query y is generatedkThe probability of (d);
Qθ(sk-1,yk) The second original query m and the third rewritten query y input by the rewritten pair discrimination model D are represented by the parameter theta of the rewritten pair generation model GkAnd judging the optimal rewrite inquiry, and outputting a judgment result, wherein the judgment result is 0 or 1. Wherein s isk-1Representing the state of the overwrite pair generator model G at time k-1.
For example, when the second original query m is input into the rewrite pair generation model G, and the new terms generated at the first k-2 moments are { y1, … … yk-2}, the state (state) s of the model G at the k-1 momentk-1Can be expressed as (m, { y1, … …, yk-2 });
Figure BDA0001935187220000191
the parameters expressed in the rewrite pair discriminant model D are
Figure BDA0001935187220000192
In the case of (2), the numerical value of the loss function for the discriminant model D is rewritten.
Wherein p is1:kThe first k terms representing the third target rewrite query in the second negative example (essentially the third target rewrite query);
wherein the value of the loss function is the rewritten pair discriminant model D for the second original query m and the third target rewritten query p1:kMaking a third target rewrite query p1:kAnd obtaining the numerical value of the loss function when judging whether the query is the best rewrite query of the second original query m.
In the embodiment of the invention, the rewrite pair discriminant model D is a GBDT model, so that commonly used loss functions of GBDT, such as a Huber loss function, a mean square error, an absolute loss function and the like, can be adopted. The calculation formula for rewriting the loss function to the discriminant model is not listed here.
Figure BDA0001935187220000193
The parameters expressed in the rewrite pair discriminant model D are
Figure BDA0001935187220000194
In the case of (2), the numerical value of the loss function for the discriminant model D is rewritten.
Wherein, t1:kThe first k terms representing the second rewritten query in the first positive sample (essentially a second rewritten query);
wherein the value of the loss function is the rewrite pair discriminant model D for the second original query m and the second rewritten query t1:kMaking a second rewrite query p1:kAnd obtaining the numerical value of the loss function when judging whether the query is the best rewrite query of the second original query m.
In the embodiment of the invention, the rewrite pair discriminant model D is a GBDT model, so that commonly used loss functions of GBDT, such as a Huber loss function, a mean square error, an absolute loss function and the like, can be adopted. The calculation formula for rewriting the loss function to the discriminant model is not listed here.
In this way, the embodiment of the present invention performs countermeasure training on the generated model of the rewrite pair and the discriminant model of the rewrite pair after pre-training, can perform continuous update iteration on the generated model of the rewrite pair based on the output result of the generated model of the rewrite pair, and then performs continuous update iteration on the generated model of the rewrite pair by using the output result of the discrimination model of the rewrite pair after continuous update iteration until the training target is reached, and the generated model of the rewrite pair after the training target is reached can generate an accurate optimal rewrite query for an input original query text, and then performs data search subsequently by using the optimal rewrite query, thereby improving the accuracy and recall rate of semantic search. In the embodiment of the invention, when two models are trained, a reinforcement learning method is adopted, and compared with a supervision learning method, the data required by the two models during updating mainly comes from interaction/sampling with the environment (namely a user), so that the expense of manually marking the data is reduced; in addition, when the reinforcement learning-based method trains the generative model by rewriting, the adjusted parameters are updated autonomously and iteratively according to a reward mechanism and are not specified artificially, and the parameter adjustment of the generative model by rewriting is more flexible compared with a rule-based rewriting method.
After the training target is reached through the countertraining, the user input text can be rewritten by utilizing the rewriting pair generation model, and the rewriting result is utilized to inquire and access the knowledge graph, so that the inquiry result is obtained.
As shown in fig. 6, an embodiment of the present invention further provides a data retrieval method, which specifically includes the following steps:
step 601, receiving a user query text;
step 602, inputting the user query text into a rewrite pair generation model which is trained in advance to obtain an optimal rewrite query text;
step 603, retrieving a preset knowledge icon according to the optimal rewritten query text to obtain a retrieval result;
the rewrite pair generation model is a rewrite pair generation model which is subjected to countermeasure training in the model training method and enables an objective function to be converged, and the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
For example, the query text entered by the user is "who did i want to know the wife of the actor dung XX? "then the re-write after the countertraining is to the original query that the generative model entered" who i want to know the wife of the actor dang XX? "rewrite, generate and output the best rewrite query" Dun XX spouse "; then, the method of the embodiment of the present invention may use the best rewrite query "dun XX spouse" to access a preset knowledge graph as shown in fig. 4 (the knowledge graph includes many entity types, and specifically, the above description about the knowledge graph may be referred to), and in the preset knowledge graph, a relationship (here, "spouse") of a star entity (here, "dun XX") may be hit, and the search result is a star entity (here, "grand XX"). Finally, the search result "grandchild XX" may be returned to the user.
By means of the method, when the original query sentence input by the user is not accurate enough, the method can obtain the optimal rewrite query of the original query sentence by inputting the original query sentence into the rewrite pair generation model after the countermeasure training, the semantic of the optimal rewrite query is very close to that of the original query sentence, and the user intention can be expressed more accurately, so that the rewritten optimal rewrite query sentence is used for retrieval in the knowledge map, and the hit accuracy of the query result of the user query sentence can be improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Corresponding to the model training method provided in the embodiment of the present invention, referring to fig. 7, a structural block diagram of an embodiment of a model training apparatus according to the present invention is shown, which may specifically include the following modules:
a first obtaining module 701, configured to obtain a first training set, where the first training set includes a first original query and a first rewritten query that match the same query result;
a first pre-training module 702, configured to pre-train a rewrite pair generation model according to the first training set, where the rewrite pair generation model subjected to the pre-training is used to generate a rewrite query text for an input user query text;
a second obtaining module 703, configured to obtain a second training set, where the second training set includes a plurality of first positive samples and a plurality of first negative samples, the first positive samples include a second original query and a second rewritten query that match the same query result, and the first negative samples include a third original query and a second rewritten query that match different query results;
a second pre-training module 704, configured to pre-train a rewrite pair decision model according to the second training set, where the rewrite pair decision model subjected to the pre-training is used to determine, for the input user query text and the rewrite query text, whether the rewrite query text is the best rewrite query of the user query text, and output a determination result;
the countermeasure training module 705 is configured to perform countermeasure training on the pre-trained rewrite pair generation model and the pre-trained rewrite pair decision model according to a countermeasure training method, where the rewrite pair generation model after the countermeasure training is used to generate an optimal rewrite query text for any input user query text.
Optionally, the second pre-training module 704 includes:
a first obtaining sub-module, configured to obtain a pattern matching degree between the second rewrite query in the second training set and a preset atlas query pattern set;
the retrieval submodule is used for retrieving a preset knowledge graph according to the second rewritten query to obtain retrieval results and obtain the number of the retrieval results;
a second obtaining sub-module, configured to obtain a semantic matching degree between the second rewritten query and the second original query or the third original query;
and the pre-training sub-module is used for inputting the pattern matching degree, the number of the retrieval results and the semantic matching degree corresponding to any sample in the second training set into the rewriting and pre-training discrimination model.
Optionally, the first obtaining sub-module includes:
a first obtaining unit, configured to obtain a semantic meaning of the second rewritten query;
the generating unit is used for carrying out semantic reduction on the semantics according to the context-free grammar to generate a syntax tree;
and the matching unit is used for matching the grammar tree with a pattern tree in a preset map query pattern set and identifying the matched node proportion as the pattern matching degree between the second rewrite query and the preset map query pattern set.
Optionally, the confrontation training module 705 comprises:
a first iterative training sub-module for performing a first iterative training based on the plurality of first positive samples
Figure BDA0001935187220000221
Performing first iterative updating on the parameter theta of the pre-trained rewriting pair generation model G by utilizing a strategy gradient method;
wherein, G (y)k|y1:k-1) To overwrite the parameters, y, to be estimated when training the generative model G1:k-1Representing k-1 terms, y generated by the rewrite pair Generation model G for said second original query m inputkRepresents a third rewritten query, G (y), composed of k terms generated by rewriting the second original query m input to the generation model Gk|y1:k-1) Representing rewrite vs. Generation model G on already generated terms y1:k-1When a third rewrite query y is generatedkThe probability of (d);
Qθ(sk-1,yk) The second original query m and the third rewritten query y input by the rewritten pair discrimination model D are represented by the parameter theta of the rewritten pair generation model GkMaking the judgment of the best rewrite inquiry and outputting the judgment result, wherein sk-1Represents the state of the overwrite pair generator model G at the time k-1, and the state at the time k-1 is represented as (m, { y1, … …, yk-2 });
a first input sub-module, configured to input the second original query in the plurality of first positive samples to the rewrite pair generation model updated by the first iteration, and obtain a third rewrite query generated by the rewrite pair generation model for the second original query;
a second input sub-module, configured to input the second original query and the third rewritten query to the pre-trained rewritten pair discrimination model, so as to obtain a determination result of whether the third rewritten query is an optimal rewritten query of the second original query;
a third obtaining sub-module, configured to obtain, in the third rewritten query, a third target rewritten query whose corresponding determination result is that the third rewritten query is not the optimal rewritten query of the second original query;
a generating module, configured to generate a third training set, where the third training set includes the first positive samples and a second negative samples, where the second negative samples include the second original query and the third target rewrite query;
a second iterative training submodule for performing a pre-trained iterative training on the parameters of the re-pair discriminant model according to the third training set
Figure BDA0001935187220000234
Performing a second iterative update;
a loop training submodule, configured to perform the first iteration updating step and the second iteration updating step in a loop until the objective function converges;
wherein the objective function is:
Figure BDA0001935187220000231
wherein the content of the first and second substances,
Figure BDA0001935187220000232
Figure BDA0001935187220000233
wherein, t1:kRepresenting the first k terms, p, of the second rewritten query in the first positive sample1:kRepresenting the first k terms of the third target rewrite query in the second negative example, m representsThe second original query;
Figure BDA0001935187220000241
the parameters expressed in the rewrite pair discriminant model D are
Figure BDA0001935187220000242
In the case of (3), the rewrite pair discrimination model D pairs the second original queries m and p1:kObtaining the numerical value of the loss function when judging the optimal rewrite query;
Figure BDA0001935187220000243
the parameters expressed in the rewrite pair discriminant model D are
Figure BDA0001935187220000244
In the case of (3), the rewrite pair discrimination model D pairs the second original query m and t1:kAnd obtaining the numerical value of the loss function when the optimal rewrite query is judged.
For the embodiment of the apparatus, since it is basically similar to the embodiment of the model training method, the description is simple, and for the relevant points, refer to the partial description of the embodiment of the method.
Corresponding to the data retrieval method provided by the above embodiment of the present invention, referring to fig. 8, a structural block diagram of an embodiment of a data retrieval device of the present invention is shown, which may specifically include the following modules:
a receiving module 801, configured to receive a user query text;
an input module 802, configured to input the user query text into a pre-trained rewrite pair generation model to obtain an optimal rewrite query text;
the retrieval module 803 is configured to retrieve a preset knowledge icon according to the optimal rewritten query text to obtain a retrieval result;
wherein the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
For the device embodiment, since it is basically similar to the data retrieval method embodiment, the description is relatively simple, and for the relevant points, refer to the partial description of the method embodiment.
According to still another embodiment of the present invention, there is also provided a terminal including: a memory, a processor and a model training program stored on the memory and executable on the processor, the model training program when executed by the processor implementing the steps of the model training method according to any one of the embodiments described above.
According to still another embodiment of the present invention, there is also provided a computer-readable storage medium having a model training program stored thereon, the model training program, when executed by a processor, implementing the steps of the model training method according to any one of the above embodiments.
According to still another embodiment of the present invention, there is also provided a terminal including: a memory, a processor and a data retrieval program stored on the memory and executable on the processor, the data retrieval program when executed by the processor implementing the steps of the data retrieval method as described in the embodiments above.
According to still another embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a data retrieval program which, when executed by a processor, implements the steps in the data retrieval method of the above-described embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The model training method, the model training device, the data retrieval method, the data retrieval device, the terminal and the computer-readable storage medium provided by the invention are described in detail, specific examples are applied in the description to explain the principle and the implementation mode of the invention, and the description of the above embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (8)

1. A method of model training, comprising:
acquiring a first training set, wherein the first training set comprises a first original query and a first rewritten query which are matched with the same query result;
pre-training a rewrite pair generation model according to the first training set, wherein the pre-trained rewrite pair generation model is used for generating a rewrite query text for an input user query text;
obtaining a second training set, wherein the second training set comprises a plurality of first positive samples and a plurality of first negative samples, the first positive samples comprise a second original query and a second rewritten query which match the same query result, and the first negative samples comprise a third original query and a second rewritten query which match different query results;
pre-training a rewrite pair discrimination model according to the second training set, wherein the pre-trained rewrite pair discrimination model is used for judging whether the rewrite query text is the best rewrite query of the user query text or not and outputting a judgment result for the input user query text and the rewrite query text;
according to the method of the countermeasure training, the model for generating the rewrite pair which is trained in advance and the discrimination model for the rewrite pair which is trained in advance are subjected to the countermeasure training, and the model for generating the rewrite pair which is trained in advance is used for generating the optimal rewrite query text for any input user query text;
pre-training a discriminative model for rewrite according to the second training set, comprising:
obtaining a pattern matching degree between the second rewrite query and a preset atlas query pattern set in the second training set;
retrieving a preset knowledge graph according to the second rewrite query to obtain retrieval results, and acquiring the number of the retrieval results;
obtaining semantic matching degree between the second rewritten query and the second original query or the third original query;
and inputting the pattern matching degree, the number of the retrieval results and the semantic matching degree corresponding to any sample in the second training set into a rewriting and pre-training discriminant model.
2. The method of claim 1, wherein obtaining the pattern matching degree between the second rewritten query and a preset atlas query pattern set in the second training set comprises:
obtaining semantics of the second rewritten query;
performing semantic reduction on the semantics according to the context-free grammar to generate a syntax tree;
and matching the grammar tree with a pattern tree in a preset map query pattern set, and identifying the matched node proportion as the pattern matching degree between the second rewrite query and the preset map query pattern set.
3. A model training apparatus, comprising:
the first acquisition module is used for acquiring a first training set, wherein the first training set comprises a first original query and a first rewritten query which are matched with the same query result;
the first pre-training module is used for pre-training a rewrite pair generation model according to the first training set, and the rewrite pair generation model after the pre-training is used for generating a rewrite query text for an input user query text;
a second obtaining module, configured to obtain a second training set, where the second training set includes multiple first positive samples and multiple first negative samples, the first positive samples include a second original query and a second rewritten query that match a same query result, and the first negative samples include a third original query and a second rewritten query that match different query results;
the second pre-training module is used for pre-training a rewrite pair discrimination model according to the second training set, and the rewrite pair discrimination model after the pre-training is used for judging whether the rewrite query text is the best rewrite query of the user query text or not and outputting a judgment result for the input user query text and the rewrite query text;
the system comprises a confrontation training module, a recognition module and a recognition module, wherein the confrontation training module is used for carrying out confrontation training on the pre-trained rewriting pair generation model and the pre-trained rewriting pair discrimination model according to a confrontation training method, and the rewriting pair generation model after the confrontation training is used for generating an optimal rewriting query text for any input user query text;
the second pre-training module comprises:
a first obtaining sub-module, configured to obtain a pattern matching degree between the second rewrite query in the second training set and a preset atlas query pattern set;
the retrieval submodule is used for retrieving a preset knowledge graph according to the second rewritten query to obtain retrieval results and obtain the number of the retrieval results;
a second obtaining sub-module, configured to obtain a semantic matching degree between the second rewritten query and the second original query or the third original query;
and the pre-training sub-module is used for inputting the pattern matching degree, the number of the retrieval results and the semantic matching degree corresponding to any sample in the second training set into the rewriting and pre-training discrimination model.
4. The apparatus of claim 3, wherein the first acquisition submodule comprises:
a first obtaining unit, configured to obtain a semantic meaning of the second rewritten query;
the generating unit is used for carrying out semantic reduction on the semantics according to the context-free grammar to generate a syntax tree;
and the matching unit is used for matching the grammar tree with a pattern tree in a preset map query pattern set and identifying the matched node proportion as the pattern matching degree between the second rewrite query and the preset map query pattern set.
5. A method of data retrieval, comprising:
receiving a user query text;
inputting the user query text into a rewrite pair generation model trained according to any of claims 1-2 to obtain an optimal rewrite query text;
searching a preset knowledge graph according to the optimal rewriting query text to obtain a search result;
wherein the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
6. A data retrieval device, comprising:
the receiving module is used for receiving a user query text;
an input module for inputting the user query text into the rewrite pair generation model trained according to any of claims 1-2 to obtain an optimal rewrite query text;
the retrieval module is used for retrieving a preset knowledge graph according to the optimal rewriting query text to obtain a retrieval result;
wherein the rewrite pair generation model is used for rewriting any input user query text to generate an optimal rewrite query text.
7. A terminal, comprising: a memory, a processor and a model training program or a data retrieval program stored on the memory and executable on the processor, the model training program when executed by the processor implementing the steps of the model training method as claimed in any one of claims 1 to 2, the data retrieval program when executed by the processor implementing the steps in the data retrieval method as claimed in claim 5.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a model training program or a data retrieval program, the model training program, when executed by a processor, implementing the steps in the model training method of any one of claims 1 to 2, the data retrieval program, when executed by a processor, implementing the steps in the data retrieval method of claim 5.
CN201910005290.1A 2019-01-03 2019-01-03 Model training and data retrieval method, device, terminal and computer-readable storage medium Active CN109857845B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910005290.1A CN109857845B (en) 2019-01-03 2019-01-03 Model training and data retrieval method, device, terminal and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910005290.1A CN109857845B (en) 2019-01-03 2019-01-03 Model training and data retrieval method, device, terminal and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN109857845A CN109857845A (en) 2019-06-07
CN109857845B true CN109857845B (en) 2021-06-22

Family

ID=66893928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910005290.1A Active CN109857845B (en) 2019-01-03 2019-01-03 Model training and data retrieval method, device, terminal and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN109857845B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457567B (en) * 2019-07-08 2023-05-30 创新先进技术有限公司 Method and device for correcting errors of query terms
CN112215629B (en) * 2019-07-09 2023-09-01 百度在线网络技术(北京)有限公司 Multi-target advertisement generating system and method based on construction countermeasure sample
CN110390340B (en) * 2019-07-18 2021-06-01 暗物智能科技(广州)有限公司 Feature coding model, training method and detection method of visual relation detection model
CN110490080B (en) * 2019-07-22 2023-05-09 毕昇云(武汉)信息技术有限公司 Human body falling judgment method based on image
CN112348162B (en) * 2019-08-12 2024-03-08 北京沃东天骏信息技术有限公司 Method and device for generating a recognition model
CN112528680B (en) * 2019-08-29 2024-04-05 上海卓繁信息技术股份有限公司 Corpus expansion method and system
CN110765235B (en) * 2019-09-09 2023-09-05 深圳市人马互动科技有限公司 Training data generation method, device, terminal and readable medium
CN112860884A (en) * 2019-11-12 2021-05-28 马上消费金融股份有限公司 Method, device, equipment and storage medium for training classification model and information recognition
CN111428119A (en) * 2020-02-18 2020-07-17 北京三快在线科技有限公司 Query rewriting method and device and electronic equipment
US11816159B2 (en) 2020-06-01 2023-11-14 Yandex Europe Ag Method of and system for generating a training set for a machine learning algorithm (MLA)
CN112037181B (en) * 2020-08-12 2023-09-08 深圳大学 2D SAXS (three dimensional architecture) atlas analysis model training method and device
CN112328891B (en) * 2020-11-24 2023-08-01 北京百度网讯科技有限公司 Method for training search model, method for searching target object and device thereof
CN112465043A (en) * 2020-12-02 2021-03-09 平安科技(深圳)有限公司 Model training method, device and equipment
CN113673245A (en) * 2021-07-15 2021-11-19 北京三快在线科技有限公司 Entity identification method and device, electronic equipment and readable storage medium
CN113569011B (en) * 2021-07-27 2023-03-24 马上消费金融股份有限公司 Training method, device and equipment of text matching model and storage medium
CN114238648B (en) * 2021-11-17 2022-11-08 中国人民解放军军事科学院国防科技创新研究院 Game countermeasure behavior decision method and device based on knowledge graph
CN115438193B (en) * 2022-09-23 2023-05-16 苏州爱语认知智能科技有限公司 Training method of path reasoning model and path reasoning method

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105335391A (en) * 2014-07-09 2016-02-17 阿里巴巴集团控股有限公司 Processing method and device of search request on the basis of search engine
CN106557480A (en) * 2015-09-25 2017-04-05 阿里巴巴集团控股有限公司 Implementation method and device that inquiry is rewritten
CN107491447A (en) * 2016-06-12 2017-12-19 百度在线网络技术(北京)有限公司 Establish inquiry rewriting discrimination model, method for distinguishing and corresponding intrument are sentenced in inquiry rewriting
CN107748757A (en) * 2017-09-21 2018-03-02 北京航空航天大学 A kind of answering method of knowledge based collection of illustrative plates
CN107861954A (en) * 2017-11-06 2018-03-30 北京百度网讯科技有限公司 Information output method and device based on artificial intelligence
CN107958067A (en) * 2017-12-05 2018-04-24 焦点科技股份有限公司 It is a kind of based on without mark Automatic Feature Extraction extensive electric business picture retrieval system
CN108460085A (en) * 2018-01-19 2018-08-28 北京奇艺世纪科技有限公司 A kind of video search sequence training set construction method and device based on user journal

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9043248B2 (en) * 2012-03-29 2015-05-26 International Business Machines Corporation Learning rewrite rules for search database systems using query logs
CN106294341A (en) * 2015-05-12 2017-01-04 阿里巴巴集团控股有限公司 A kind of Intelligent Answer System and theme method of discrimination thereof and device
CN105808688B (en) * 2016-03-02 2021-02-05 百度在线网络技术(北京)有限公司 Complementary retrieval method and device based on artificial intelligence
US20180341862A1 (en) * 2016-07-17 2018-11-29 Gsi Technology Inc. Integrating a memory layer in a neural network for one-shot learning
CN108447049A (en) * 2018-02-27 2018-08-24 中国海洋大学 A kind of digitlization physiology organism dividing method fighting network based on production
CN109033390B (en) * 2018-07-27 2020-02-18 深圳追一科技有限公司 Method and device for automatically generating similar question sentences

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105335391A (en) * 2014-07-09 2016-02-17 阿里巴巴集团控股有限公司 Processing method and device of search request on the basis of search engine
CN106557480A (en) * 2015-09-25 2017-04-05 阿里巴巴集团控股有限公司 Implementation method and device that inquiry is rewritten
CN107491447A (en) * 2016-06-12 2017-12-19 百度在线网络技术(北京)有限公司 Establish inquiry rewriting discrimination model, method for distinguishing and corresponding intrument are sentenced in inquiry rewriting
CN107748757A (en) * 2017-09-21 2018-03-02 北京航空航天大学 A kind of answering method of knowledge based collection of illustrative plates
CN107861954A (en) * 2017-11-06 2018-03-30 北京百度网讯科技有限公司 Information output method and device based on artificial intelligence
CN107958067A (en) * 2017-12-05 2018-04-24 焦点科技股份有限公司 It is a kind of based on without mark Automatic Feature Extraction extensive electric business picture retrieval system
CN108460085A (en) * 2018-01-19 2018-08-28 北京奇艺世纪科技有限公司 A kind of video search sequence training set construction method and device based on user journal

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
人工智能研究的新前线:生成式对抗网络;林懿伦等;《自动化学报》;20180531;第44卷(第5期);775-792 *
融合对抗学习的因果关系抽取;冯冲等;《自动化学报》;20180531;第44卷(第5期);811-818 *

Also Published As

Publication number Publication date
CN109857845A (en) 2019-06-07

Similar Documents

Publication Publication Date Title
CN109857845B (en) Model training and data retrieval method, device, terminal and computer-readable storage medium
CN109840287B (en) Cross-modal information retrieval method and device based on neural network
CN112989005B (en) Knowledge graph common sense question-answering method and system based on staged query
IE20170201A1 (en) Neural machine translation systems
CN109933602B (en) Method and device for converting natural language and structured query language
CN106503231B (en) Search method and device based on artificial intelligence
CN104615589A (en) Named-entity recognition model training method and named-entity recognition method and device
CN112528637B (en) Text processing model training method, device, computer equipment and storage medium
CN110442880B (en) Translation method, device and storage medium for machine translation
CN110399454B (en) Text coding representation method based on transformer model and multiple reference systems
Das et al. Best of both worlds: Robust accented speech recognition with adversarial transfer learning
CN110992943B (en) Semantic understanding method and system based on word confusion network
CN113948066A (en) Error correction method, system, storage medium and device for real-time translation text
CN115544303A (en) Method, apparatus, device and medium for determining label of video
CN110516240B (en) Semantic similarity calculation model DSSM (direct sequence spread spectrum) technology based on Transformer
JP7466784B2 (en) Training Neural Networks Using Graph-Based Temporal Classification
CN113284499A (en) Voice instruction recognition method and electronic equipment
CN116881470A (en) Method and device for generating question-answer pairs
CN114528387A (en) Deep learning conversation strategy model construction method and system based on conversation flow bootstrap
CN117094325B (en) Named entity identification method in rice pest field
CN112883713A (en) Evaluation object extraction method and device based on convolutional neural network
CN111462734A (en) Semantic slot filling model training method and system
CN116702765A (en) Event extraction method and device and electronic equipment
CN113779190B (en) Event causal relationship identification method, device, electronic equipment and storage medium
CN114239555A (en) Training method of keyword extraction model and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant