Request to rewrite methods, apparatus, devices and computer storage media
By identifying rewriting categories and training models using positive and negative samples, the problem of inaccurate search requests in e-commerce platforms was solved, improving the accuracy of information retrieval and product search, and increasing conversion rates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG TMALL TECH CO LTD
- Filing Date
- 2026-01-23
- Publication Date
- 2026-05-26
AI Technical Summary
In e-commerce platforms, user search requests often contain spelling errors, colloquial expressions, and significant semantic gaps and ambiguities between standard product descriptions, leading to inaccurate search results and impacting product conversion rates.
By acquiring information query requests, determining their rewriting categories, and filtering positive and negative rewriting samples based on the rewriting categories for model training, a request rewriting model is obtained. This model is then used to rewrite the original search request, generating a rewritten request for information querying.
This improved the accuracy and reliability of information retrieval operations and the accuracy of product search results, thereby increasing product conversion rates.
Smart Images

Figure CN122086964A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing technology, and in particular to a request rewriting method, apparatus, device, and computer storage medium. Background Technology
[0002] In e-commerce platforms, users can search for products to quickly find their desired items. However, user-entered search terms often contain spelling errors, significant semantic gaps between colloquial expressions and standardized product descriptions, and ambiguous intent (e.g., "gift for girlfriend"). Therefore, directly using user-entered search terms for information retrieval can easily lead to inaccurate search results, which in turn affects product conversion rates. Summary of the Invention
[0003] This application provides a request rewriting method, apparatus, device, and computer storage medium, which can improve the accuracy and reliability of information query operations to a certain extent when performing information queries based on the rewritten request.
[0004] In a first aspect, embodiments of the present invention provide a request rewriting method, comprising: Obtain an information query request used to perform model training operations; Determine the rewrite category to which the information query request belongs; Based on the rewriting category, determine the positive rewriting samples and negative rewriting samples corresponding to the information query request; Based on the information query request, the positive rewrite sample, and the negative rewrite sample, a model is trained to obtain a request rewrite model; The request rewriting model is used to perform request rewriting operations.
[0005] In a second aspect, embodiments of the present invention provide a request rewrite apparatus, comprising: The first acquisition module is used to acquire information query requests; The first determining module is used to determine the rewrite category to which the information query request belongs; The first determining module is further configured to determine, based on the rewriting category, the positive rewriting sample and the negative rewriting sample corresponding to the information query request; The first processing module is used to train a model based on the information query request, the positive rewrite sample and the negative rewrite sample to obtain a request rewrite model. The first processing module is also used to perform request rewriting operations using the request rewriting model.
[0006] Thirdly, embodiments of the present invention provide an electronic device, including: a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method in the first aspect described above.
[0007] Fourthly, embodiments of the present invention provide a computer storage medium for storing a computer program, which, when executed by a computer, implements the method described in the first aspect above.
[0008] Fifthly, embodiments of the present invention provide a computer program product, comprising: a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, cause one or more processors to perform the steps of the method described in the first aspect.
[0009] The request rewriting method, apparatus, device, and computer storage medium provided in this embodiment obtain an information query request for model training operations, determine the rewriting category to which the information query request belongs, and then determine the positive and negative rewriting samples corresponding to the information query request based on the rewriting category. This ensures the accuracy and reliability of the sample data determination to a certain extent. Then, based on the information query request, the selected positive and negative rewriting samples, model training is performed to obtain a request rewriting model, thereby effectively ensuring the quality and effect of the model training operation. After obtaining the request rewriting model, the search request to be processed can be analyzed and processed based on the request rewriting model to obtain the rewritten request. When performing information query operations based on the rewritten request, the accuracy and reliability of the information query operation can be improved. Specifically, when the original search request is a product search request, and a product search is performed based on the rewritten request, the accuracy of the product search results can be improved to a certain extent, which is conducive to improving the product conversion rate and further enhancing the practicality of the request rewriting method. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A schematic diagram illustrating a scenario of a request rewriting method provided for an exemplary embodiment of this application; Figure 2 A flowchart illustrating a request rewriting method provided for an exemplary embodiment of this application; Figure 3 A flowchart illustrating an exemplary embodiment of this application for determining positive and negative rewrite samples corresponding to the information query request based on the rewrite category. Figure 1 ; Figure 4 A flowchart illustrating an exemplary embodiment of this application for determining positive and negative rewrite samples corresponding to the information query request based on the rewrite category. Figure 2 ; Figure 5 A schematic diagram illustrating the principle of the training data construction stage provided for an exemplary embodiment of this application; Figure 6 A schematic diagram illustrating the principle of a two-stage model training phase provided in an exemplary application embodiment of this application; Figure 7 A schematic diagram illustrating the principle of the application stage of the model provided in an exemplary application embodiment of this application; Figure 8 A schematic diagram of a request rewriting device provided for an exemplary embodiment of this application; Figure 9 A schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application. Detailed Implementation
[0011] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0012] It should be noted that, in the case of user information involved in the embodiments of this application, 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 the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0013] The various models involved in this application (including but not limited to language models or large models) comply with relevant laws and standards. Furthermore, the technical solutions provided in the embodiments of this application can employ deep learning models with relatively large parameter scales. The large model is merely an example, and the embodiments of this application do not limit the number of model parameters supported by the deep learning model used, aiming to meet actual needs. The deep learning models involved in the embodiments of this application can be artificial intelligence-based language models (LM) or multimodal models (MM).
[0014] Additionally, it should be noted that when user interaction operations or triggering operations are involved in the embodiments of this application, these operations include, but are not limited to, various interaction methods such as touch operations, gesture operations, voice operations, head movement operations, and eye movement operations. Touch operations include, but are not limited to, click operations, double-click operations, long-press operations, swipe operations, pinch operations, or mouse hover operations. Swipe operations include, but are not limited to, straight-line swipes and curved-line swipes.
[0015] To facilitate understanding of the request rewriting method, apparatus, device, and computer storage medium provided in the embodiments of this application, the relevant technologies are briefly described below: In e-commerce platforms, users can search for products to quickly find their desired items. However, user-entered search terms often contain spelling errors, significant semantic gaps between colloquial expressions and standardized product descriptions, and ambiguous intent (e.g., "gift for girlfriend"). Therefore, directly using user-entered search terms for information retrieval can easily lead to inaccurate search results, which in turn affects product conversion rates.
[0016] To ensure the quality and effectiveness of information retrieval operations, related technologies provide a solution that rewrites the user's input search terms, and then performs a search based on the rewritten request. Specifically: Implementation Method 1: A scheme for rewriting query-to-query (Q2Q) terms based on semantic similarity.
[0017] The rewritten search terms are obtained by calculating the vector similarity between queries. However, the rewritten search terms are constrained by the query patterns that have appeared in the past. The rewritten search terms are often highly similar to the original search terms. It is not easy to perform appropriate rewriting operations for long-tail and complex queries. These problems make it difficult to produce results with more incremental value and diversity.
[0018] For example, after rewriting the original search terms using vector similarity, by rewriting the user's input search terms, we can obtain the following data pairs consisting of the original search terms and the rewritten search terms. Specifically, these can include <Men's Valentine's Day Gift, Men's Valentine's Day Gift | Valentine's Day Gift for Boyfriend | Men's Valentine's Day Gift>, <Women's Pants Suitable for Plus-Size Women, Women's Pants for Plus-Size Women | Plus-Size Women's Pants | New 2025 Women's Pants for Plus-Size Women>, etc.
[0019] However, the above rewriting operation does not have a significant effect on rewriting the requested search terms. Thus, when information is retrieved based on the rewritten search terms, the actual incremental effect on recall is limited.
[0020] Implementation Method 2: Request rewriting operation based on Large Language Model (LLM).
[0021] After obtaining the user's input search term Query, the LLM model can be used to rewrite the search term Query to obtain the rewritten search term Query.
[0022] However, existing LLM models are often obtained by training the model using only positive samples and supervised fine-tuning (SFT). In this case, the LLM obtained after model training lacks the ability to distinguish negative samples (i.e. error rewriting operations), and thus cannot optimize the diversity and preference of the generated results, which reduces user experience efficiency and platform conversion rate.
[0023] To address the aforementioned technical problems, embodiments of this application provide a method, apparatus, device, and computer storage medium for request rewriting, as detailed in the appendix. Figure 1As shown, the execution entity of this request rewriting method can be a request rewriting device 200, which can be implemented as a local server, a cloud server, or an edge server. Specifically, when the request rewriting device 200 is implemented as a cloud server, the request rewriting method can be executed in the cloud. Several computing nodes (cloud servers) can be deployed in the cloud, each with computing, storage, and other processing resources. In the cloud, multiple computing nodes can be organized to provide a certain service; of course, a single computing node can also provide one or more services. The cloud can provide this service by providing a service interface, which users call to use the corresponding service. Service interfaces include Software Development Kits (SDKs), Application Programming Interfaces (APIs), and other forms.
[0024] The request rewriting device 200 is communicatively connected to the client 100, which is used by the user to trigger the request rewriting operation. The client 100 can be any computing device with some information interaction capability; specifically, it can be a mobile phone, a personal computer (PC), a tablet computer, a configuration application, etc. Furthermore, the basic structure of the client 100 may include at least one processor. The number of processors depends on the client's configuration and type. The client 100 may also include memory, which can be volatile, such as Random Access Memory (RAM), or non-volatile, such as Read-Only Memory (ROM), flash memory, etc., or both types. The memory typically stores the operating system (OS), one or more applications, and may also store program data. In addition to the processing unit and memory, the client 100 also includes some basic configurations, such as a network interface card (NIC) chip, an I / O bus, a display component, and some peripheral devices. Optionally, some peripheral devices may include, for example, a keyboard, a mouse, a stylus, a printer, etc. Other peripheral devices are well known in the art and will not be described in detail here.
[0025] The request rewrite device 200 refers to a device capable of performing request rewrite operations in a network virtual environment, typically referring to a device that utilizes a network for information planning and request rewrite operations. Specifically, the request rewrite device 200 can be a request rewrite model used to implement request rewrite operations. Physically, the request rewrite device 200 can be any device capable of providing computing services and performing corresponding request rewrite operations, such as a processor, server, etc. The request rewrite device 200 mainly comprises a processor, hard disk, memory, system bus, etc., and its architecture is similar to that of a general-purpose computer.
[0026] In the above embodiment, a network connection is established between the request rewriting device 200 and the client 100. This network connection can be a wireless or wired network connection. If the request rewriting device 200 and the client 100 are connected via communication, the mobile network standard can be any one of 2G (Global System for Mobile Communications GSM), 2.5G (General Packet Radio Service GPRS), 3G (Wideband Code Division Multiple Access (WCDMA), Time Division Synchronous Code Division Multiple Access (TD-SCDMA), 4G (Long Term Evolution LTE), 4G+ (Enhanced Long Term Evolution LTE+), Global Microwave Access Interoperability (WiMax), 5G, 6G, etc.
[0027] In this embodiment of the application, the client 100 is used for users to apply the application to generate an original search request for triggering a request rewriting operation. The original search request can be generated based on human-computer interaction. In order to realize the request rewriting operation, the original search request can be sent to the request rewriting device 200 so that the request rewriting device 200 can perform a corresponding request rewriting operation based on the original search request.
[0028] The request rewriting device 200 is used to obtain the original search request sent by the client 100 and call the request rewriting model to perform a request rewriting operation on the original search request. Specifically, the original search request can be sent to the request rewriting model for request rewriting operation, so as to obtain the rewritten request output by the request rewriting model. The semantic similarity between the rewritten request and the original search request is greater than or equal to a preset threshold, and the rewritten request and the original search request have textual differences.
[0029] The aforementioned request rewriting model can be obtained based on model training operations. To enable model training and ensure its quality and effectiveness, information query requests used for training can be acquired first. These requests can be historical information query requests. Furthermore, since different information query requests can correspond to different rewriting categories, and these categories directly affect the selection of sample data for model training, the rewriting category can be determined after acquiring the request. This category can include at least one of the following: synonymous rewriting category, semantic rewriting category, or no-rewriting category. The synonymous rewriting category is used for synonymous rewriting of the information query request, the semantic rewriting category is used for semantic generalization rewriting of the information query request, and the no-rewriting category does not require rewriting the information query request.
[0030] After determining the rewriting category to which the information query request belongs, positive and negative rewriting samples corresponding to the information query request can be determined based on the rewriting category. Then, model training can be performed based on the information query request, positive and negative rewriting samples to obtain a request rewriting model for implementing the request rewriting operation. The request rewriting operation can then be performed based on the request rewriting model to obtain the rewritten request, which can be transmitted to client 100. Client 100 can then perform the information query operation based on the rewritten request, thus ensuring the quality and effectiveness of the information query operation.
[0031] In this embodiment, when the original search request is a product search request, the conversion rate of products can be improved to a certain extent when searching for products based on the rewritten request. In addition, since the request rewriting model is obtained by training on positive and negative rewritten samples corresponding to the information query request, and the positive and negative rewritten samples are determined based on the rewriting category to which the information query request belongs, the accuracy and reliability of the sample data determination are guaranteed. Subsequently, when the model is trained based on the positive and negative rewritten samples, the quality and effect of the model training operation can be effectively guaranteed, further improving the practicality of the request rewriting method.
[0032] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0033] Figure 2 A flowchart illustrating a request rewriting method provided as an exemplary embodiment of this application; see attached diagram. Figure 2As shown, this embodiment provides a request rewriting method. The execution subject of this method is a request rewriting device, which can be implemented as software or a combination of software and hardware. When the request rewriting device is implemented as hardware, it can specifically be various electronic devices capable of performing request rewriting operations. In some instances, the request rewriting device can be implemented as an application, server, cloud server, etc. When the request rewriting device is implemented as software, it can be installed in the electronic devices exemplified above. Specifically, the request rewriting method provided in this embodiment can include: Step S201: Obtain an information query request for implementing model training operations.
[0034] Step S202: Determine the rewrite category to which the information query request belongs.
[0035] Step S203: Based on the rewriting category, determine the positive rewriting samples and negative rewriting samples corresponding to the information query request.
[0036] Step S204: Train the model based on the information query request, positive rewrite samples and negative rewrite samples to obtain the request rewrite model.
[0037] Step S205: Perform a request rewrite operation using the request rewrite model.
[0038] The specific implementation methods and principles of each of the above steps are explained in detail below: Step S201: Obtain an information query request for implementing model training operations.
[0039] To improve the quality and effectiveness of information retrieval when a user performs an information query, the original search request can be rewritten. To further ensure the quality of this rewriting process, a request rewriting model can be trained to implement the rewriting operation. To train this model, information query requests can be obtained. These requests can be historical search requests, accessed through a pre-defined database or region; alternatively, they can be search requests entered via human-computer interaction at the current moment.
[0040] Furthermore, for information query requests, different application scenarios can correspond to different types of information query requests. For example, in e-commerce application scenarios, information query requests can be product search requests; in article application scenarios, information query requests can be article search requests; in image application scenarios, information query requests can be image search requests, and so on. Those skilled in the art can flexibly configure or adjust information query requests according to specific application scenarios.
[0041] Step S202: Determine the rewrite category to which the information query request belongs.
[0042] Since information query requests can have different forms of expression or include different search keywords, different information query requests can correspond to different rewriting categories. The rewriting category can include at least one of the following: synonym rewriting category, semantic rewriting category, and no rewriting category. The above-mentioned synonym rewriting category is used to perform synonym rewriting operations on information query requests, the semantic rewriting category is used to perform semantic generalization rewriting operations on information query requests, and the no-rewriting category does not require any rewriting operation on information query requests.
[0043] For example, in e-commerce applications, when the information query request is "good-looking pants", after analyzing and identifying the information query request, it can be determined that the rewriting category of the above information query request belongs to the "synonymous rewriting category"; when the information query request is "Valentine's Day gift for girlfriend", after analyzing and identifying the information query request, it can be determined that the rewriting category of the above information query request belongs to the "semantic rewriting category"; when the information query request is "sneakers", after analyzing and identifying the information query request, it can be determined that the rewriting category of the above information query request belongs to the "no rewriting category".
[0044] Since the rewritten category of an information query request directly affects the selection strategy for sample data used in model training, to ensure the accuracy and reliability of sample data determination, the information query request can be analyzed and processed after acquisition to determine its rewritten category. In some instances, the rewritten category can be determined based on a pre-trained rewritten category recognition model. In this case, determining the rewritten category of the information query request may include: identifying prompt words for identifying the rewritten category, where the prompt words include at least the definition information and / or scenario information corresponding to each rewritten category; and then using the rewritten category recognition model to process the information query request based on the prompt words to obtain the rewritten category of the information query request.
[0045] To accurately determine the rewrite category of an information query request, a prompt word for identifying that category can be determined first. In some instances, the prompt word can be pre-configured information stored in a preset area. In this case, the prompt word can be reliably determined by accessing the preset area. Alternatively, the prompt word can be determined through human-computer interaction. In this case, determining the prompt word for identifying the rewrite category of the information query request can include: displaying the prompt word on an interactive interface; obtaining the prompt word configuration operation entered by the user in the interactive interface; and obtaining the prompt word for identifying the rewrite category of the information query request based on the prompt word configuration operation. This effectively ensures the flexibility and reliability of the prompt word determination process.
[0046] Moreover, for the determined prompting words, they at least include: definition information and / or scenario information corresponding to each rewriting category. In addition, the prompting words can also include positive request examples and negative request examples corresponding to each rewriting category. For example, the prompting words can be "You are an expert in search optimization in the Chinese e-commerce field. Please rewrite the user input request or search term (query) according to the following rules to make the rewritten query more in line with the e-commerce search context and easier to search for relevant products. Rewriting types: Type 1, mainly for synonym conversion, including but not limited to the following rewriting directions: correction of typos (mainly including errors such as pronunciation or text similarity, e.g., Zhou Jielun → Jay Chou, men's putty → men's socks, coconut juice → coconut milk), normalization of spoken language (e.g., balloons that can be blown into animals → animal-shaped balloons, magic balloons, long balloons, etc.), synonym replacement while retaining the core word (e.g., shoes without shoelaces → shoeless shoes, Velcro shoes, etc.), Chinese-English conversion of well-known brands, removal of redundant meaning words (e.g., top shirt → shirt), removal of invalid qualifiers (e.g., dress for men, usually dresses are for women and there is no men's style, so "men" here is redundant and can be directly changed to dress; e.g., night light for the elderly, night lights for getting up at night generally do not limit the population, so it can be directly changed to night light), deletion of useless characters (e.g., phone.case → phone case), explicit display and conversion of measurement units (e.g., 1.5 two meters → 1.5m * 2m, 1 jin → 500g), adaptation of price ranges (e.g., 100 yuan gift → hundred-yuan gift), stage conversion (e.g., gift for 6 - 8-year-olds → children's gift). Type 2, mainly for intention refinement, usually without clear brand category requirements (excluding category refinement), including but not limited to the following rewriting directions: concretization of abstract requirements (usually with a clear question, e.g., dark circles for 30-year-old women → dark circle eye cream, dark circle skin care products, etc.), categorization of scenario requirements (e.g., Valentine's Day gift for women → lipstick, perfume, etc., beach outfit → beach pants, etc.). Type 0, no need to rewrite: commonly used e-commerce standard words and complete and correct product descriptions (e.g., bed, coffee, men's sports shoes), proper nouns such as book names (e.g., 10,000 Scientific Puzzles), words with unclear meanings (e.g., 9415cc).Constraints include rewriting principles. Specifically, rewriting principles may include: each rewritten query must conform to the original query intent; prohibitions include: not changing the original intent (e.g., "books in a storage box" → incorrect rewriting: "bookshelf"), not adding undefined information including but not limited to "men's / women's", season, or year (e.g., "shoes" → incorrect rewriting: "men's shoes"), not altering or discarding brand names (e.g., "OnePlus phone" → incorrect rewriting: "Brand A phone", "XX brand sneakers" → incorrect rewriting: "sneakers"), not splitting broad categories (e.g., "tops" → incorrect rewriting: "hoodies"), and not altering specific... Category generalization (e.g., thermos cup → incorrect rewrite: cup); Information retention: retain or implicitly include necessary information from the original query. For locations, brands, and specific specifications, the original text must be retained (e.g., Thai specialty → Thai durian chips). Items that can carry over or implicitly contain the original information can be replaced (e.g., beachwear → beach shorts). For gift-related items, the rewrite can omit the festival name but must reflect the corresponding festival atmosphere (e.g., Dragon Boat Festival gift → zongzi gift box); Quantity control: Each query should produce no more than 5 rewritten items, ensuring rewrite quality and avoiding text duplication. Typical negative examples: Over-expansion: Steamed buns → incorrect output: meat / vegetable buns (should maintain type 0), coffee → incorrect output: coffee cup (category offset), T-shirts → incorrect output: tops (category expansion; the requirement is focused on the T-shirt category, not the broader "tops" category). Information loss: "Thai specialty" → incorrect output "durian chips" (missing location qualifier), "Li-Ning sports pants" → incorrect output "Nike sports pants" (brand misrepresentation). Assumed demand: "This year's trend" → incorrect output "2023 trend" (unknown specific year), "shoes" → incorrect output "sports shoes" (no usage scenario basis), "0.5 millet" → incorrect output "0.5 jin of millet" (incorrect demand category; although millet has multiple meanings, the original intention was for the brand name "millet," not the food "millet"). Output specifications: Format: strict JSON array, no additional explanation required; array element fields include query (the rewritten specification text, or the original query if no rewriting is needed) and type (defined rewriting type 0|1|2); Output examples: [{"query":"lipstick","type":2},{"query":"perfume","type":2}], [{"query":"sports shoes","type":0}].
[0047] After determining the prompt words used to identify the rewritten category to which the information query request belongs, a rewritten category recognition model can be used to analyze and process the information query request based on the prompt words. Specifically, the prompt words and the information query request can be sent to the rewritten category recognition model for analysis and processing, so that the rewritten category recognition model can analyze and process the information query request based on the input prompt words and output the rewritten category to which the information query request belongs. This effectively ensures the accuracy and reliability of determining the rewritten category to which the information query request belongs.
[0048] In some instances, during the process of the rewrite category recognition model identifying the rewrite category of an information query request, there may be multiple rewrite categories that match the information query request. For example, when the rewrite category recognition model identifies the rewrite category of an information query request, the rewrite categories that match the information query request may include "synonymous rewrite category" and "semantic rewrite category". Then, the matching degree 1 between the "information query request" and the "synonymous rewrite category" and the matching degree 2 between the "information query request" and the "semantic rewrite category" are determined. The rewrite category to which the information query request belongs is determined based on the size of the matching degree 1 and the matching degree 2. The rewrite category to which the information query request belongs can be the rewrite category corresponding to the larger matching degree. For example, if the matching degree 2 > the matching degree 1, the "semantic rewrite category" can be determined as the rewrite category to which the information query request belongs. This effectively ensures the accuracy and reliability of determining the rewrite category to which the information query request belongs.
[0049] In this application, the rewrite category recognition model can be a Large Language Model (LLM) based on artificial intelligence. This application does not limit the number of model parameters supported by the model, aiming to meet actual needs. If the model has relatively more parameters, the model will be larger and perform better, but it will consume more time and resources during inference or training. If the model has relatively fewer parameters, the model will be smaller and, while meeting performance requirements, more lightweight, consuming less time and resources during inference or training. This rewrite category recognition model can be a deep learning model used to process and generate natural language text or multimodal data, implemented based on a neural network architecture, and can be pre-trained on large amounts of data. In an optional implementation, the rewrite category recognition model may include an encoder, a decoder, a self-attention layer, and a feed-forward neural network, etc. The encoder is mainly used to convert input data (usually in sequence form) into vector representation. This process can capture the semantic features of the input data. The decoder is responsible for converting the intermediate representation generated by the encoder into output data (usually in sequence form). The self-attention layer is a mechanism that allows the model to pay attention to other positions in the sequence to better encode the current position information. The feedforward neural network can perform nonlinear transformations on the output of the self-attention layer to enhance the model's expressive power. All parts work together, enabling the model built on them to perform well in various complex processing tasks, such as natural language processing, computer vision, speech recognition, machine translation, text summarization, and intelligent question answering.
[0050] Step S203: Based on the rewriting category, determine the positive rewriting samples and negative rewriting samples corresponding to the information query request.
[0051] Since different rewrite categories can correspond to different screening strategies for rewrite samples, and these rewrite samples can include positive and negative rewrite samples used for model training, after determining the rewrite category to which the information query request belongs, the positive and negative rewrite samples corresponding to the information query request can be determined based on the rewrite category. In some instances, positive and negative rewrite samples can be determined based on the sample screening strategy corresponding to the rewrite category. In this case, determining the positive and negative rewrite samples corresponding to the information query request based on the rewrite category can include: determining the sample screening strategy corresponding to the rewrite category based on a preset mapping relationship; and determining the positive and negative rewrite samples corresponding to the information query request based on the sample screening strategy. This effectively ensures the accuracy and reliability of determining the positive and negative rewrite samples.
[0052] For example, when the rewriting category includes the "no rewriting" category (where no rewriting operation is required for the information query request), positive and negative rewriting samples can be determined based on the sample selection strategy corresponding to the "no rewriting" category. In this case, determining the positive and negative rewriting samples corresponding to the information query request can include: performing random sampling based on the "no rewriting" category to obtain random samples, where the character similarity between the random samples and the information query request is less than or equal to a preset threshold; determining the information query request as the positive rewriting sample; and determining the random samples as the negative rewriting samples. This achieves the goal of determining the user's original input "information query request" as the positive rewriting sample and the random samples from the random sampling operation as the negative rewriting sample. Thus, when training the model based on the aforementioned positive and negative rewriting samples, over-rewriting of the request rewriting model can be effectively prevented, thereby improving the accuracy and reliability of the request rewriting operation to a certain extent.
[0053] Step S204: Train the model based on the information query request, positive rewrite samples and negative rewrite samples to obtain the request rewrite model.
[0054] After determining the positive and negative rewrite samples corresponding to the information query request, the model can be trained based on the information query request, the positive and negative rewrite samples, thereby obtaining a request rewrite model for implementing the request rewrite operation.
[0055] In some instances, model training operations can be implemented based on the Direct Preference Optimization (DPO) paradigm. In this case, the DPO paradigm can be used to process information query requests, positive rewrite samples, and negative rewrite samples to complete the model training operation, thereby stably obtaining the request rewrite model.
[0056] While preference-aligned training allows the request rewriting model to learn the differences between positive and negative rewriting samples, thus satisfying human preferences, it doesn't guarantee that the model's output will perfectly fit the positive rewriting samples. Therefore, to address this technical issue, a two-stage model training approach can be employed. This involves training the model based on information query requests, positive rewriting samples, and negative rewriting samples. The process can include: supervising and fine-tuning a large language model using information query requests and positive rewriting samples to obtain a preliminary training model; and then training the preliminary training model using the same three samples to obtain the final request rewriting model.
[0057] In the first training phase of the model, in order to ensure that the rewriting result of the request rewriting model meets the requirements of the positive rewriting sample, the large language model can be supervised and fine-tuned using information query requests and positive rewriting samples. Specifically, the large language model can be supervised and fine-tuned based on the loss function of the supervised fine-tuning operation, the information query request, and the positive rewriting sample. The loss function of the above-mentioned supervised fine-tuning operation can be implemented as the standard cross-entropy loss function, thereby obtaining the preliminary trained model after the first training phase.
[0058] After obtaining the initial training model, we can proceed to the second training stage of the model. Specifically, we can use information query requests, positive rewrite samples, and negative rewrite samples to perform Direct Preference Optimization (DP0) training on the initial training model. This allows us to obtain the request rewrite model through the two-stage model training operation.
[0059] In some instances, the second training phase can be implemented based on the loss function of the direct preference optimization operation. Specifically, the initial training model can be trained using information query requests, positive rewrite samples, and negative rewrite samples to obtain the loss function of the direct preference optimization operation. Then, the initial training model can be trained again based on this loss function to obtain the request-rewrite model. Alternatively, in other instances, the second training phase can be implemented based on the supervised fine-tuning loss function corresponding to the supervised fine-tuning operation and the direct preference loss function corresponding to the direct preference optimization operation. In this case, training the initial training model using information query requests, positive rewrite samples, and negative rewrite samples to obtain the request-rewrite model can include: generating a supervised fine-tuning loss function corresponding to the initial training model based on the information query requests and positive rewrite samples; generating a direct preference loss function corresponding to the initial training model based on the information query requests, positive rewrite samples, and negative rewrite samples; and training the initial training model again based on both the supervised fine-tuning loss function and the direct preference loss function to obtain the request-rewrite model.
[0060] Specifically, during the second stage of training the initial training model, the information query requests and positive rewrite samples are first analyzed and processed to generate a supervised fine-tuning loss function L_(SFT) corresponding to the initial training model. This supervised fine-tuning loss function can be implemented as the standard cross-entropy loss function. Then, the information query requests, positive rewrite samples, and negative rewrite samples are analyzed and processed to generate a direct preference loss function L_(DPO) corresponding to the initial training model. After obtaining the supervised fine-tuning loss function L_(SFT) and the direct preference loss function L_(DPO), the initial training model can be trained based on these functions to obtain the request rewrite model.
[0061] Example 1: When the supervised fine-tuning loss function is L_(SFT) and the direct preference loss function is L_(DPO), the initial training model can be trained based on the supervised fine-tuning loss function L_(SFT) and the direct preference loss function L_(DPO). Specifically, the initial training model can be trained first using the supervised fine-tuning loss function L_(SFT) to obtain an intermediate training model, and then the intermediate training model can be trained based on the direct preference loss function L_(DPO) to obtain the rewrite model after training.
[0062] Example 2: When the supervised fine-tuning loss function is L_(SFT) and the direct preference loss function is L_(DPO), a hybrid loss function can be obtained first based on the supervised fine-tuning loss function L_(SFT) and the direct preference loss function L_(DPO). Specifically, the hyperparameters corresponding to the supervised fine-tuning loss function L_(SFT) can be determined first, and then the product value between the hyperparameters and the supervised fine-tuning loss function L_(SFT) can be determined. The hybrid loss function can then be determined based on the product value and the direct preference loss function L_(DPO). In some instances, the hybrid loss function can be the sum of the product value and the direct preference loss function L_(DPO). The hybrid loss function can then be used to train the initially trained model. This can obtain a request rewrite model after model training, and can avoid the problem of excessive differences between the request rewrite model obtained after the DPO stage and the initially trained model obtained after the SFT stage, thereby ensuring the quality and effectiveness of training the request rewrite model.
[0063] Step S205: Perform a request rewrite operation using the request rewrite model.
[0064] After obtaining the request rewriting model, the request rewriting model can be used to perform request rewriting operations. Specifically, when the user inputs the search request to be processed, the search request to be processed is input into the request rewriting model for analysis and processing, so as to obtain the rewritten request output by the request rewriting model. Then, information query operations can be performed based on the rewritten request. This can reliably obtain information query results and ensure the accuracy and reliability of the information query results.
[0065] The request rewriting method provided in this embodiment obtains an information query request used for model training operations, determines the rewriting category to which the information query request belongs, and then determines the positive and negative rewriting samples corresponding to the information query request based on the rewriting category. This ensures the accuracy and reliability of the sample data determination to a certain extent. Then, based on the information query request, the selected positive and negative rewriting samples, model training is performed to obtain a request rewriting model, thereby effectively ensuring the quality and effect of the model training operation. After obtaining the request rewriting model, the search request to be processed can be analyzed and processed based on the request rewriting model to obtain the rewritten request. When performing information query operations based on the rewritten request, the accuracy and reliability of the information query operation can be improved. Specifically, when the original search request is a product search request, and a product search is performed based on the rewritten request, the accuracy of the product search results can be improved to a certain extent, which is conducive to improving the product conversion rate and further enhancing the practicality of the request rewriting method.
[0066] Figure 3 A flowchart illustrating an exemplary embodiment of this application for determining positive and negative rewrite samples corresponding to an information query request based on rewrite category. Figure 1 Based on the above embodiments, refer to the appendix. Figure 3 As shown, when the rewriting category includes a synonym rewriting category for performing synonym rewriting operations on information query requests, the positive and negative rewriting samples corresponding to the information query request can be determined based on the synonym rewriting operation. In this case, determining the positive and negative rewriting samples corresponding to the information query request based on the rewriting category can include: Step S301: Perform synonym rewriting operations on the information query request based on the synonym rewriting category to obtain multiple rewritten samples.
[0067] When the rewriting category is the synonym rewriting category, since the synonym rewriting category is used to perform synonym rewriting operations on information query requests, in order for the request rewriting model to learn the ability to perform synonym rewriting operations on requests, it can perform synonym rewriting operations on information query requests based on the synonym rewriting category, thereby obtaining multiple rewritten samples. Here, synonym rewriting operation refers to the operation of expressing information query requests using different words or keywords while keeping the original semantics of the information query request unchanged.
[0068] In some instances, synonym rewriting can be implemented using predefined rewriting rules (or a thesaurus). In this case, performing synonym rewriting on an information query request based on the synonym rewriting category to obtain multiple rewritten samples can include: determining predefined rewriting rules (or a thesaurus) based on the synonym rewriting category; using the rewriting rules to perform synonym rewriting on the information query request, thereby obtaining multiple rewritten samples, thus stably implementing the synonym rewriting operation.
[0069] In other instances, synonym rewriting can be achieved not only through preset rewriting rules, but also by combining the search matching results obtained after performing a search operation on the information query request. In this case, performing a synonym rewriting operation on the information query request based on the synonym rewriting category to obtain multiple rewritten samples can include: performing a search based on the information query request to obtain search matching results; or performing a synonym rewriting operation on the information query request based on the synonym rewriting category and the search matching results to obtain multiple rewritten samples.
[0070] Since information query operations in different scenarios may have different focuses, in order to ensure the accuracy and reliability of obtaining multiple rewritten samples, after obtaining the information query request, a search operation can be performed based on the information query request, so as to reliably obtain one or more search matching results.
[0071] For example, when the information query request is a product search request, a product search operation can be performed based on the product search request to obtain product search results that match the information query request. The product search results can be product title information that matches the product search request, and the product title information can include at least one of the following: product brand, product category, product attributes, product selling points, and applicable scenarios or target audience, etc. When the information query request is an article search request, an article search operation can be performed based on the article search request to obtain article search results that match the article search request. The article search results can include at least one of the following: article title, article keywords, etc.
[0072] After obtaining the search matching results, the information query request can be paraphrased based on the paraphrasing category and the search matching results, thus reliably obtaining multiple paraphrased samples. In some instances, the paraphrasing operation can be implemented based on a paraphrasing model. In this case, paraphrasing the information query request based on the paraphrasing category and the search matching results to obtain multiple paraphrased samples can include: concatenating and fusing the information query request and the search matching results based on the paraphrasing category to obtain a fused request; and inputting the fused request into the paraphrasing model for paraphrasing to obtain multiple paraphrased samples.
[0073] Specifically, since search matching results can represent the information of interest in the information query operation to a certain extent, after obtaining search matching results that match the information query request, the information query request and the search matching results can be concatenated and fused based on the synonym rewriting category to obtain a fused request. Then, the fused request can be input into a pre-trained synonym rewriting model for synonym rewriting operations, and multiple rewritten samples output by the synonym rewriting model can be obtained. This effectively ensures the stability and reliability of the synonym rewriting operation.
[0074] In some other instances, synonym rewriting can be implemented not only based on a synonym rewriting model, but also through the matched rewriting rules. In this case, performing synonym rewriting on an information query request based on the synonym rewriting category and search matching results to obtain multiple rewritten samples can include: determining a preset rewriting rule (or thesaurus) based on the synonym rewriting category and search matching results; using the rewriting rule to perform synonym rewriting on the information query request, thereby reliably obtaining multiple rewritten samples and stably implementing the synonym rewriting operation.
[0075] Step S302: Determine the sample selection parameters for screening multiple rewritten samples.
[0076] Since multiple rewritten samples are obtained by performing synonym rewriting operations on information query requests, and different rewritten samples may have different degrees of fit for the training task of the request rewriting model, in order to stably ensure the training quality and effect of the request rewriting model, after obtaining multiple rewritten samples, sample selection parameters can be determined for filtering multiple rewritten samples. In some instances, sample selection parameters may include at least one of the following: incremental recall information, text similarity, and semantic similarity, etc.
[0077] In addition, the sample selection parameters can be determined through human-computer interaction. In this case, determining the sample selection parameters for selecting multiple rewritten samples can include: displaying the human-computer interaction interface; obtaining the parameter configuration operation input by the user in the human-computer interaction interface; and determining the sample selection parameters for selecting multiple rewritten samples based on the parameter configuration operation. For example, the sample selection parameters can be the recall increment information.
[0078] In other instances, sample selection parameters can be determined not only through human-computer interaction but also through a comprehensive analysis of the recall increment information, text similarity, and semantic similarity corresponding to each of the multiple rewritten samples. In this case, determining the sample selection parameters used for selecting multiple rewritten samples can include: determining the recall increment information, text similarity, and semantic similarity corresponding to each of the multiple rewritten samples; and determining the sample selection parameters corresponding to each of the multiple rewritten samples based on the recall increment information, text similarity, and semantic similarity corresponding to each of the multiple rewritten samples.
[0079] For the multiple rewritten samples obtained, the recall increment, text similarity, and semantic similarity are determined by analyzing each rewritten sample and the original information query request. The recall increment can be determined based on the original recall corresponding to the information query request and the rewritten recall corresponding to the rewritten sample; the recall increment can be the difference between the original recall and the rewritten recall. Text similarity can be implemented to evaluate the similarity of text characters between the information query request and the rewritten sample; in some instances, text similarity can be implemented using Jaccard similarity. Semantic similarity is used to identify the similarity or proximity between the information query request and the rewritten sample in the semantic or intent dimensions.
[0080] After determining the recall increment, text similarity, and semantic similarity for each of the multiple rewritten samples, these parameters can be analyzed to determine the sample selection parameters for each sample. In some instances, the sample selection parameters can be determined by weighted fusion of the recall increment, text similarity, and semantic similarity for each of the multiple rewritten samples. In this case, the sample selection parameters are positively correlated with the recall increment and semantic similarity, and negatively correlated with text similarity, thus effectively ensuring the accuracy and reliability of the determined sample selection parameters.
[0081] In other instances, sample selection parameters can be determined not only by weighted fusion of recall increments, text similarity, and semantic similarity for each of the rewritten samples, but also through a pre-defined mapping table. In this case, determining the sample selection parameters for each of the rewritten samples based on their respective recall increments, text similarity, and semantic similarity can include: determining a mapping table, which can include multiple mapping relationships used to identify the relationship between recall increments, text similarity, semantic similarity, and sample selection parameters; and then querying the mapping table based on the respective recall increments, text similarity, and semantic similarity for each of the rewritten samples to reliably obtain the sample selection parameters for each of the rewritten samples.
[0082] Step S303: Based on the sample screening parameters, determine the positive and negative rewritten samples corresponding to the information query request from multiple rewritten samples.
[0083] After determining the sample filtering parameters used to filter multiple rewritten samples, the positive and negative rewritten samples corresponding to the information query request can be determined from among the multiple rewritten samples based on the sample filtering parameters. In some instances, the positive and negative rewritten samples can be filtered based on the magnitude of the sample filtering parameters. In this case, determining the positive and negative rewritten samples corresponding to the information query request from among the multiple rewritten samples based on the sample filtering parameters may include: sorting the multiple rewritten samples based on the magnitude of the sample filtering parameters to obtain the first rewritten sample corresponding to the largest sample filtering parameter and the second rewritten sample corresponding to the smallest sample filtering parameter; determining the first rewritten sample as the positive rewritten sample; and determining the second rewritten sample as the negative rewritten sample.
[0084] Specifically, after determining the sample selection parameters used to filter multiple rewritten samples, the numerical values of these parameters can be determined first. To ensure the efficiency of training the rewritten network model, a limited number of positive and negative rewritten samples can be selected. In some instances, the number of positive and negative rewritten samples selected is only one. Then, the multiple rewritten samples can be sorted based on the magnitude of the sample selection parameters to obtain the first rewritten sample corresponding to the largest parameter and the second rewritten sample corresponding to the smallest parameter. The first rewritten sample can then be designated as the positive rewritten sample, and the second as the negative rewritten sample. This effectively ensures the accuracy and reliability of determining the positive and negative rewritten samples.
[0085] In other instances, positive and negative rewritten samples can be determined not only based on the magnitude of sample selection parameters, but also based on a sample selection model. In this case, determining the positive and negative rewritten samples corresponding to the information query request from multiple rewritten samples based on the sample selection parameters can include: inputting the sample selection parameters, the information query request, and multiple rewritten samples into the sample selection model to perform a sample selection operation, and obtaining the positive and negative rewritten samples corresponding to the information query request output by the sample selection model. This also ensures the accuracy and reliability of determining the positive and negative rewritten samples.
[0086] In this embodiment, when the rewriting category includes a synonym rewriting category for performing synonym rewriting operations on information query requests, the information query request is rewritten based on the synonym rewriting category to obtain multiple rewritten samples. Then, sample filtering parameters are determined for filtering the multiple rewritten samples. Based on the sample filtering parameters, positive and negative rewritten samples corresponding to the information query request are determined from the multiple rewritten samples. This effectively ensures the accuracy and reliability of determining positive and negative rewritten samples. Furthermore, since the number of positive and negative rewritten samples is finite, the quality and efficiency of model training operations can be improved to a certain extent when performing model training operations based on positive and negative rewritten samples, further improving the flexibility and reliability of the method.
[0087] Figure 4 A flowchart illustrating an exemplary embodiment of this application for determining positive and negative rewrite samples corresponding to an information query request based on rewrite category. Figure 2 Based on the above embodiments, refer to the appendix. Figure 4 As shown, when the rewriting category includes a semantic rewriting category used for semantic rewriting operations on information query requests, the positive and negative rewriting samples corresponding to the information query request can be determined based on the semantic rewriting category. In this case, determining the positive and negative rewriting samples corresponding to the information query request based on the rewriting category can include: Step S401: Perform semantic rewriting operation on the information query request based on the semantic rewriting category to obtain multiple rewritten samples. Any rewritten sample corresponds to the information query request with the same or similar request intent.
[0088] When the rewriting category is semantic rewriting, since the semantic rewriting category is used to perform intent rewriting operations on information query requests (e.g., intent generalization, intent refinement, etc.), in order for the request rewriting model to learn the ability of semantic rewriting operations, semantic rewriting operations can be performed on the information query request based on the semantic rewriting category. This can obtain multiple rewritten samples, ensuring that any rewritten sample obtained after semantic rewriting operations corresponds to the same or similar request intent as the information query request. Semantic rewriting operations refer to operations that use different words or keywords to express the same or similar semantic meaning as the original information query request.
[0089] In some instances, semantic rewriting operations can be implemented using preset rewriting rules. In this case, performing semantic rewriting operations on information query requests based on semantic rewriting categories to obtain multiple rewritten samples can include: determining preset rewriting rules based on semantic rewriting categories; using rewriting rules to perform semantic rewriting operations on information query requests, thereby stably obtaining multiple rewritten samples, thus stably implementing semantic rewriting operations.
[0090] In other instances, semantic rewriting operations can be implemented not only through preset rewriting rules but also based on pre-trained rewriting network models. In this case, performing semantic rewriting operations on information query requests based on semantic rewriting categories to obtain multiple rewritten samples can include: determining the rewriting network model used to implement the semantic rewriting operation based on the semantic rewriting category; inputting the information query request into the rewriting network model for semantic rewriting operations, thereby obtaining multiple rewritten samples output by the rewriting network model. This effectively ensures the accuracy and reliability of determining multiple rewritten samples.
[0091] Step S402: Based on multiple rewritten samples and information query requests, determine the positive rewritten samples and negative rewritten samples corresponding to the information query requests.
[0092] Since multiple rewritten samples and information query requests have the same or similar request intent, in order to enable the request rewriting model to learn the ability of semantic generalization rewriting operations, multiple rewritten samples and information query requests can be analyzed and processed to determine the positive and negative rewritten samples corresponding to the information query requests.
[0093] In some instances, positive and negative rewritten samples can be determined based on the intent similarity between the rewritten sample and the information query request. In this case, determining the positive and negative rewritten samples corresponding to the information query request based on multiple rewritten samples and the information query request may include: determining the intent similarity between the information query request and each rewritten sample; if the intent similarity is greater than or equal to a preset threshold, the rewritten sample corresponding to the highest intent similarity can be determined as the positive rewritten sample; if the intent similarity is less than the preset threshold, the rewritten sample corresponding to the lowest intent similarity can be determined as the negative rewritten sample. This effectively ensures the accuracy and reliability of determining the positive and negative rewritten samples.
[0094] In other instances, positive and negative rewritten samples can be determined not only based on the intent similarity between the rewritten sample and the information query request, but also directly based on the rewritten sample and the information query request. In this case, determining the positive and negative rewritten samples corresponding to the information query request based on multiple rewritten samples and the information query request can include: determining multiple rewritten samples as positive rewritten samples corresponding to the information query request; and determining the information query request as a negative rewritten sample corresponding to the information query request. In this case, the number of positive rewritten samples is multiple, in some instances, it can be 5, 10, etc.; the number of negative rewritten samples is 1. This also ensures the flexibility and reliability of determining positive and negative rewritten samples.
[0095] In this embodiment, when the rewriting category includes a semantic rewriting category for semantic rewriting operations on information query requests, the information query request is semantically rewritten based on the semantic rewriting category to obtain multiple rewritten samples. Then, based on the multiple rewritten samples and the information query request, the positive and negative rewritten samples corresponding to the information query request are determined. This effectively ensures the accuracy and reliability of determining the positive and negative rewritten samples, which is beneficial to improving the quality and effect of model training based on the positive and negative rewritten samples, and further improves the practicality of the request rewriting method.
[0096] In specific applications, within e-commerce scenarios, to effectively address issues such as typos, semantic gaps between search queries and product descriptions, and ambiguous expression of user needs, this application embodiment provides an intelligent query rewriting method. This method utilizes a Large Language Model (LLM) to intelligently rewrite user-input queries. Since the LLM can be trained using a combination of Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO) paradigms, the trained LLM not only improves task adaptability but also intelligently rewrites user search terms, enhancing rewriting quality. After obtaining the rewritten request, it can be used for product searches, significantly optimizing downstream product recall, effectively reducing user search frustration, and improving user experience efficiency and platform conversion rates. This intelligent rewriting method includes the following stages: a training data construction stage, a two-stage model training stage, and a model application stage; for details, please refer to the appendix. Figure 5 As shown, the training data construction phase may include the following steps: Step 11: Obtain historical search requests (i.e., the original query).
[0097] Step 12: Classify and identify historical search requests to determine the request rewriting category to which the historical search requests belong.
[0098] After obtaining historical search requests, a large language model for category recognition can be used to analyze and identify these requests. Specifically, a prompt word for category recognition can be determined first. This prompt word includes the definition information and instance requests corresponding to each request category. Then, the prompt word and historical search requests are input into the large language model to determine the request rewriting category to which the historical search requests belong. In some instances, the request rewriting category can include any of the following: a synonym rewriting category for rewriting information search requests, a semantic rewriting category for rewriting information search requests, or a no-rewriting category for information search requests that do not require rewriting.
[0099] Step 13: Based on the request rewriting category to which the historical search requests belong, determine the sample set corresponding to the historical search requests.
[0100] Scenario 1: When the historical search request is "good-looking pants", a large language model used for category recognition is employed to analyze and identify the historical search request, determining that it belongs to the synonym rewriting category. If the historical search request is determined to belong to the synonym rewriting category, a synonym rewriting operation can be performed on the historical search request, obtaining multiple rewritten RewQ samples.
[0101] The paraphrasing of historical search requests can be achieved using a pre-trained paraphrasing network model. To ensure the accuracy and reliability of acquiring multiple paraphrased samples, a product search can be performed on an e-commerce platform based on the historical search requests to obtain the top N product titles that match the historical search requests. Then, prompt words can be constructed from the historical search requests and the top N product titles, and these prompt words can be input into the paraphrasing network model to obtain multiple paraphrased samples (RewQ) output by the model. Furthermore, the output multiple paraphrased samples (RewQ) are relevant to the e-commerce scenario.
[0102] After obtaining multiple rewritten RewQ samples, a sample filtering operation can be performed to obtain a sample set corresponding to the historical search request. This sample set includes one positive rewritten sample and one negative rewritten sample corresponding to the historical search request. Specifically, the sample data included in the sample set can be determined by a filtering score calculated by comprehensively considering the recall increment information, text character similarity (e.g., Jaccard similarity), and semantic similarity. The filtering score can be determined by a weighted summation of the recall increment information, text character similarity, and semantic similarity. Specifically, the filtering score can be positively correlated with the recall increment information and semantic similarity, and negatively correlated with text character similarity. Then, the rewritten sample with the highest score can be selected as the positive rewritten sample, while the rewritten sample with the lowest score can be selected as the negative rewritten sample. This effectively ensures the accuracy and reliability of the filtering of positive and negative rewritten samples.
[0103] Scenario 2: When the historical search request is "Valentine's Day gift for girlfriend", a large language model used for category recognition can be used to analyze and identify the historical search request to determine its request rewriting category as a semantic rewriting category (or generalized semantic rewriting category). Once the historical search request is determined to belong to the semantic rewriting category, semantic rewriting can be performed on the historical search request, resulting in multiple rewritten RewQ samples.
[0104] The semantic rewriting operation of historical search requests can be implemented through a pre-trained rewriting network model. The historical search request can be input into the rewriting network model for semantic rewriting, resulting in multiple rewritten samples output by the model. Any two rewritten samples correspond to different product categories; for example, one rewritten sample corresponds to "perfume," and another to "lipstick." These rewritten samples corresponding to different product categories are then designated as positive rewritten samples, resulting in multiple positive rewritten samples. The original historical search request is designated as a negative rewritten sample, effectively ensuring the accuracy and reliability of the sample set determination.
[0105] Scenario 3: When the historical search request is "sports shoes", since the above historical search requests correspond to a clear search target or search intent, the large language model used to implement category recognition operation can be used to analyze and identify the historical search request, and it can be determined that the request rewriting category to which the historical search request belongs is a category that does not need to be rewritten.
[0106] Since no rewriting operation is required for historical search requests, the original historical search requests can be identified as positive rewriting samples, and other randomly sampled search requests can be identified as negative rewriting samples. The difference between other search requests and historical search requests is greater than or equal to a preset threshold, thereby ensuring the accuracy and reliability of the sample set. In this way, when performing model training operations based on the above positive and negative rewriting samples, the situation of excessive rewriting operation of the model can be effectively prevented.
[0107] It should be noted that the different situations described above can generate different sample sets, which include the original search requests, positive rewrite samples, and negative rewrite samples used to implement model training operations, thereby completing the construction of training data.
[0108] Additionally, please refer to the appendix. Figure 6 As shown, the two-stage model training phase may include the following steps: Step 21: Perform supervised fine-tuning (SFT) on the large language model using the training sample set to obtain the initial trained model.
[0109] After obtaining the training sample set, the original search requests and positive rewrite samples can be used to perform supervised fine-tuning of the large language model, so that the large language model can learn the basic request rewrite capability, thereby obtaining the initial training model.
[0110] Step 22: Use the sample set to perform Direct Preference Optimization (DPO) on the initial trained model to obtain the request rewrite model for implementing the request rewrite operation.
[0111] The training operation of directly optimizing the initial training model using the sample set (for learning human preference information) can include: generating a supervised fine-tuning loss function L_{SFT} corresponding to the initial training model based on the original search request and the positive rewritten samples in the sample set; simultaneously, generating a direct preference loss function L_{DPO} corresponding to the initial training model based on the original search request, the positive rewritten samples and the negative rewritten samples in the sample set; and then determining a hybrid loss function based on the supervised fine-tuning loss function L_{SFT} and the direct preference loss function L_{DPO}. In some instances, the hybrid loss function L can be determined by the following formula: L = L_{DPO} + β * L_{SFT}, where β is a hyperparameter used to balance the influence of the supervised learning stage and the preference optimization stage. β can be a value greater than 0 and less than 1. In some instances, β can be 0.5.
[0112] After determining the hybrid loss function, the initial training model can be optimized using the hybrid loss function to obtain a request rewrite model for implementing request rewrite operations. This effectively ensures the quality and effectiveness of the request rewrite model in performing request rewrite operations.
[0113] Reference Appendix Figure 7 As shown, the application phase of the model may include the following steps: Step 31: Obtain the product search request used for searching on the e-commerce platform.
[0114] Step 32: Invoke the pre-trained request rewrite model used to implement the request rewrite operation.
[0115] Step 33: Input the product search request into the request rewriting model for rewriting operation to obtain at least one rewritten search request corresponding to the product search request.
[0116] Step 34: Based on at least one rewritten search request, perform a product search operation on the e-commerce platform to obtain product search results, thereby effectively ensuring the accuracy and reliability of product search results.
[0117] The intelligent query request rewriting method provided in this application embodiment determines the query rewriting category to which historical search requests belong, and then implements a differentiated sample selection mechanism for different query rewriting categories to construct positive and negative rewriting samples for model training. For example, when the query rewriting category is synonym rewriting, a comprehensive score is calculated by jointly considering recall increment (scenario indicators), text similarity (e.g., Jaccard similarity), and semantic similarity (e.g., Embedding similarity) to obtain a comprehensive score for sample selection. Then, a comprehensive ranking is performed based on the comprehensive score, and positive and negative rewriting samples are selected based on the comprehensive score. When the query rewriting category is no-rewrite category, "original search request = positive rewriting sample" is explicitly constructed, thus implementing an anti-degeneracy design by adding no-rewrite queries. This effectively prevents the query rewriting model from forcibly rewriting high-precision queries, thereby improving the stability of product search operations and ensuring the accuracy and reliability of the sample set selection operation. Furthermore, after obtaining positive and negative rewriting samples... After rewriting the samples, since the request rewriting model is obtained by training an LLM model, specifically, a two-stage training scheme of SFT+DPO reinforcement learning is used to optimize the LLM model's preferences. The SFT stage ensures the basic generation quality of the LLM model, while the DPO stage strengthens positive sample preferences through contrastive learning, avoiding interference from negative samples in the model training process, thus obtaining a high-quality request rewriting model. Furthermore, when using the request rewriting model to rewrite product search requests, the world knowledge of the LLM model can be used for semantic understanding of the product search requests, ensuring the quality and effectiveness of the rewriting operation and addressing the problem of poor generalization ability in related technologies. Simultaneously, by introducing highly relevant product title information to assist in rewriting product search requests, the semantic gap in product search requests can be narrowed, further improving the accuracy and intelligence of request rewriting. When performing product search operations based on the rewritten requests, the conversion rate of products can be improved to a certain extent, further enhancing the practicality of this rewriting method.
[0118] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 11, 12, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0119] Figure 8 A schematic diagram of a request rewriting device provided for an exemplary embodiment of this application; see attached drawing. Figure 8 As shown, this embodiment provides a request rewrite device, which is used to perform the above-described... Figure 2 The request rewriting method shown herein, specifically, the request rewriting device may include: The first acquisition module 11 is used to acquire information query requests; The first determining module 12 is used to determine the rewrite category to which the information query request belongs; The first determining module 12 is also used to determine, based on the rewriting category, the positive rewriting samples and negative rewriting samples corresponding to the information query request; The first processing module 13 is used to train the model based on the information query request, positive rewrite samples and negative rewrite samples to obtain the request rewrite model. The first processing module 13 is also used to perform request rewriting operations using the request rewriting model.
[0120] The request rewriting device in this embodiment can also perform the above-described actions. Figures 1-7 The description of the embodiments shown is for reference only, and will not be elaborated upon here.
[0121] like Figure 9 As shown, this embodiment provides an electronic device for performing the above-described... Figure 2 The requested rewrite method shown may include a memory 24 and a processor 25.
[0122] Memory 24 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device, data structures, contact data, phone book data, messages, pictures, videos, etc.
[0123] The processor 25, coupled to the memory 24, is used to execute the computer program in the memory 24 for: acquiring an information query request for implementing model training operations; determining the rewrite category to which the information query request belongs; determining the positive and negative rewrite samples corresponding to the information query request based on the rewrite category; training the model based on the information query request, the positive and negative rewrite samples to obtain a request rewrite model; and performing a request rewrite operation using the request rewrite model.
[0124] Furthermore, such as Figure 9 As shown, the electronic device also includes other components such as a communication component 26, a display 27, a power supply component 28, and an audio component 29. Figure 9 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 9 The components shown. Additionally... Figure 9 The components within the center frame are optional, not mandatory, and their specific requirements depend on the product form of the work node. In this embodiment, the work node can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT device, or a server-side device such as a conventional server, cloud server, or server array. If the work node in this embodiment is implemented as a terminal device such as a desktop computer, laptop computer, or smartphone, it may include... Figure 9 The components within the center frame; if the working node in this embodiment is implemented as a server-side device such as a conventional server, cloud server, or server array, it may not include... Figure 9 The component within the center frame.
[0125] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0126] The aforementioned communication component is configured to facilitate wired or wireless communication between the device containing the communication component and other devices. The device containing the communication component can access wireless networks based on communication standards, such as 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.
[0127] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0128] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.
[0129] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0130] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the above-described method embodiments. The computer-readable storage medium includes volatile or non-volatile components, or a combination thereof, and can be removable or non-removable. Examples of computer-readable storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium. Accordingly, this application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, the processor is able to implement the steps in the above method embodiments. It should be understood that each step or combination of steps in the above method flow can be implemented by the computer program or instructions. In addition, these computer programs or instructions can be applied to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device, so that the processor of the general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device can be implemented as a means to implement the corresponding functions in the above method embodiments.
[0131] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0132] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A request rewriting method, characterized in that, include: Obtain an information query request used to perform model training operations; Determine the rewrite category to which the information query request belongs; Based on the rewriting category, determine the positive rewriting samples and negative rewriting samples corresponding to the information query request; Based on the information query request, the positive rewrite sample, and the negative rewrite sample, a model is trained to obtain a request rewrite model; The request rewriting model is used to perform request rewriting operations.
2. The method according to claim 1, characterized in that, Determining the rewrite category to which the information query request belongs includes: Determine prompt words for identifying the rewrite category to which the information query request belongs, wherein the prompt words include at least: definition information and / or scenario information corresponding to each rewrite category; The information query request is processed based on the prompt words using a rewrite category recognition model to obtain the rewrite category to which the information query request belongs.
3. The method according to claim 1, characterized in that, The rewriting categories include synonym rewriting categories used for performing synonym rewriting operations on the information query request; Based on the rewriting category, determine the positive and negative rewriting samples corresponding to the information query request, including: Based on the synonym rewriting category, the information query request is rewritten using a synonym rewriting operation to obtain multiple rewritten samples; Determine the sample selection parameters to be used for filtering multiple rewritten samples; Based on the sample screening parameters, positive and negative rewritten samples corresponding to the information query request are determined from multiple rewritten samples.
4. The method according to claim 3, characterized in that, Based on the aforementioned synonym rewriting category, the information query request is subjected to synonym rewriting operations to obtain multiple rewritten samples, including: Based on the information query request, a search is performed to obtain search matching results; Based on the synonym rewriting category and the search matching result, the information query request is rewritten using synonym rewriting to obtain multiple rewritten samples.
5. The method according to claim 4, characterized in that, Based on the synonym rewriting category and the search matching results, the information query request is rewritten using synonym rewriting operations to obtain multiple rewritten samples, including: Based on the synonym rewriting category, the information query request and the search matching result are concatenated and merged to obtain the merged request; The fused request is input into the synonym rewriting model to perform synonym rewriting operations, resulting in multiple rewritten samples.
6. The method according to claim 3, characterized in that, Determine the sample selection parameters used for filtering multiple rewritten samples, including: Determine the recall increment information, text similarity, and semantic similarity for each of the multiple rewritten samples; Based on the recall increment information, text similarity, and semantic similarity of each of the multiple rewritten samples, the sample selection parameters corresponding to each of the multiple rewritten samples are determined.
7. The method according to claim 3, characterized in that, Based on the sample selection parameters, the positive and negative rewritten samples corresponding to the information query request are determined from multiple rewritten samples, including: The multiple rewritten samples are sorted based on the size of the sample selection parameter to obtain the first rewritten sample corresponding to the largest sample selection parameter and the second rewritten sample corresponding to the smallest sample selection parameter. The first rewritten sample is determined as the positive rewritten sample; The second rewritten sample is determined as the negative rewritten sample.
8. The method according to claim 1, characterized in that, The rewriting categories include semantic rewriting categories used for semantic rewriting operations on the information query request; Based on the rewriting category, determine the positive and negative rewriting samples corresponding to the information query request, including: Based on the semantic rewriting category, the information query request is semantically rewritten to obtain multiple rewritten samples. Any rewritten sample corresponds to the information query request with the same or similar request intent. Based on the multiple rewritten samples and the information query request, the positive rewritten samples and negative rewritten samples corresponding to the information query request are determined.
9. The method according to claim 8, characterized in that, Based on the multiple rewritten samples and the information query request, determine the positive and negative rewritten samples corresponding to the information query request, including: The multiple rewritten samples are identified as the positive rewritten samples corresponding to the information query request; The information query request is identified as the negative rewrite sample corresponding to the information query request.
10. The method according to claim 1, characterized in that, The rewriting categories include categories that do not require rewriting of the information query request; Based on the rewriting category, determine the positive and negative rewriting samples corresponding to the information query request, including: Based on the above-mentioned random sampling operation without rewriting the category, a random sample is obtained, and the character similarity between the random sample and the information query request is less than or equal to a preset threshold. The information query request is identified as the positive rewrite sample; The random sample is determined as the negative rewrite sample.
11. The method according to any one of claims 1-10, characterized in that, Based on the information query request, the positive rewrite sample, and the negative rewrite sample, a model is trained to obtain a request rewrite model, including: The large language model is supervised and fine-tuned using the information query request and the positive rewrite sample to obtain a preliminary training model; The preliminary training model is trained using the information query request, the positive rewrite sample, and the negative rewrite sample to obtain the request rewrite model.
12. The method according to claim 11, characterized in that, The initial training model is trained using the information query request, the positive rewrite sample, and the negative rewrite sample to obtain the request rewrite model, including: Based on the information query request and the positive rewrite sample, a supervised fine-tuning loss function corresponding to the preliminary training model is generated. Based on the information query request, the positive rewrite sample, and the negative rewrite sample, a direct preference loss function corresponding to the preliminary training model is generated. The preliminary training model is trained based on the supervised fine-tuning loss function and the direct preference loss function to obtain the requested rewrite model.
13. A request rewrite device, characterized in that, include: The first acquisition module is used to acquire information query requests; The first determining module is used to determine the rewrite category to which the information query request belongs; The first determining module is further configured to determine, based on the rewriting category, the positive rewriting sample and the negative rewriting sample corresponding to the information query request; The first processing module is used to train a model based on the information query request, the positive rewrite sample and the negative rewrite sample to obtain a request rewrite model. The first processing module is also used to perform request rewriting operations using the request rewriting model.
14. An electronic device, characterized in that, include: A memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any one of claims 1-12.
15. A computer storage medium, characterized in that, Used to store a computer program that, when executed by a computer, implements the method of any one of claims 1-12.
16. A computer program product, characterized in that, include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the steps of the method of any one of claims 1-12.