Model training method, query processing method, electronic device, storage medium and computer program product
By classifying and annotating the rewritten training data according to intent, a target query rewriting model is trained, which solves the problem of insufficient flexibility in query rewriting in existing technologies, realizes query rewriting that is closer to user intent, and improves user experience and model applicability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA (CHINA) CO LTD
- Filing Date
- 2024-10-11
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies struggle to meet complex query needs when processing user queries, resulting in poor flexibility in query rewriting and a poor user experience.
By classifying and annotating the rewritten training data according to intent, a target query rewriting model is trained, and an adaptive question rewriting strategy is selected to generate target questions that closely match user intent.
It improves the flexibility of query rewriting and the applicability of the model to complex queries, thereby enhancing the user experience.
Smart Images

Figure CN121880913A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of large model technology and data query technology, and more specifically, to a model training method, a query processing method, an electronic device, a storage medium, and a computer program product. Background Technology
[0002] In artificial intelligence applications, user query needs are increasingly complex and varied. In response, language models provided by related technologies often struggle to accurately understand the user's true query intent. Specifically, some technologies paraphrase the input query, replacing some words or making minor semantic adjustments. While paraphrasing can slightly improve query accuracy, it focuses on a single information point and is only suitable for users with a clear intent to obtain specific information, failing to meet broader information retrieval needs (e.g., handling complex queries requiring a combination of information). Other technologies expand the input query by adding relevant keywords or phrases to broaden the search scope and enrich the results. However, this expansion may introduce more low-relevance information, only suitable for handling queries with ambiguous intent. This makes it difficult for users with clear intent to quickly locate the specific content they need from the search results, reducing query efficiency and resulting in a poor user experience.
[0003] Therefore, improving the flexibility of models in understanding user queries and thus enhancing their applicability to complex query scenarios has become a significant technical challenge in this field. Currently, no effective solution has been proposed to address these issues. Summary of the Invention
[0004] This application provides a model training method, a query processing method, an electronic device, a storage medium, and a computer program product to at least solve the technical problem that poor query rewriting flexibility leads to models being unable to meet complex query needs and resulting in a poor user experience.
[0005] According to one aspect of the embodiments of this application, a model training method is provided, comprising: acquiring rewritten training data; classifying the rewritten training data by intent to obtain a classification result, wherein the classification result is used to determine the question type of the rewritten training data; rewriting the rewritten training data by rewriting the classification result to obtain rewritten labeled data; and training an initial query rewriting model using the rewritten labeled data to obtain a target query rewriting model, wherein the target query rewriting model is used to rewrite the original question by adopting a question rewriting strategy corresponding to the original question to be queried in order to obtain a target question.
[0006] According to another aspect of the embodiments of this application, a query processing method is also provided, including: obtaining an original question to be queried; rewriting the original question using a question rewriting strategy corresponding to the question type of the original question to obtain a target question; and generating a target answer corresponding to the original question based on the target question.
[0007] According to another aspect of the embodiments of this application, a query processing method is also provided, comprising: obtaining a query processing request through a first application programming interface, wherein the request data carried in the query processing request includes: an original question to be queried; and returning a query processing response through a second application programming interface, wherein the response data carried in the query processing response includes: a search result for a target question and a target answer generated based on the search result, wherein the target question is obtained by query rewriting the original question using a question rewriting strategy corresponding to the question type of the original question.
[0008] According to another aspect of the embodiments of this application, a query processing method is also provided, comprising: obtaining a currently input query dialogue request, wherein the request data carried in the query dialogue request includes: the original question to be queried; responding to the query dialogue request, returning a query dialogue response, wherein the information carried in the query dialogue response includes: the search results for the target question and the target answer generated based on the search results, wherein the target question is obtained by query rewriting the original question using a question rewriting strategy corresponding to the question type of the original question; and displaying the search results and the target answer in a graphical user interface.
[0009] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the model training method or query processing method of any of the above-mentioned methods during runtime.
[0010] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to execute the model training method or query processing method of any of the above.
[0011] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the model training method or query processing method of any of the above.
[0012] In this embodiment, rewriting training data is obtained; the rewriting training data is classified according to intent to obtain classification results, wherein the classification results are used to determine the question type of the rewriting training data; the rewriting training data is labeled based on the classification results to obtain rewriting labeled data; the initial query rewriting model is trained using the rewriting labeled data to obtain a target query rewriting model, wherein the target query rewriting model is used to rewrite the original question using the question rewriting strategy corresponding to the original question to obtain the target question. Based on this, this application, by classifying the query training data according to intent and selectively labeling the rewriting training data according to the classification results, trains the target query rewriting model to adaptively select a question rewriting strategy for the original question, making the obtained target question more closely match the user's query intent.
[0013] It is noteworthy that, since different question rewriting strategies can meet users' varying needs for the accuracy and richness of query results under different circumstances, flexibly selecting a suitable question rewriting strategy enables the model to better cope with complex and ever-changing user query needs. Therefore, this application achieves the goal of training a target query rewriting model that can adaptively select a question rewriting strategy to rewrite the original question based on the intent classification result corresponding to the question type. This achieves the technical effects of improving the flexibility of query rewriting, enhancing the model's applicability to complex query needs, and improving user experience, thereby solving the technical problem of poor query rewriting flexibility leading to models being unable to meet complex query needs and resulting in a poor user experience.
[0014] It is worth noting that the general description above and the detailed description that follow are merely for illustrative purposes and do not constitute a limitation on this application. Attached Figure Description
[0015] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0016] Figure 1 This is a schematic diagram illustrating an application scenario of a model training method according to an embodiment of this application;
[0017] Figure 2 This is a flowchart of a model training method according to an embodiment of this application;
[0018] Figure 3 This is a schematic diagram of the training process of an optional target intent model according to an embodiment of this application;
[0019] Figure 4This is a schematic diagram of an optional data rewriting and annotation process according to an embodiment of this application;
[0020] Figure 5 This is a schematic diagram of an optional training loss calculation method according to an embodiment of this application;
[0021] Figure 6 This is a flowchart of a query processing method according to an embodiment of this application;
[0022] Figure 7 This is a flowchart of another query processing method according to an embodiment of this application;
[0023] Figure 8 This is a flowchart of another query processing method according to an embodiment of this application;
[0024] Figure 9 This is a schematic diagram of the structure of a model training device according to an embodiment of this application;
[0025] Figure 10 This is a schematic diagram of the structure of a query processing device according to an embodiment of this application;
[0026] Figure 11 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] The technical solution provided in this application is mainly implemented using large-scale model technology. Here, "large-scale model" refers to a deep learning model with a massive number of parameters, typically containing hundreds of millions, tens of billions, hundreds of billions, trillions, or even tens of trillions of parameters. Large-scale models are also known as foundation models. They are pre-trained using large-scale unlabeled corpora to produce pre-trained models with hundreds of millions of parameters. Such models can adapt to a wide range of downstream tasks and have good generalization ability. Examples include Large Language Models (LLMs) and multi-modal pre-training models.
[0030] It should be noted that in practical applications, large models can be fine-tuned using a small number of samples to adapt them to different tasks. For example, large models can be widely used in Natural Language Processing (NLP), computer vision, and speech processing. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as NLP tasks such as text-based sentiment classification, text summarization, and machine translation. Therefore, the main application scenarios for large models include, but are not limited to, digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design. In this embodiment, data querying using a large language model in a data query scenario is used as an example for explanation.
[0031] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows.
[0032] Large-scale language models (LLMs) are neural network models trained on large datasets that possess strong natural language understanding and generation capabilities. Applications of large-scale models include, but are not limited to, automated text creation, machine translation, text summarization, speech recognition, sentiment analysis, automated question answering, and intelligent customer service.
[0033] Retrieval-Augmented Generation (RAG) is a technique that combines the precision of information retrieval with the creativity of natural language generation. By utilizing RAG, models can retrieve more relevant information fragments when generating content, thus improving the accuracy of the generated content.
[0034] Query refining refers to the process of re-expressing or reorganizing the original query input by the user during information retrieval to improve the effectiveness and accuracy of the query.
[0035] According to an embodiment of this application, a model training method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0036] Considering the large number of model parameters in large models and the limited computing resources of mobile terminals, the model training method provided in this application can be applied to, for example, Figure 1 The application scenarios shown are not limited to these. In, for example... Figure 1 In the application scenario shown, the large model is deployed on server 10. Server 10 can connect to one or more client devices 20 via a local area network (LAN), wide area network (WAN), internet connection, or other types of data network. These client devices 20 may include, but are not limited to, smartphones, tablets, laptops, PDAs, personal computers, smart home devices, and in-vehicle devices. Client devices 20 can interact with users through a graphical user interface to access the large model, thereby implementing the method provided in this embodiment.
[0037] In this embodiment, the system consisting of a client device and a server can perform the following steps: the client device uploads rewritten training data to the server; after obtaining the rewritten training data, the server performs intent classification on the rewritten training data to obtain classification results; based on the classification results, the rewritten training data is rewritten and labeled to obtain rewritten labeled data; and the rewritten labeled data is used to train an initial query rewriting model to obtain a target query rewriting model. This target query rewriting model is used to rewrite the original question using the question rewriting strategy corresponding to the original question to obtain the target question. It should be noted that this embodiment can be performed on the client device if the client device's operating resources can meet the deployment and operation conditions of a large model.
[0038] Under the aforementioned operating environment, this application provides the following: Figure 2 The model training method shown. Figure 2 This is a flowchart of a model training method according to an embodiment of this application, such as... Figure 2 As shown, the model training method includes the following steps S21 to S24.
[0039] Step S21: Obtain the rewritten training data.
[0040] The aforementioned rewriting training data can be a dataset used to train the target query rewriting model. This training data may include multiple rewritten data samples, representing different types of user queries. Each rewritten data sample includes the user query and the corresponding rewritten result. This training data helps the target query rewriting model learn how to rewrite the original question into a target question that more closely reflects the user's true query intent.
[0041] The rewritten training data mentioned above can be obtained from query records between users and the query model. These query records can include historical data from multiple data sources, such as historical dialogue databases, user feedback tables, and query log files. When obtaining the rewritten training data, historical data from multiple data sources can be collected and organized to obtain the aforementioned multiple rewritten data samples.
[0042] Taking a smart dialogue scenario between a user and a smart assistant as an example, in one historical dialogue, the user inputs the original question, "What is the current price of product X?". When the smart assistant processes this original question, it queries and rewrites it, obtaining the rewritten result of ["Product X price", "Real-time Product X price", "Current price of Product X"]. After collection and organization, the first rewritten data sample in the rewritten training data includes the original question and the rewritten result. In another historical dialogue, the user inputs the original question, "Deeply analyze the price trend of product X". When the smart assistant processes this original question, it queries and rewrites it, obtaining the rewritten result of ["Product X", "Historical price of product X", "Future price prediction of product X", "Detailed analysis of the price fluctuation trend of product X", "Deep discussion of the price trend of product X"]. After collection and organization, the second rewritten data sample in the rewritten training data includes the original question and the rewritten result.
[0043] Step S22: Perform intent classification on the rewritten training data to obtain classification results, wherein the classification results are used to determine the question type of the rewritten training data.
[0044] The above intent classification can be a process for identifying the true query intent represented by a user's query. In application scenarios, various query intents may arise, and a question type can be defined for one query intent or multiple similar query intents.
[0045] For example, the question types mentioned above can be the forms in which the original question is presented, such as deterministic questions and open-ended questions. Deterministic questions have a unique answer, while open-ended questions have multiple answers. As another example, the question types mentioned above can also be more specific query task types defined semantically based on the original question, such as information retrieval, instruction requests, and sentiment expression.
[0046] Taking the intelligent dialogue scenario as an example, in the process of intent classification, based on the original question "What is the current price of product X?", the question type of the first rewritten data sample is determined to be a deterministic question; based on the original question "Deeply analyze the price trend of product X", the question type of the second rewritten data sample is determined to be an open question.
[0047] Step S23: Based on the classification results, rewrite the training data and add annotations to obtain the rewritten annotation data.
[0048] The aforementioned rewriting annotation can be the process of adding rewriting annotation information to the rewritten training data. This rewriting annotation information at least includes the target rewriting strategy. The aforementioned rewritten annotation data is the training data obtained after adding rewriting annotation information to the rewritten training data.
[0049] For example, for a rewritten data sample with a deterministic problem type (such as the first rewritten data sample), the added rewriting annotation information is "synonymous rewriting strategy"; for a rewritten data sample with an open-ended problem type (such as the second rewritten data sample), the added rewriting annotation information is "extended rewriting strategy". Furthermore, the above rewriting annotation information may also include the problem type corresponding to the rewritten data sample.
[0050] Step S24: Train the initial query rewriting model using the rewritten labeled data to obtain the target query rewriting model. The target query rewriting model is used to rewrite the original question using the question rewriting strategy corresponding to the original question to obtain the target question.
[0051] The initial query rewriting model described above is a predefined, untrained query rewriting model. This initial query rewriting model can be a neural network model or other machine learning model. The target query rewriting model described above is a query rewriting model obtained by training the initial query rewriting model using rewriting labeled data. Specifically, the rewriting labeled data is input into the initial query rewriting model, and the model parameters are iteratively adjusted through multiple rounds using machine learning algorithms (such as backpropagation) until the query rewriting model can effectively rewrite the original problem and obtain the expected rewriting result, thus obtaining the target query rewriting model.
[0052] The target query rewriting model described above can determine a suitable question rewriting strategy based on the original input question, and then use the question rewriting strategy to rewrite the original question into a target question and output the target question.
[0053] Taking the intelligent dialogue scenario as an example, the trained target query rewriting model can determine whether the original question to be queried is an open-ended question or a deterministic question, and whether the question rewriting strategy is an expansion rewriting strategy or a synonym rewriting strategy.
[0054] The target query rewriting model trained by the model training method provided in this application embodiment can be used to provide a pre-query rewriting function for the query processing model in preset application scenarios. This rewrites the user-inputted original question into a more standard or easier-to-understand target question, enabling the query processing model to provide more accurate and / or richer query processing results. The preset application scenarios can be, but are not limited to, scenarios involving intelligent data querying in fields such as e-commerce, education, healthcare, conferences, social networks, financial products, logistics, and navigation.
[0055] Through steps S21 to S24 above, this embodiment of the application classifies the query training data by intent and then specifically rewrites and labels the training data according to the classification results. This trains a target query rewriting model that can adaptively select a question rewriting strategy for the original question, making the resulting target question more closely match the user's query intent. Since different question rewriting strategies can meet users' varying needs for the accuracy and richness of query results under different circumstances, flexibly selecting a suitable question rewriting strategy allows the model to better cope with complex and ever-changing user query needs. Therefore, this application achieves the goal of training a target query rewriting model that can adaptively select a question rewriting strategy based on the intent classification results corresponding to the question type to rewrite the original question. This improves the flexibility of query rewriting, enhances the model's applicability to complex query needs, and improves the user experience, thus solving the technical problem of poor query rewriting flexibility leading to models that cannot meet complex query needs and poor user experience.
[0056] In an optional embodiment, step S22 involves classifying the rewritten training data to obtain a classification result, including the following method steps:
[0057] Step S221: Use the target intent classification model to classify the rewritten training data to obtain the classification result. The target intent classification model is obtained by training the initial intent classification model with the classification label data. The classification label data is obtained by labeling the classification training data.
[0058] In the above optional embodiments, a target intent classification model is used to classify the intent of the rewritten training data. Since the target intent classification model is a neural network model trained using classification labeled data (such as a large language model), the above method steps can achieve intent classification of the rewritten training data with a high degree of automation and strong natural language processing capabilities.
[0059] Through step S221 above, this embodiment of the application classifies the rewrite training data using a target intent classification model to obtain the intent category of each question. These classification results will be used for the next step of rewrite annotation, thereby achieving intent recognition of the rewrite training data. Through the above method steps, the model training method can effectively guide the learning of the query rewrite model, enabling it to rewrite more accurate and easier-to-process query statements (i.e., target questions) based on the question type and intent when processing the original questions input by users, thereby improving the model's answer quality, search efficiency, and user experience when processing user input questions.
[0060] In one optional embodiment, the model training method further includes the following method steps:
[0061] Step S251: Obtain classification training data;
[0062] Step S252: Label the classification training data to obtain the classification labeled data;
[0063] Step S253: Correct the classification labeling data to obtain corrected labeling data;
[0064] Step S254: Train the initial intent classification model using the corrected labeled data to obtain the target intent classification model.
[0065] The classification training data mentioned above may include multiple pre-collected sample questions. These sample questions may include the original question or the rewritten result obtained by querying and rewriting the original question. The multiple sample questions may correspond to multiple different question categories.
[0066] Furthermore, a large language model is used to label the classification training data, adding an intent category label to each sample question to obtain classified labeled data. This intent category label at least includes the target question category corresponding to the classified data sample. The aforementioned classified labeled data is the dataset used to train the target intent classification model. This classified labeled data may include multiple classified data samples. Each classified data sample includes a sample question and the corresponding intent category label.
[0067] Continuing with the example of intelligent dialogue, a large language model is used to classify the original question "What is the current price of product X?", determining that the target question type is a "deterministic question". This target question type is then used as the intent category label and combined with the original question to obtain the first category of data samples. As another example, a large language model is used to classify the original question "Deeply analyze the price trend of product X", determining that the target question type is an "open-ended question". This target question type is then used as the intent category label and combined with the original question to obtain the second category of data samples.
[0068] Furthermore, during the correction process of the classification labeling data, each classification data sample in the classification labeling data is reviewed and corrected. For example, if it is found that the target question category labeled for a sample question in a certain classification data sample is incorrect, the correct question category corresponding to the sample question is re-determined, and the correct question category is used as the real label to correct the classification data sample. The corrected classification data sample includes the sample question and the real label corresponding to the correct question category.
[0069] It should be noted that the corrected labeling data obtained by correcting the classification labeling data can be achieved through manual fine-grained correction, or it can be achieved automatically by using computer scripts based on predefined correction rules.
[0070] Furthermore, the corrected labeled data is input into the initial intent classification model for multiple rounds of iterative training to obtain the target intent classification model. During iterative training, the sample questions in the corrected labeled data are used as input, and the intent category label corresponding to the sample question (here referring to the corrected true label) is used as output. The model parameters of the initial intent classification model are adjusted using methods such as backpropagation to minimize the prediction error, thus obtaining the target intent classification model.
[0071] Through steps S251 to S254 above, this embodiment of the application trains a more accurate target intent classification model through high-quality data annotation and data correction. This target intent classification model can accurately identify and classify the intent categories of various questions input by users, thereby providing key support for subsequent question rewriting and query processing.
[0072] In an optional embodiment, the corrected annotation data includes: sample questions and corrected true labels. In step S254, the initial intent classification model is trained using the corrected annotation data to obtain the target intent classification model, including the following method steps:
[0073] Step S2541: Use the sample problem and the initial intent classification model to make a prediction and obtain the predicted label;
[0074] Step S2542: Calculate the first target loss based on the predicted label and the true label;
[0075] Step S2543: Adjust the model parameters of the initial intent classification model based on the first target loss to obtain the target intent classification model.
[0076] In the above optional embodiments, the corrected labeled data is input into the initial intent classification model for training, and the model parameters of the initial intent classification model are iteratively adjusted in multiple rounds until the difference between the output predicted question category and the target question category meets the preset conditions, thereby obtaining the target intent classification model.
[0077] Specifically, the sample question is input into the initial intent classification model to obtain the predicted label output by the initial intent classification model. A first loss function is used to calculate the first target loss between the predicted label and the true label corresponding to the sample question.
[0078] It should be noted that the first loss function mentioned above can be, but is not limited to, the Mean Squared Error (MSE) loss function, the Mean Absolute Error (MAE) loss function, the Cross Entropy Loss function, etc. The model parameters of the initial intent classification model are adjusted based on the first target loss to obtain the target intent classification model.
[0079] In intelligent dialogue scenarios, the training process of a target intent classification model is as follows: Figure 3 As shown, taking the training with the first category data sample from the classified label data as an example, the original question "What is the current price of product X?" is input into the Bidirectional Encoder Representations from Transformers (BERT) model to obtain a compressed vectorized language representation. Further, this language representation is input into the fully connected layer (Linear) of the intent classification model to obtain the predicted output label and its probability distribution. Figure 3 For example, for the original question "What is the price of product X now?", the model's prediction result has a 97% probability of being a deterministic question and a 3% probability of being an open-ended question. By comparing the probability distribution of the model's predictions for all samples in the training dataset with the results of manual annotation, the training loss (i.e., the first objective loss) can be calculated using the cross-entropy loss function. This allows for backpropagation to adjust the model parameters and train a target intent classification model.
[0080] Through the above steps S2541 to S2543, the embodiments of this application optimize and train the initial intent classification model to obtain a target intent classification model that can more accurately identify and classify the intent of the problem. Using the target intent classification model to classify the intent of the rewritten training data can further improve the classification accuracy of the rewritten training data, thereby helping to determine the rewritten annotation data corresponding to the rewritten training data more flexibly and accurately.
[0081] In an optional embodiment, the rewritten training data includes: actual input data and actual output data. In step S24, the initial query rewriting model is trained using the rewritten labeled data to obtain the target query rewriting model, including the following method steps:
[0082] Step S241: Use the rewritten labeled data and the initial query rewriting model to make a prediction and obtain the prediction output data. The rewritten labeled data is obtained by classifying the actual input data by intent and rewriting it.
[0083] Step S242: Calculate the second target loss based on the predicted output data and the actual output data;
[0084] Step S243: Adjust the model parameters of the initial query rewriting model according to the second target loss to obtain the target query rewriting model.
[0085] The actual input data mentioned above can be the query question entered by the user in the application scenario, and the actual output data mentioned above can be the rewritten result obtained by the large language model in the application scenario after performing effective query rewriting when processing the query question. It should be noted that when the large language model obtains a query result that satisfies the user based on the rewritten result, the query rewriting corresponding to the rewritten result is considered to be effective.
[0086] In the application scenario, after classifying and rewriting the actual input data according to intent, rewritten labeled data is obtained. This rewritten labeled data includes rewritten training data and rewritten labeling information. The rewritten labeling information is used to determine the actual problem rewriting strategy corresponding to the rewritten training data. The actual input data and the actual problem rewriting strategy are then input into the initial query rewriting model for inference, resulting in the model's predicted output data.
[0087] For example, the implementation process of rewriting annotations is as follows: Figure 4As shown, for rewriting training data, the intent classification determines whether the sample question in the training data is a deterministic question or an open question. If the sample question is a deterministic question, it is labeled with synonym rewriting (that is, the synonym rewriting strategy is used when rewriting the query of the sample question); if the sample question is an open question, it is labeled with extended rewriting (that is, the extended rewriting strategy is used when rewriting the query of the sample question).
[0088] Furthermore, based on the predicted output data and the actual output data, a second target loss is calculated using a second loss function. In multiple training rounds, the model parameters of the initial query rewriting model (or the current query rewriting model in training) are adjusted according to the second target loss corresponding to each actual input data until the second target loss is less than a preset threshold, thus obtaining the target query rewriting model.
[0089] It should be noted that the target query rewriting model described above can be trained using a Causal Language Model (CLM) training method. In the CLM training method, when the initial query rewriting model predicts the query question (considered as a sentence) corresponding to each actual input data, it considers the word to the left of the current position and predicts the next word at the current position. In other words, the predictions of the initial query rewriting model and the target query rewriting model are unidirectional.
[0090] In the CLM training method described above, the second loss function is the cross-entropy loss function. During training, the query rewriting model calculates the cross-entropy loss (i.e., the second objective loss) between the actual output data and the predicted output data, and uses this cross-entropy loss for backpropagation to adjust the model parameters. This training process is also known as the autoregressive loss training process.
[0091] It should be noted that the loss calculation in the CLM training method described above can be performed on the entire input sequence, not just a single input. That is, the query rewriting model during training can predict the predicted output sequence corresponding to the entire input sequence of the rewritten training data in one go. This predicted output sequence can be used to determine the predicted output data, and further, the loss corresponding to the entire sequence can be calculated based on this predicted output sequence and the actual output data, thereby accelerating the training speed of the target query rewriting model. Through the CLM training method, the target query rewriting model can generate fluent and grammatically correct text content (the target question in this embodiment) based on the contextual information of the original question during the prediction process.
[0092] For example, one loss calculation method in the above CLM training method is as follows: Figure 5As shown, when calculating the second objective loss during training, the next token at the current position can be predicted based on the k tokens preceding the current position. The likelihood function of the expected token (the next token in the sentence) is then maximized within the predicted token distribution to obtain the second objective loss corresponding to the current position. For example, if the k tokens preceding the current position are "What is the price of product X now?", the likelihood function can be calculated based on the predicted distribution of the next token and the actual next token "query", thus obtaining the second objective loss.
[0093] Through steps S241 to S243 described above, this embodiment of the application can intelligently rewrite the original question by training a target query rewriting model, thereby generating a more accurate and efficient target question. For example, in an intelligent dialogue scenario, query rewriting enables the chatbot to more accurately understand the user's query intent. When the user's input original question is a deterministic question, it is paraphrased, allowing the chatbot to provide more accurate query results based on the paraphrased target question. When the user's input original question is an open-ended question, it is expanded, allowing the chatbot to provide richer query results based on the expanded target question. Therefore, this embodiment of the application can flexibly select a query rewriting strategy based on the user's input original question, making it suitable for scenarios with more and more complex user query needs, thus improving the user experience.
[0094] It should be noted that when training the target query rewriting model, if the data input to the query rewriting model includes rewriting training data corresponding to multiple rounds of dialogue, the query rewriting model can also concatenate the rewriting training data according to the dialogue order of the multiple rounds of dialogue to obtain the input sequence; the query rewriting model will automatically predict the input sequence, and then complete the loss calculation and parameter adjustment based on the input.
[0095] As can be seen from the above, the model training method proposed in this application can significantly improve the flexibility of query rewriting. Specifically, by intelligently identifying the question type and adaptively selecting the question rewriting strategy, the system can transform the original question into a more accurate search statement, thereby quickly locating the most relevant results in massive amounts of information, greatly improving the efficiency and satisfaction of users in obtaining information.
[0096] Furthermore, based on the aforementioned target query rewriting model, the system's query processing generalization ability has been significantly enhanced. This is due to the extensive training of the target intent classification model, which enables the target query rewriting model to cope with various complex and ever-changing query scenarios. Whether in academic research, business analysis, or daily life, it can demonstrate excellent performance and wide applicability.
[0097] This application's embodiments also provide personalized services, customizing the query based on the specific needs and intentions of different users to ensure that the query results are both accurate and comprehensive. Through continuous iterative optimization, the system can automatically learn and adjust model parameters to cope with constantly changing usage environments, ensuring a steady improvement in model performance.
[0098] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0099] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, they can also be implemented by hardware. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM), random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0101] In the aforementioned operating environment, this application also provides, as follows: Figure 6 This illustrates a query processing method. Figure 6This is a flowchart of a query processing method according to an embodiment of this application, such as... Figure 6 As shown, the query processing method includes:
[0102] Step S61: Obtain the original question to be queried;
[0103] Step S62: Using the problem rewriting strategy corresponding to the problem type of the original problem, the original problem is queried and rewritten to obtain the target problem;
[0104] Step S63: Generate the target answer corresponding to the original question based on the target question.
[0105] The original question to be queried is a query question expressed in natural language by the user. Further, based on the question type of the original question, a question rewriting strategy is determined; this strategy is then applied to rewrite the original question to obtain the target question. Further, a query processing model (such as an intelligent chatbot, a large language model, or an intelligent assistant) performs a data query based on this target question to generate the target answer to the original question.
[0106] The question types mentioned above can be the form of the original question, such as deterministic questions and open-ended questions. Deterministic questions have a unique answer, while open-ended questions have multiple answers. Furthermore, these question types can also be more specific query task types defined semantically based on the original question, such as information retrieval, instruction requests, and sentiment expression.
[0107] Through steps S61 to S63, this embodiment of the application determines a question rewriting strategy based on the question type of the original question to be queried, further rewriting the original question to obtain a more accurate or more easily understood target question, thereby improving the accuracy of the target answer given by the model based on the target question. Since different question rewriting strategies can meet the different needs of users for the accuracy and richness of query results under different circumstances, flexibly selecting a suitable question rewriting strategy enables the model to better cope with complex and ever-changing user query needs. Therefore, this application achieves the goal of adaptively selecting a question rewriting strategy based on the question type of the original question to rewrite the original question and generate a target answer, thereby realizing the technical effects of improving the flexibility of query rewriting, enhancing the applicability of the query processing model to complex query needs, and improving user experience. This solves the technical problem of poor query rewriting flexibility leading to the model's inability to meet complex query needs and a poor user experience.
[0108] It should be noted that the preferred embodiments of steps S61 to S63 described above can be found in the foregoing description, and will not be repeated here.
[0109] In an optional embodiment, in step S62, the original question is rewritten using a question rewriting strategy corresponding to the question type of the original question to obtain the target question, including the following method steps:
[0110] Step S621: The target query rewriting model is used to obtain the question rewriting strategy corresponding to the question type of the original question, and the original question is rewritten based on the question rewriting strategy to obtain the target question. The target query rewriting model is obtained by training the initial query rewriting model with rewriting annotation data. The rewriting annotation data is obtained by performing intent classification and rewriting annotation processing on the rewriting training data.
[0111] In the above optional embodiments, the specific training method of the target query rewriting model can be referred to the explanation of the model training method in the previous text, and will not be repeated here.
[0112] In an optional embodiment, the original problem type includes: a deterministic problem. In step S621, a target query rewriting model is used to obtain the question rewriting strategy corresponding to the original problem type, and the original problem is rewritten based on the question rewriting strategy to obtain the target problem. This includes the following method steps:
[0113] Step S6211: Use the target query rewriting model to obtain the synonym rewriting strategy corresponding to the deterministic problem, and rewrite the original problem based on the synonym rewriting strategy to obtain the target problem.
[0114] In the above optional embodiments, the aforementioned deterministic question is one with a unique answer. For example, in an intelligent dialogue scenario, the original question input by the user, "What is the current price of product X?", is a deterministic question. This original question is input into the target query rewriting model, which will use a synonym rewriting strategy to rewrite the original question to obtain the target question.
[0115] It should be noted that the target question mentioned above can be a rewritten question, or it can contain one or more synonymous rewritten query keywords.
[0116] For example, if the original question "What is the current price of product X?" is input into the target query rewriting model, the target query rewriting model will use a synonym rewriting strategy to rewrite the original question. The resulting target question includes: ["Price of product X", "Real-time price of product X", "Current price of product X"]. That is, the query processing model will perform data queries based on these query keywords and generate the target answer to the original question based on the query results.
[0117] By implementing step S6211, when a user inputs a deterministic question, the deterministic question is paraphrased, enabling the query processing model to obtain more accurate query results in a more targeted manner, and providing users with more accurate target answers.
[0118] In an optional embodiment, the original question type includes: an open-ended question. In step S621, a target query rewriting model is used to obtain the question rewriting strategy corresponding to the question type of the original question, and the original question is rewritten based on the question rewriting strategy to obtain the target question. This includes the following method steps:
[0119] Step S6212: Use the target query rewriting model to obtain the expansion rewriting strategy corresponding to the open question, and expand and rewrite the original question based on the expansion rewriting strategy to obtain the target question.
[0120] In the above optional embodiments, open-ended questions are those with multiple possible answers. For example, in an intelligent dialogue scenario, the user's original question, "Deeply analyze the price trend of product X," is an open-ended question. This original question is input into the target query rewriting model, which will use an extended rewriting strategy to rewrite the original question to obtain the target question.
[0121] It should be noted that the target question mentioned above may include multiple extended and rewritten query keywords and / or multiple query sentences.
[0122] For example, if the original question "In-depth analysis of the price trend of commodity X" is input into the target query rewriting model, the target query rewriting model will use an extended rewriting strategy to rewrite the original question. The resulting target questions include: ["commodity X", "historical price of commodity X", "future price prediction of commodity X", "detailed analysis of the price fluctuation trend of commodity X", "in-depth discussion of the price trend of commodity X"]. That is, the query processing model will perform data queries based on these query keywords and generate the target answer to the original question based on the query results.
[0123] By implementing step S6212, when an open-ended question is detected by the user, the open-ended question is expanded and rewritten, so that the query processing model can obtain richer query results more comprehensively, and provide users with more comprehensive and richer target answers.
[0124] It should be noted that the above query processing method can be implemented based on the aforementioned target intent classification model and target query rewriting model. This query processing method may also include other methods and steps. For specific implementation methods, please refer to the description of the model training method in the previous text, which will not be repeated here.
[0125] In the aforementioned operating environment, this application provides the following: Figure 7 This illustrates a query processing method. Figure 7 This is a flowchart of another query processing method according to an embodiment of this application, such as... Figure 7 As shown, the query processing method includes:
[0126] Step S71: Obtain a query processing request through the first application programming interface, wherein the request data carried in the query processing request includes: the original question to be queried;
[0127] Step S72: Return the query processing response through the second application programming interface. The response data carried in the query processing response includes: the search results of the target question and the target answer generated based on the search results. The target question is obtained by rewriting the original question using the question rewriting strategy corresponding to the question type of the original question.
[0128] Based on the above steps, a method for implementing a query processing cloud service is provided, which runs on a cloud server. The cloud server obtains a query processing request from a service caller through a first application programming interface (API). Based on the original question to be queried carried in the query processing request, it executes a query processing flow to obtain search results for the target question and a target answer generated based on the search results. Further, the cloud server returns a query processing response to the service caller through a second API, providing the search results for the target question and the target answer generated based on the search results to the service caller.
[0129] Furthermore, if the client device's operating resources can meet the training, deployment, and operation conditions of a large model, the query processing method described in this application embodiment can also be performed on the client device to provide local query processing services to customers.
[0130] Through the above steps S71 to S72, the embodiments of this application can flexibly rewrite the original question during the query processing through the application programming interface. It is applicable to scenarios that need to be integrated into existing data query systems, intelligent question answering systems, or query processing systems, such as enterprise internal customer service systems, online education platforms, etc. It can smoothly connect the query processing method to the above systems, improve the query processing quality of the system, and enhance the user experience.
[0131] It should be noted that the preferred embodiments of steps S71 to S72 described above can be found in the relevant descriptions in the foregoing embodiments, and will not be repeated here.
[0132] In the aforementioned operating environment, this application provides the following: Figure 8 This illustrates a query processing method. Figure 8This is a flowchart of another query processing method according to an embodiment of this application, such as... Figure 8 As shown, the query processing method includes:
[0133] Step S81: Obtain the currently input query dialogue request, wherein the request data carried in the query dialogue request includes: the original question to be queried;
[0134] Step S82: In response to the query dialogue request, return the query dialogue response, wherein the information carried in the query dialogue response includes: the search results of the target question and the target answer generated based on the search results. The target question is obtained by rewriting the original question using the question rewriting strategy corresponding to the question type of the original question.
[0135] Step S83: Display the search results and target response within the graphical user interface.
[0136] Based on the above method steps, a visualization scheme for query processing functions is provided. The terminal device provides a graphical user interface (GUI), which displays at least one query processing scenario. The GUI display content also includes input components (such as text input boxes, voice input controls, etc.) and display components (such as text display windows). The user inputs a query processing dialog request through the input components to specify the original question to be queried in the query processing task. After detecting the user's input behavior, the query processing flow is executed based on the original question to be queried, obtaining the search results for the target question and the target answer generated based on the search results. Furthermore, the search results and the target answer are displayed through the display components within the GUI.
[0137] In this embodiment, a question rewriting strategy is determined based on the question type of the original question to be queried. The original question is then further rewritten to obtain a more accurate or more easily understood target question, thereby improving the accuracy of the target answer provided by the model based on the target question. Since different question rewriting strategies can meet users' varying needs for the accuracy and richness of query results under different circumstances, flexibly selecting a suitable question rewriting strategy allows the model to better cope with complex and ever-changing user query needs. Therefore, this application achieves the goal of adaptively selecting a question rewriting strategy based on the question type of the original question to rewrite the original question and generate a target answer. This achieves the technical effects of improving the flexibility of query rewriting, enhancing the applicability of the query processing model to complex query needs, and improving user experience. It also solves the technical problem of poor query rewriting flexibility leading to the model's inability to meet complex query needs and a poor user experience.
[0138] It should be noted that the preferred embodiments of steps S81 to S83 described above can be found in the relevant descriptions in the foregoing embodiments, and will not be repeated here.
[0139] According to an embodiment of this application, an apparatus embodiment for implementing the above-described model training method is also provided. Figure 9 This is a schematic diagram of a model training device according to an embodiment of this application, as shown below. Figure 9 As shown, the device includes: an acquisition module 901 for acquiring rewriting training data; a classification module 902 for classifying the rewriting training data by intent to obtain a classification result, wherein the classification result is used to determine the question type of the rewriting training data; an annotation module 903 for annotating the rewriting training data based on the classification result to obtain rewriting annotation data; and a training module 904 for training an initial query rewriting model using the rewriting annotation data to obtain a target query rewriting model, wherein the target query rewriting model is used to rewrite the original question using the question rewriting strategy corresponding to the original question to obtain the target question.
[0140] Optionally, the classification module 902 is further configured to: classify the rewritten training data using a target intent classification model to obtain a classification result, wherein the target intent classification model is obtained by training the initial intent classification model using classification label data, and the classification label data is obtained by labeling the classification training data.
[0141] Optionally, the classification module 902 is further configured to: acquire classification training data; label the classification training data to obtain classification labeled data; correct the classification labeled data to obtain corrected labeled data; and train the initial intent classification model using the corrected labeled data to obtain the target intent classification model.
[0142] Optionally, the corrected labeled data includes: the sample question and the corrected real label. The classification module 902 is also used to: make a prediction using the sample question and the initial intent classification model to obtain the predicted label; calculate the first target loss based on the predicted label and the real label; and adjust the model parameters of the initial intent classification model according to the first target loss to obtain the target intent classification model.
[0143] Optionally, the rewritten training data includes: actual input data and actual output data. The classification module 902 is further used to: make predictions using the rewritten labeled data and the initial query rewriting model to obtain predicted output data, wherein the rewritten labeled data is obtained by performing intent classification and rewriting labeling on the actual input data; calculate the second target loss based on the predicted output data and the actual output data; and adjust the model parameters of the initial query rewriting model according to the second target loss to obtain the target query rewriting model.
[0144] It should be noted that the above-mentioned acquisition module 901, classification module 902, annotation module 903 and training module 904 correspond to steps S21 to S24 in the embodiments. The four modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiments.
[0145] According to an embodiment of this application, an apparatus embodiment for implementing the query processing method in the above embodiments is also provided. Figure 10 This is a schematic diagram of the structure of a query processing method according to an embodiment of this application, such as... Figure 10 As shown, the device includes: an acquisition module 1001, used to acquire the original question to be queried; a rewriting module 1002, used to rewrite the original question using a question rewriting strategy corresponding to the question type of the original question, to obtain the target question; and a generation module 1003, used to generate the target answer corresponding to the original question based on the target question.
[0146] Optionally, the above-mentioned rewriting module 1002 is further configured to: obtain the question rewriting strategy corresponding to the question type of the original question using the target query rewriting model, and perform query rewriting on the original question based on the question rewriting strategy to obtain the target question, wherein the target query rewriting model is obtained by training the initial query rewriting model using rewriting annotation data, and the rewriting annotation data is obtained by performing intent classification and rewriting annotation processing on the rewriting training data.
[0147] Optionally, the original problem type includes: a deterministic problem. The rewriting module 1002 is further used to: obtain the synonym rewriting strategy corresponding to the deterministic problem using the target query rewriting model, and rewrite the original problem synonymously based on the synonym rewriting strategy to obtain the target problem.
[0148] Optionally, the original question type includes: open-ended questions. The rewriting module 1002 is further used to: obtain the extended rewriting strategy corresponding to the open-ended question using the target query rewriting model, and extend and rewrite the original question based on the extended rewriting strategy to obtain the target question.
[0149] It should be noted that the above-mentioned acquisition module 1001, rewriting module 1002 and generation module 1003 correspond to the aforementioned steps S61 to S63. The three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments.
[0150] According to an embodiment of this application, another embodiment of a query processing device is also provided. The query processing device includes: a request module, configured to obtain a query processing request through a first application programming interface, wherein the request data carried in the query processing request includes: the original question to be queried; and a response module, configured to return a query processing response through a second application programming interface, wherein the response data carried in the query processing response includes: the search results for the target question and the target answer generated based on the search results, wherein the target question is obtained by query rewriting the original question using a question rewriting strategy corresponding to the question type of the original question.
[0151] According to an embodiment of this application, another embodiment of a query processing device is also provided. The query processing device includes: an acquisition module, configured to acquire a currently input query dialogue request, wherein the request data carried in the query dialogue request includes: the original question to be queried; a response module, configured to respond to the query dialogue request and return a query dialogue response, wherein the information carried in the query dialogue response includes: the search results for the target question and a target answer generated based on the search results, wherein the target question is obtained by rewriting the original question using a question rewriting strategy corresponding to the question type of the original question; and a display module, configured to display the search results and the target answer within a graphical user interface.
[0152] It should be noted that the above-mentioned modules or units may be hardware or software components stored in memory and processed by one or more processors. The above-mentioned modules may also be part of a device and run in a computer terminal.
[0153] It should be noted that the preferred implementation of this embodiment can be found in the relevant descriptions of the foregoing embodiments, and will not be repeated here.
[0154] According to an embodiment of this application, an electronic device is also provided, which can be any terminal device in a group of computer terminals. Optionally, in this embodiment, the above-mentioned electronic device can also be replaced by a mobile terminal or other terminal device.
[0155] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0156] In this embodiment, the above-mentioned electronic device can execute the program code of the following steps in the model training method: acquiring rewritten training data; classifying the rewritten training data by intent to obtain a classification result, wherein the classification result is used to determine the question type of the rewritten training data; rewriting the rewritten training data based on the classification result to obtain rewritten labeled data; and training the initial query rewriting model using the rewritten labeled data to obtain a target query rewriting model, wherein the target query rewriting model is used to rewrite the original question by adopting the question rewriting strategy corresponding to the original question to obtain the target question.
[0157] In this embodiment, the above-mentioned electronic device can execute the program code of the following steps in the query processing method: obtain the original question to be queried; use the question rewriting strategy corresponding to the question type of the original question to query and rewrite the original question to obtain the target question; generate the target answer corresponding to the original question based on the target question.
[0158] Optionally, Figure 11 This is a structural block diagram of an electronic device according to an embodiment of this application, such as... Figure 11 As shown, the electronic device 110 may include: one or more (only one is shown in the figure) processors 1102, memory 1104, memory controller 1106, and peripheral interface 1108, wherein the peripheral interface 1108 is connected to a radio frequency module, an audio module, and a display.
[0159] The memory 1104 can be used to store software programs and modules, such as the program instructions / modules corresponding to the model training method, query processing method, model training device, and query processing device in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the aforementioned model training method and / or query processing method. The memory 1104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the electronic device 110 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0160] The processor 1102 can invoke information and application programs stored in the memory via the transmission device to perform the following steps: acquiring rewriting training data; classifying the rewriting training data by intent to obtain a classification result, wherein the classification result is used to determine the question type of the rewriting training data; rewriting the rewriting training data by rewriting based on the classification result to obtain rewriting labeled data; and training an initial query rewriting model using the rewriting labeled data to obtain a target query rewriting model, wherein the target query rewriting model is used to rewrite the original question by adopting the question rewriting strategy corresponding to the original question to obtain the target question.
[0161] The processor 1102 can call the information and application program stored in the memory through the transmission device to perform the following steps: obtain the original question to be queried; use the question rewriting strategy corresponding to the question type of the original question to query and rewrite the original question to obtain the target question; generate the target answer corresponding to the original question based on the target question.
[0162] This application provides an electronic device solution for implementing the aforementioned model training method and / or query processing method. By classifying query training data according to intent, and specifically rewriting and labeling the training data based on the classification results, the target query rewriting model is trained to adaptively select a question rewriting strategy for the original question, making the resulting target question more closely match the user's query intent. Since different question rewriting strategies can meet users' varying needs for the accuracy and richness of query results under different circumstances, flexibly selecting a suitable question rewriting strategy allows the model to better cope with complex and ever-changing user query needs. Therefore, this application achieves the goal of training a target query rewriting model that can adaptively select a question rewriting strategy based on the intent classification results corresponding to the question type to rewrite the original question. This improves the flexibility of query rewriting, enhances the model's applicability to complex query needs, and improves the user experience, thus solving the technical problem of poor query rewriting flexibility leading to models failing to meet complex query needs and poor user experience.
[0163] Those skilled in the art will understand that Figure 11 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, and mobile internet devices (MIDs) and other terminal devices. Figure 11 This does not limit the structure of the aforementioned electronic device. For example, electronic device 110 may also include components that are more... Figure 11 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 11 The different configurations shown.
[0164] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.
[0165] According to an embodiment of this application, a computer-readable storage medium is also provided. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the model training method and / or query processing method provided in the above embodiments.
[0166] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0167] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: acquiring rewrite training data; classifying the rewrite training data by intent to obtain a classification result, wherein the classification result is used to determine the question type of the rewrite training data; rewriting the rewrite training data based on the classification result to obtain rewrite labeled data; and training an initial query rewrite model using the rewrite labeled data to obtain a target query rewrite model, wherein the target query rewrite model is used to rewrite the original question using a question rewrite strategy corresponding to the original question to obtain the target question.
[0168] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: obtaining the original question to be queried; rewriting the original question using a question rewriting strategy corresponding to the question type of the original question to obtain the target question; and generating a target answer corresponding to the original question based on the target question.
[0169] Embodiments of this application also provide a computer program product. Optionally, in this embodiment, the computer program product may include a computer program that, when executed by a processor, implements the methods provided in the embodiments described above.
[0170] Embodiments of this application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which can be used to store a computer program that, when executed by a processor, implements the method provided in the above embodiments.
[0171] Embodiments of this application also provide a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, it implements the method provided in the above embodiments.
[0172] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0173] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0174] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0175] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0176] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, ROM, RAM, portable hard drives, magnetic disks, or optical disks.
[0177] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A model training method, characterized in that, include: Obtain and rewrite the training data; The rewritten training data is subjected to intent classification to obtain a classification result, wherein the classification result is used to determine the question type of the rewritten training data; Based on the classification results, the rewritten training data is rewritten and labeled to obtain rewritten labeled data. The initial query rewriting model is trained using the rewritten annotation data to obtain the target query rewriting model. The target query rewriting model is used to rewrite the original question using the question rewriting strategy corresponding to the original question to obtain the target question.
2. The model training method according to claim 1, characterized in that, The rewritten training data is subjected to intent classification to obtain the classification results, including: The rewritten training data is classified using a target intent classification model to obtain the classification result. The target intent classification model is obtained by training an initial intent classification model using classification label data, and the classification label data is obtained by labeling the classification training data.
3. The model training method according to claim 2, characterized in that, The model training method also includes: Obtain the classification training data; The classification training data is labeled to obtain the classification labeled data; The classification labeling data is corrected to obtain corrected labeling data; The initial intent classification model is trained using the corrected labeled data to obtain the target intent classification model.
4. The model training method according to claim 3, characterized in that, The corrected annotation data includes: sample questions and corrected ground truth labels. The initial intent classification model is trained using the corrected annotation data to obtain the target intent classification model, which includes: The predicted label is obtained by using the sample question and the initial intent classification model; Calculate the first target loss based on the predicted label and the true label; The model parameters of the initial intent classification model are adjusted based on the first target loss to obtain the target intent classification model.
5. The model training method according to any one of claims 1 to 4, characterized in that, The rewritten training data includes: actual input data and actual output data. The initial query rewriting model is trained using the rewritten annotation data to obtain the target query rewriting model, which includes: The rewritten annotation data and the initial query rewriting model are used to make predictions to obtain predicted output data, wherein the rewritten annotation data is obtained by performing intent classification and rewriting annotation on the actual input data; Calculate the second target loss based on the predicted output data and the actual output data; The model parameters of the initial query rewriting model are adjusted based on the second target loss to obtain the target query rewriting model.
6. A query processing method, characterized in that, include: Retrieve the original question to be queried; Using the problem rewriting strategy corresponding to the problem type of the original problem, the original problem is queried and rewritten to obtain the target problem; Generate a target answer corresponding to the original question based on the target question.
7. The query processing method according to claim 6, characterized in that, Using the problem rewriting strategy corresponding to the problem type of the original problem, the original problem is queried and rewritten to obtain the target problem, which includes: A target query rewriting model is used to obtain the question rewriting strategy corresponding to the question type of the original question, and the original question is rewritten based on the question rewriting strategy to obtain the target question. The target query rewriting model is obtained by training an initial query rewriting model with rewriting annotation data, and the rewriting annotation data is obtained by performing intent classification and rewriting annotation processing on the rewriting training data.
8. The query processing method according to claim 7, characterized in that, The original problem types include: deterministic problems. The target query rewriting model is used to obtain the question rewriting strategy corresponding to the question type of the original problem, and the original problem is rewritten based on the question rewriting strategy to obtain the target problem, which includes: The target query rewriting model is used to obtain the synonym rewriting strategy corresponding to the deterministic problem, and the original problem is rewritten using the synonym rewriting strategy to obtain the target problem.
9. The query processing method according to claim 7, characterized in that, The original question types include: open-ended questions. The target query rewriting model is used to obtain the question rewriting strategy corresponding to the question type of the original question, and the original question is rewritten based on the question rewriting strategy to obtain the target question, which includes: The target query rewriting model is used to obtain the extended rewriting strategy corresponding to the open question, and the original question is extended and rewritten based on the extended rewriting strategy to obtain the target question.
10. A query processing method, characterized in that, include: A query processing request is obtained through a first application programming interface, wherein the request data carried in the query processing request includes: the original question to be queried; The query processing response is returned through the second application programming interface. The response data carried in the query processing response includes: the search results of the target question and the target answer generated based on the search results. The target question is obtained by query rewriting the original question using the question rewriting strategy corresponding to the question type of the original question.
11. A query processing method, characterized in that, include: Obtain the currently input query dialogue request, wherein the request data carried in the query dialogue request includes: the original question to be queried; In response to the query dialogue request, a query dialogue response is returned, wherein the information carried in the query dialogue response includes: the search results for the target question and the target answer generated based on the search results. The target question is obtained by querying and rewriting the original question using a question rewriting strategy corresponding to the question type of the original question. The search results and the target response are displayed within a graphical user interface.
12. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, executes the model training method according to any one of claims 1 to 5 or the query processing method according to any one of claims 6 to 11.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device where the computer-readable storage medium is located to perform the model training method according to any one of claims 1 to 5 or the query processing method according to any one of claims 6 to 11.
14. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the model training method according to any one of claims 1 to 5 or the query processing method according to any one of claims 6 to 11.