Searching method and device, storage medium and program product
Patent Information
- Application Number
- CN202411210539.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-01-24
AI Technical Summary
Existing search engines have poor search results when processing large-scale data, making it difficult to provide highly relevant search results.
Adopt a search method to obtain the search conditions entered by the user, retrieve the target search terms related to them, and use the pre-trained language model and neural network model to generate matching prompt text to evaluate the matching degree between the search conditions and the target search terms. , and finally output relevant search results.
By combining pre-trained language models and neural network models, the semantic matching degree between search conditions and target search terms can be more accurately evaluated, providing more relevant search results, and improving search engine performance and user experience.
Smart Images

Figure CN119357453A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computer software technology, and in particular, to a search method, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] A search engine is an information retrieval system. Users input query information such as keywords or query statements based on actual needs. The search engine retrieves content related to the query information in its index database and returns the most relevant results to the user. With the development of information technology, the data size of the database indexed by the search engine has gradually expanded, and the search effect of the search method in the relevant technology is not good, which needs to be further improved. Summary of the invention
[0003] In view of this, one or more embodiments of the present specification provide a search method, an electronic device, a computer-readable storage medium, and a computer program product.
[0004] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0005] According to a first aspect of one or more embodiments of this specification, a search method is proposed, including:
[0006] Get the search criteria entered by the user in the search box;
[0007] Retrieving a plurality of target search items related to the search condition from a database pre-stored with a plurality of search items;
[0008] Based on the search condition and each of the target search items, each matching prompt text is generated; the matching prompt text is used to prompt the trained matching model to judge the matching degree between the search condition and each of the target search items; the matching model includes a pre-trained language model and a neural network model;
[0009] Input each of the matching prompt texts into the matching model, so that the pre-trained language model generates a first embedding vector for representing the degree of matching between the search condition and each of the target search items based on the matching prompt text, and the neural network model obtains a matching result based on the first embedding vector;
[0010] Based on the matching results between the search condition and each of the target search terms, a search result of the search condition is output.
[0011] According to a second aspect of an embodiment of this specification, a search method is provided, which is applied to a client, and the method includes:
[0012] Get the search criteria entered by the user in the search box;
[0013] Sending the search condition to a server, so that the server performs the search method according to the first aspect based on the search condition;
[0014] The search results returned by the server are received and displayed on the search page.
[0015] According to a third aspect of the embodiments of this specification, there is provided an electronic device, including:
[0016] processor;
[0017] a memory for storing processor-executable instructions;
[0018] When the processor executes the executable instructions, it is used to implement the method described in the first aspect.
[0019] According to a fourth aspect of the embodiments of this specification, there is provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any of the above methods are implemented.
[0020] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program, which implements the steps of any of the above methods when executed by a processor.
[0021] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0022] In the embodiment of this specification, the search condition entered by the user in the search box is first obtained, and the target search term related to the search condition is retrieved from a database pre-stored with several search terms, and a matching prompt text is generated based on the search condition and the target search term, and the pre-trained language model included in the matching model generates a first embedding vector for representing the degree of matching based on the matching prompt text, and then the neural network model included in the matching model obtains the final matching result based on the first embedding vector, and finally outputs the search result of the search condition according to the matching result. Among them, the pre-trained language model can capture the complex semantic information in the language, thereby improving the accuracy of matching, and the neural network model can further refine the matching results. The combination of the pre-trained language model and the neural network model can more accurately evaluate the degree of semantic matching between the search condition and the target search term, thereby providing more relevant search results.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1AIt is a schematic diagram of the architecture of a search service system provided by an exemplary embodiment.
[0025] Figure 1B It is a schematic diagram of a search process provided by an exemplary embodiment.
[0026] Figure 2 It is a schematic diagram of a model training process provided by an exemplary embodiment.
[0027] Figure 3 It is a schematic diagram of another model training process provided by an exemplary embodiment.
[0028] Figure 4A It is a schematic diagram of a matching model training process provided by an exemplary embodiment.
[0029] Figure 4B It is a schematic diagram of another matching model training process provided by an exemplary embodiment.
[0030] Figure 5 It is a flowchart of a search method provided by an exemplary embodiment.
[0031] Figure 6 It is a flowchart of another search method provided by an exemplary embodiment.
[0032] Figure 7 It is a flowchart diagram of another search method provided by an exemplary embodiment.
[0033] Figure 8 It is a schematic structural diagram of an electronic device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0035] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0036] 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, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0037] Here is an explanation of the relevant terms:
[0038] Pre-trained language model: also known as Large Language Model, is a modeling method based on statistics and natural language processing technology. It uses a high-capacity model architecture (such as Transformer) to train on massive texts. Therefore, it can obtain a lot of prior knowledge through the above pre-training, and the model question answering is the process of guiding it to give relevant knowledge by instructions. It generally has more than 100 million parameters.
[0039] Prompt: Prompt can be understood as a way to specify the focus of the pre-trained language model. It is a piece of text or sentence that guides the pre-trained language model to generate output of a specific type, topic or format. A carefully designed prompt can guide the pre-trained language model to respond in the desired a priori direction.
[0040] Figure 1A FIG. 1 is a schematic diagram of the architecture of a search service system provided by an exemplary embodiment. Figure 1A As shown, the system may include a server 11, a network 12, and several terminals, including but not limited to a PC (Personal Computer) 13, a mobile phone 14, and the like.
[0041] The server 11 may be a physical server including an independent host, or the server 11 may be a virtual server carried by a host cluster. During operation, the server 11 may run a server-side program of an application to implement the relevant functions of the application. For example, when the server 11 runs a search service program, it may be implemented as a corresponding search server.
[0042] PC13 and mobile phone 14 are only some types of terminals that can be used by users. In fact, users can obviously also use terminals such as tablet devices, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), etc., and one or more embodiments of this specification do not limit this. During operation, the terminal can run a program on the client side of an application to implement the relevant functions of the application. For example, when the terminal runs a program for a search service, it can be implemented as a client of the search service. Among them, the application program of the client of the above-mentioned search service can be started and run on the terminal. The program on the client side can be a native application installed on the terminal, or the program on the client side can be a small program, a quick application or other similar forms. Of course, when using web page technologies such as HTML5 or similar, the relevant functions can be implemented through the page displayed by the browser. The browser here can be an independent browser application or a browser module embedded in certain applications.
[0043] As for the network 12 for interaction between terminals such as PC 13 and mobile phone 14 and server 11, it is possible to select a wired or wireless network to achieve communication based on the communication mode supported by the corresponding terminal, and this specification does not limit this. For example, PC 13 can support both wired and wireless communication, so it can use a wired or wireless network to achieve communication as needed, while mobile phone 14 usually only supports wireless communication, so it can use a wireless network to achieve communication.
[0044] The embodiment of this specification provides a search method, which can be executed by the above-mentioned server. During the search process, the server first obtains the search condition entered by the user in the search box, retrieves the target search term related to the search condition from a database pre-stored with several search terms, generates a matching prompt text based on the search condition and the target search term, and generates a first embedding vector for representing the degree of matching based on the matching prompt text by a pre-trained language model included in the matching model, and then obtains the final matching result based on the first embedding vector by a neural network model included in the matching model, and finally outputs the search result of the search condition according to the matching result. In this embodiment, the pre-trained language model has been trained on large-scale data and can capture complex semantic information in the language, thereby improving the accuracy of matching, and the neural network model can further refine the matching results by learning specific patterns and features. The combination of the pre-trained language model and the neural network model can more accurately evaluate the degree of semantic matching between the search condition and the target search term, thereby providing more relevant search results.
[0045] In order to further improve the search accuracy and efficiency, in the process of retrieving target search items related to the search conditions from a database that pre-stores several search items, it is also possible to use pre-trained language models (hereinafter referred to as the first search model and the second search model).
[0046] In an exemplary application scenario, see Figure 1B The terminal, such as a mobile phone 14, displays a search page, which includes a search box. The user can enter search conditions in the search box according to actual needs. The mobile phone 14 sends the search conditions to the server 11, so that the server 11 executes the search method provided in this specification after receiving the search conditions, and returns the search results of the search conditions to the mobile phone 14, so that the search results of the search conditions can be displayed in the display interface of the mobile phone 14, and the search results can be multiple search items related to the search conditions.
[0047] Next, the training process of various models to which the search method provided in this specification is applied is exemplified:
[0048] In some embodiments, see Figure 2 , Figure 2 A schematic diagram of a model training process is shown, and the model training method can be performed by an electronic device, including but not limited to a physical server, a server cluster, a cloud server, a smart phone / mobile phone, a tablet computer, a personal digital assistant (PDA), a laptop computer, and a desktop computer. The model training method includes:
[0049] In S201, a training sample set is obtained, the training sample set includes a number of search pair samples annotated with matching labels, each search pair sample includes a search condition sample and a search item sample, and the matching label is used to describe the matching degree between the search condition sample and the search item sample.
[0050] This step implements supervised training of the pre-trained language model by obtaining pre-labeled samples, ensuring that the pre-trained language model has sufficient, well-labeled data to learn during training. By using labeled matching labels, the pre-trained language model can better learn how to distinguish which search conditions and search items are matched and which are not matched. The label corresponding to each search pair sample is used to indicate the degree of semantic matching between the search condition sample and the search item sample, such as 0 for no match and 1 for a perfect match, or a continuous score is used to indicate the degree of matching, but is not limited to this.
[0051] In S202, a first prompt text is generated based on the search condition sample and a preset first prompt template, and a second prompt text is generated based on the search item sample and a preset second prompt template.
[0052] The first prompt text is used to prompt the pre-trained language model to generate a second embedding vector for representing the search condition sample. The second prompt text is used to prompt the pre-trained language model to generate a third embedding vector for representing the search term sample. The first prompt text and the second prompt text are used to provide context or guidance information for the pre-trained language model so that the pre-trained language model can generate an embedding vector more accurately.
[0053] Exemplarily, the format of the preset first prompt template is such as "[start] Please generate an embedding vector for the given search condition, the search condition is XXX[end]". The format of the preset second prompt template is such as "[start] Please generate an embedding vector for the given search term, the search term is XXX[end]". But it is not limited to this. Among them, the header identifier "[start]" is used to identify the starting position of the prompt text, and the tail identifier "[end]" is used to identify the ending position of the prompt text.
[0054] In S203, the first prompt text is input into the pre-trained language model so that the pre-trained language model generates a second embedding vector for representing the search condition sample based on the first prompt text; and the second prompt text is input into the pre-trained language model so that the pre-trained language model generates a third embedding vector for representing the search term sample based on the second prompt text.
[0055] In this step, the second embedding vector is a high-dimensional representation of the search condition sample, and the third embedding vector is a high-dimensional representation of the search term sample, which can condense and express the core semantic information of the sample.
[0056] Exemplarily, the pre-trained language model uses the Transformer architecture, in which the self-attention mechanism in the Transformer architecture allows the pre-trained language model to consider the information of all other positions in the sequence when processing each position of the input sequence, which means that when the pre-trained language model generates an embedding vector for each position, this vector contains not only the information of the position itself, but also the global information in the context. Under this mechanism, when the pre-trained language model generates an embedding vector for the tail marker of the prompt text, the embedding vector of the tail marker has actually integrated the information of all the preceding content in the entire prompt text, that is, the embedding vector of this tail position can effectively capture the semantics of the entire prompt text.
[0057] Therefore, the tail of the first prompt text includes a tail identifier for identifying the end position; the second embedding vector representing the search condition includes an embedding vector corresponding to the tail identifier of the first prompt text. The tail of the second prompt text includes a tail identifier for identifying the end position; and the third embedding vector representing the search term includes an embedding vector corresponding to the tail identifier of the second prompt text.
[0058] In S204, a predicted matching result is determined based on the similarity between the second embedding vector used to represent the search condition sample and the third embedding vector used to represent the search term sample.
[0059] In this step, after obtaining the second embedding vector and the third embedding vector, the similarity between them can be calculated. The similarity can be calculated by cosine similarity, Euclidean distance or other suitable measurement methods. This similarity is the predicted matching result of the pre-trained language model, which represents the judgment of the pre-trained language model on the matching degree between the search condition sample and the search item sample.
[0060] In S205, the pre-trained language model is optimized and trained with minimizing the difference between the predicted matching result and the matching label as the optimization goal.
[0061] In this step, by comparing the difference between the predicted matching result and the actual matching label, for example, the difference can be measured by a loss function, the loss function includes but is not limited to the mean square error or cross entropy, etc., the difference between the predicted matching result and the actual matching label is minimized as the optimization goal, and the model parameters of the pre-trained language model are continuously adjusted. This process can be completed by back propagation and gradient descent algorithms.
[0062] The trained pre-trained language model can generate an embedding vector for representing the search condition based on the search condition, or can generate an embedding vector for representing the search term based on the search term. The trained pre-trained language model can be used as the first search model (as a model for generating an embedding vector for representing the search condition) in the subsequent search process, or as the second search model (as a model for generating an embedding vector for representing the search term) in the subsequent search process.
[0063] In some embodiments, see Figure 3 , Figure 3 A schematic diagram of another model training process is shown, and the model training method can be performed by an electronic device, including but not limited to a physical server, a server cluster, a cloud server, a smart phone / mobile phone, a tablet computer, a personal digital assistant (PDA), a laptop computer, and a desktop computer. The model training method includes:
[0064] In S301, a training sample set is obtained, the training sample set includes a number of search pair samples marked with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the matching degree between the search condition samples and the search item samples.
[0065] In this step, a training sample set annotated with matching labels is collected and prepared. The training sample set includes multiple pairs of search pair samples, each pair of search pair samples consists of a search condition sample and a search item sample, and each pair of search pair samples has a matching label to indicate the degree of matching between the search condition sample and the search item sample, such as 0 for no match, 1 for a complete match, or a continuous score is used to indicate the degree of matching, but not limited to this.
[0066] In S302, a first prompt text is generated based on the search condition sample and a preset first prompt template, and a second prompt text is generated based on the search term sample and a preset second prompt template.
[0067] The first prompt text is used to prompt the first pre-trained language model to generate a second embedding vector for representing the search condition sample. The second prompt text is used to prompt the second pre-trained language model to generate a third embedding vector for representing the search term sample. The first prompt text and the second prompt text are used to provide context or guidance information for the pre-trained language model so that the pre-trained language model can generate the embedding vector more accurately.
[0068] Exemplarily, the format of the preset first prompt template is such as "[start] Please generate an embedding vector for the given search condition, the search condition is XXX[end]". The format of the preset second prompt template is such as "[start] Please generate an embedding vector for the given search term, the search term is XXX[end]". But it is not limited to this. Among them, the header identifier "[start]" is used to identify the starting position of the prompt text, and the tail identifier "[end]" is used to identify the ending position of the prompt text.
[0069] In this step, the process of generating prompt text helps to convert the search condition samples and search item samples into a form that can be processed by the pre-trained language model. This conversion not only retains the original information, but also provides additional contextual guidance, which helps the pre-trained language model generate more accurate embedding vectors.
[0070] In S303, the first prompt text is input into the first pre-trained language model to be trained, so that the first pre-trained language model to be trained generates a second embedding vector for representing the search condition sample based on the first prompt text; and the second prompt text is input into the second pre-trained language model to be trained, so that the second pre-trained language model to be trained generates a third embedding vector for representing the search term sample based on the second prompt text; wherein the parameter amount of the first pre-trained language model is less than the parameter amount of the second pre-trained language model.
[0071] In this step, the second embedding vector is a high-dimensional representation of the search condition sample, and the third embedding vector is a high-dimensional representation of the search term sample, which can condense and express the core semantic information of the sample.
[0072] The first pre-trained language model has a small number of parameters and is usually used in lightweight, real-time application scenarios. It can quickly generate an embedding vector for representing the search conditions in the subsequent search process. The second pre-trained language model has a large number of parameters and can generate a more detailed and higher-quality embedding vector. It can generate an embedding vector for representing the search term in advance for application in the search process.
[0073] Exemplarily, the two pre-trained language models with different parameter values use the Transformer architecture, in which the self-attention mechanism in the Transformer architecture allows the pre-trained language model to consider the information of all other positions in the sequence when processing each position of the input sequence, which means that when the pre-trained language model generates an embedding vector for each position, this vector contains not only the information of the position itself, but also the global information in the context. Under this mechanism, when the pre-trained language model generates an embedding vector for the tail marker of the prompt text, the embedding vector of the tail marker has actually integrated the information of all the preceding content in the entire prompt text, that is, the embedding vector of this tail position can effectively capture the semantics of the entire prompt text.
[0074] Therefore, the tail of the first prompt text includes a tail identifier for identifying the end position; the second embedding vector representing the search condition includes an embedding vector corresponding to the tail identifier of the first prompt text. The tail of the second prompt text includes a tail identifier for identifying the end position; and the third embedding vector representing the search term includes an embedding vector corresponding to the tail identifier of the second prompt text.
[0075] In S304, a predicted matching result is determined based on the similarity between the second embedding vector used to represent the search condition sample and the third embedding vector used to represent the search term sample.
[0076] In this step, the predicted matching result is determined by calculating the similarity between the second embedding vector (generated by the first pre-trained language model) and the third embedding vector (generated by the second pre-trained language model). The similarity can be calculated using cosine similarity, Euclidean distance, or other methods. The higher the similarity, the more the search condition sample matches the search item sample.
[0077] In S305 , the first pre-trained language model to be trained and the second pre-trained language model to be trained are jointly trained with minimizing the difference between the predicted matching result and the matching label as an optimization goal.
[0078] In this step, the difference between the predicted matching result and the actual matching label is used as the loss, and the first pre-trained language model and the second pre-trained language model are jointly optimized through back propagation to jointly improve the matching performance. Joint training ensures that the two pre-trained language models with different parameter amounts can complement each other, balance performance and computational efficiency, and improve the overall accuracy of the matching task. The two pre-trained language models with different parameter amounts continuously adjust their own model parameters through the optimization process, and gradually improve their prediction capabilities on new data.
[0079] Among them, the trained first pre-trained language model can be used as the first search model, and in the subsequent search process, an embedding vector for representing the search condition is generated based on the search condition; the trained second pre-trained language model can be used as the second search model, and in the subsequent search process, an embedding vector for representing the search term is generated based on the search term.
[0080] In some embodiments, see Figure 4A , Figure 4A A schematic diagram of a matching model training process is shown, and the matching model training method can be performed by an electronic device, including but not limited to a physical server, a server cluster, a cloud server, a smart phone / mobile phone, a tablet computer, a personal digital assistant (PDA), a laptop computer, and a desktop computer. The matching model training method includes:
[0081] In S401, a training sample set is obtained, the training sample set includes a number of search pair samples marked with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the matching degree between the search condition samples and the search item samples.
[0082] In this step, a training sample set annotated with matching labels is collected and prepared. The training sample set includes multiple pairs of search pair samples, each pair of search pair samples consists of a search condition sample and a search item sample, and each pair of search pair samples has a matching label to indicate the degree of matching between the search condition sample and the search item sample, such as 0 for no match, 1 for a complete match, or a continuous score to indicate the degree of matching, but not limited to this. The training sample set can come from actual user interaction data or be generated through manual annotation.
[0083] Supervised training of the matching model is achieved by obtaining pre-labeled samples, ensuring that the matching model has sufficient, well-labeled data to learn during training. By using labeled matching labels, the matching model can better learn how to distinguish which search terms and search items are matched and which are not matched.
[0084] In S402, a matching prompt text is generated based on the search pair sample and a preset third prompt template.
[0085] The matching hint text is used to prompt the matching model to judge the matching degree between the search condition sample and the search item sample. The matching hint text is used to provide context or guidance information for the matching model so that the matching model can more accurately judge the matching degree between the two.
[0086] Exemplarily, the format of the preset third prompt template is such as "[start] Please determine the matching degree of the given search condition and search item. The search condition is XX and the search item is XX[end]". But it is not limited to this. Among them, the head mark "[start]" is used to mark the starting position of the prompt text, and the tail mark "[end]" is used to mark the ending position of the prompt text.
[0087] In S403, the matching prompt text is input into the matching model to be trained, and the matching model includes a pre-trained language model and a neural network model: the pre-trained language model generates a first embedding vector for characterizing the degree of matching between the search condition sample and the search item sample based on the matching prompt text, and the neural network model obtains a predicted matching result based on the first embedding vector.
[0088] Among them, the matching model combines the powerful language understanding ability of the pre-trained language model and the flexible reasoning ability of the neural network model, so that the matching model can accurately capture the matching features in the input text and generate high-quality matching results.
[0089] Exemplarily, the pre-trained language model adopts the Transformer architecture, wherein the self-attention mechanism in the Transformer architecture allows the pre-trained language model to consider the information of all other positions in the sequence when processing each position of the input sequence, which means that when the pre-trained language model generates an embedding vector for each position, this vector contains not only the information of the position itself, but also the global information in the context. Under this mechanism, when the pre-trained language model generates an embedding vector for the tail identifier of the prompt text, the embedding vector of the tail identifier has actually integrated the information of all the preceding content in the entire prompt text, that is, the embedding vector of this tail position can effectively capture the semantics of the entire prompt text. Therefore, the tail of the matching prompt text includes a tail identifier for identifying the termination position; the first embedding vector includes an embedding vector corresponding to the tail identifier of the matching prompt text.
[0090] Exemplarily, the neural network model included in the matching model can adopt a variety of different structures, and the specific selection depends on the complexity of the task, the characteristics of the data, and the limitation of computing resources. For example, the neural network model can be a fully connected neural network, a convolutional neural network, a recurrent neural network, or a Transformer model, but is not limited thereto.
[0091] In S404, the matching model to be trained is trained with minimizing the difference between the predicted matching result and the matching label as the optimization goal.
[0092] In this step, the matching model is optimized and trained with the goal of minimizing the difference between the predicted matching results and the matching labels. The model parameters are adjusted through the back propagation algorithm so that the model's performance on the matching task is gradually improved after each iteration. The optimization process enables the matching model to continuously correct its own judgment, so that the difference between the predicted matching results and the matching labels is gradually reduced, thereby gradually improving the matching accuracy and robustness of the matching model. After sufficient training, the matching model can better perform matching tasks in practical applications and accurately judge the degree of matching between the search condition samples and the search item samples.
[0093] The trained matching model can be used to determine the matching degree between the search condition and the search item in the subsequent search process.
[0094] In a possible implementation, the neural network model described above may be a model that only performs a matching task, where the matching task is used to evaluate the degree of matching between the search condition sample and the search item sample based on the first embedding vector to obtain a predicted matching result.
[0095] In another possible implementation, see Figure 4B ( Figure 4B Taking a quality detection task as an example), the above neural network model can be a model based on multi-task learning, and the neural network model is used to perform a matching task and at least one quality detection task at the same time. In the neural network model, the matching task and the at least one quality detection task share model parameters. The matching task is used to evaluate the matching degree between the search condition sample and the search item sample according to the first embedding vector to obtain a predicted matching result; the quality detection task is used to detect the quality of the search item sample according to the first embedding vector to obtain a quality detection result.
[0096] Multi-task learning is a strategy for learning multiple related tasks simultaneously in a neural network model. By sharing some model parameters, multi-task learning can improve the performance of each task. In multi-task learning, different tasks share some model parameters (such as the underlying feature extraction layer), and the neural network model can jointly learn more general and robust feature representations through feedback from different tasks during the training process. In multi-task learning, the learning results of one task can assist another task. For example, the quality inspection task may identify some features in the search term sample (such as the clarity of the text, the completeness of the information, etc.), which are also key factors in the matching task. When the neural network model learns better features in the quality inspection task, due to the sharing of some model parameters, these features can be directly used in the matching task, improving the accuracy of the judgment of the degree of matching between the search condition sample and the search term sample. In addition, the adversarial and collaborative relationship between different tasks can help the neural network model discover more robust feature representations. For example, the quality inspection task may make the neural network model more sensitive to bad or ambiguous data, thereby automatically filtering out the negative impact of these data in the matching task. This collaboration can ensure that the neural network model has taken into account the quality factors of the data when making matching decisions, thereby reducing the possibility of misjudgment of matching.
[0097] That is to say, through multi-task learning, the matching task can benefit from related tasks (such as quality inspection tasks) and learn more comprehensive and accurate feature representations, thereby significantly improving the accuracy and robustness of the matching task.
[0098] Based on the needs of multi-task learning, the training sample set used to train the matching model includes: a number of search pair samples annotated with matching labels and at least one quality label corresponding to at least one quality detection task, the search pair samples include search condition samples and search item samples, the matching labels are used to describe the degree of matching between the search condition samples and the search item samples, and different quality labels are used to describe the quality of the search item samples in different evaluation dimensions.
[0099] Then, in the training process of the matching model, step S403 includes: inputting the matching prompt text into the matching model to be trained, the matching model including a pre-trained language model and a neural network model: the pre-trained language model generates a first embedding vector for characterizing the degree of matching between the search condition sample and the search item sample based on the matching prompt text, and the neural network model simultaneously performs a matching task and at least one quality detection task based on the first embedding vector to obtain a predicted matching result and at least one quality detection result.
[0100] Step S404 includes: training the matching model to be trained with minimizing the difference between the predicted matching result and the matching label and minimizing the difference between the quality detection result and the quality label as optimization goals.
[0101] In this step, the matching model is optimized and trained with the goal of minimizing the difference between the predicted matching results and the matching labels, as well as the difference between the quality detection results and the quality labels. The model parameters are adjusted through the back propagation algorithm so that the matching model's performance on the matching task and the quality detection task is gradually improved after each iteration. The optimization process enables the matching model to continuously correct its own judgment, so that the difference between the predicted matching results and the matching labels, and the difference between the quality labels are gradually reduced, thereby gradually improving the matching accuracy and robustness of the matching model. After sufficient training, the matching model can better perform matching tasks in practical applications and accurately judge the degree of matching between the search condition samples and the search item samples.
[0102] The search items include but are not limited to at least one of documents, pictures, videos and audios.
[0103] Exemplarily, when the search term is a document, at least one of the following quality detection tasks can be performed: (1) Detect whether the document comes from an authoritative or trustworthy source; (2) Detect the completeness of the document content and the rationality of its structure; (3) Detect the timeliness of the document to determine whether it is the latest information or whether it is still valid within a certain period of time; (4) Evaluate the originality of the document to detect whether there is plagiarism or excessive citation of other documents. However, this is not limited to this. Through the quality detection task of the document, the neural network model can more accurately evaluate the overall value and credibility of the document, thereby improving the performance in the matching task.
[0104] For example, if the search item is a picture, at least one of the following quality inspection tasks can be performed: (1) inspecting whether the picture is clear, has noise, blur, etc.; (2) evaluating whether the content of the picture is related to the subject indicated by the search condition; (3) evaluating whether the color of the picture is natural and whether the exposure is appropriate. However, the present invention is not limited to these.
[0105] For example, if the search item is a video, at least one of the following quality detection tasks may be performed: (1) detecting the resolution and frame rate of the video to evaluate its playback quality; and (2) evaluating whether the video content is related to the topic indicated by the search condition. However, the present invention is not limited thereto.
[0106] Exemplarily, when the search item is audio, at least one of the following quality detection tasks can be performed: (1) detecting the clarity of the audio and the presence of background noise; (2) detecting the duration and rhythm of the audio to determine whether it is suitable for the subject indicated by the search condition. But not limited to this. Through the quality detection tasks of pictures, videos and audio, the neural network model can screen out high-quality multimedia content and match it with the search condition more accurately. High-quality multimedia is not only more visually and auditorily attractive, but also can convey information more effectively, thereby improving the overall performance of the matching task.
[0107] It is understandable that the electronic device used to train the model and the electronic device used to perform the search method can be the same device or different devices, and this embodiment does not impose any restrictions on this. For example, the model training process can be performed by a certain electronic device, and then the trained model can be deployed to another electronic device used to perform the search method.
[0108] The following is an exemplary description of the search method provided in this specification:
[0109] See also Figure 5 , Figure 5 A schematic diagram of a search method is shown, which can be performed by an electronic device (such as Figure 1A The search method includes:
[0110] In S501, the search condition entered by the user in the search box is obtained.
[0111] In this step, the search condition can be a keyword, phrase or complete query statement entered by the user in the search box; or the search condition can also be data in other modes, such as images, videos or audio uploaded by the user through the search box, and this implementation does not impose any restrictions on this. For example, the user may enter "smart watch function" as the search condition. The server will perform subsequent search processes based on the search condition. Among them, the user can input the search condition through a physical input device or a virtual input device such as a keyboard, mouse, stylus, voice acquisition device, image upload control, audio upload control or physical upload control.
[0112] In S502, a plurality of target search terms related to the search condition are retrieved from a database pre-stored with a plurality of search terms.
[0113] In this step, the server retrieves target search items related to the search conditions input by the user from a database storing a large number of search items. The search items can be one or more types of data such as text, picture, video or audio.
[0114] In S503, each matching prompt text is generated based on the search conditions and each target search item; the matching prompt text is used to prompt the trained matching model to determine the degree of matching between the search conditions and each target search item; the matching model includes a pre-trained language model and a neural network model.
[0115] In this step, see Figure 6Based on the search conditions and each target search item, a matching prompt text is generated for each target search item; the matching prompt text is used to prompt the trained matching model to judge the matching degree between the search conditions and the target search item.
[0116] The matching prompt text may be generated based on a search pair consisting of a search condition and each target search item and a preset third prompt template to ensure a unified format and structure.
[0117] Exemplarily, the format of the preset third prompt template is such as "[start] Please determine the degree of match between the given search conditions and search items. The search condition is XX and the search item is XX[end]". But it is not limited to this. Among them, the header identifier "[start]" is used to identify the starting position of the prompt text, and the tail identifier "[end]" is used to identify the ending position of the prompt text. The server can embed the search conditions and target search items into the predefined third prompt template to generate matching prompt text, thereby providing context for the subsequent matching model and helping the matching model to make matching judgments more accurately.
[0118] In S504, each matching prompt text is input into the matching model, so that the pre-trained language model generates a first embedding vector for characterizing the degree of matching between the search condition and each target search item based on the matching prompt text, and the neural network model obtains the matching result based on the first embedding vector.
[0119] In this step, see Figure 6 The matching model consists of a pre-trained language model and a neural network model. The pre-trained language model has been trained on large-scale data and can capture complex semantic information in the language, thereby improving the accuracy of matching, while the neural network model can further refine the matching results by learning specific patterns and features. The combination of the pre-trained language model and the neural network model can more accurately evaluate the degree of semantic matching between the search conditions and the target search terms, thereby providing more relevant search results.
[0120] Exemplarily, the pre-trained language model uses the Transformer architecture. When the pre-trained language model generates an embedding vector for the tail mark of the matching prompt text, the embedding vector of the tail mark has actually integrated the information of all the preceding contents in the entire matching prompt text, that is, the embedding vector of the tail position can effectively capture the semantics of the entire matching prompt text. Therefore, the tail of the matching prompt text includes a tail mark for identifying the end position; the first embedding vector includes an embedding vector corresponding to the tail mark of the matching prompt text.
[0121] In S505, based on the matching results between the search condition and each target search item, the search result of the search condition is output.
[0122] In this step, the server can sort the target search items based on the matching results between each target search item and the search conditions, and output them to the user. These sorted target search items are the search results of the search conditions, and are usually arranged from high to low according to the degree of matching. The most relevant target search items will be displayed in front, providing users with results that meet their search conditions, thereby improving search accuracy and user experience.
[0123] The search method provided in this embodiment achieves accurate matching of search terms by combining the advantages of pre-trained language models and neural network models. It can not only understand the semantics of search conditions, but also effectively evaluate the degree of matching with target search terms in the database, thereby providing users with more accurate and relevant search results, which helps to improve the performance of search engines and user satisfaction.
[0124] In some embodiments, see Figure 6 , here is an exemplary description of the retrieval process of multiple target search items related to the search conditions:
[0125] First, a pre-trained second search model can be used to process several search items in the database in advance (for example, in an offline environment) to obtain a database pre-stored with several third embedding vectors for characterizing the search items. The server can perform the following processing in advance: embed each search item into a preset second prompt template, generate a second prompt text corresponding to each search item, the second prompt text is used to prompt the pre-trained second search model to generate a third embedding vector for characterizing the search item, and then input the second prompt text into the second search model, so that the second search model generates a third embedding vector for characterizing the search item based on the second prompt text. Exemplarily, the tail of the second prompt text includes a tail identifier for identifying the end position; the third embedding vector characterizing the search item includes an embedding vector corresponding to the tail identifier of the second prompt text. The second prompt template can refer to the above description and will not be repeated here. In this embodiment, by using the pre-trained second search model to pre-process the search items in the database, the third embedding vector is generated and stored in advance, and the target search item related to the search condition can be quickly determined in the actual search process. This pre-processing and storage strategy reduces the complexity of online calculation and improves the response speed of the search process, especially in the case of large-scale databases.
[0126] During the search process for the search criteria, see Figure 6, the server can use the pre-trained first search model to process the search condition and generate a second embedding vector for representing the search condition. For example, the search condition can be embedded in a preset first prompt template to generate a first prompt text, and the first prompt text is used to prompt the first search model to generate a second embedding vector for representing the search condition; then the first prompt text is input into the first search model, so that the first search model generates a second embedding vector for representing the search condition based on the first prompt text; wherein the tail of the first prompt text includes a tail identifier for identifying the end position; the second embedding vector representing the search condition includes an embedding vector corresponding to the tail identifier of the first prompt text. The first prompt template can be found in the above description and will not be repeated here.
[0127] Then, a plurality of candidate third embedding vectors located within a preset range centered on the second embedding vector can be determined from a database pre-stored with a plurality of third embedding vectors for respectively representing a plurality of search terms, and then the similarity between the second embedding vector and each candidate third embedding vector is calculated respectively, and finally the search terms corresponding to the candidate third embedding vectors with similarity higher than a preset threshold are determined as target search terms. The preset range and the preset threshold can be specifically set according to the actual application scenario, and this embodiment does not impose any limitation on this.
[0128] In this embodiment, the search conditions and search items are represented by embedded vectors, and similarity calculations can be performed in high-dimensional space. The embedded vectors can capture the semantic information of the search conditions and search items, thereby more accurately evaluating the degree of match between the search conditions and the search items. By calculating the similarity between the second embedded vector and the candidate third embedded vector, the target search item most relevant to the search condition can be accurately identified, and search results that better meet user needs can be provided. In addition, since the third embedded vector used to characterize the search item is completed in an offline environment, the server only needs to perform simple embedded vector lookup and similarity calculation when retrieving the target search item related to the search condition, avoiding a large amount of computing burden during online processing, which not only improves scalability, allowing it to process larger data sets, but also improves stability and reduces the possibility of delays and errors in online processing.
[0129] In a possible implementation, the first search model and the second search model may be the same model.
[0130] The first search model and the second search model are obtained by fine-tuning the same pre-trained language model based on several search pair samples annotated with matching labels. The search pair samples include search condition samples and search item samples. The matching labels are used to describe the degree of matching between the search condition samples and the search item samples. The optimization goals in the fine-tuning process include: minimizing the difference between the predicted matching results and the matching labels; the predicted matching results are determined based on the similarity between the second embedding vector used to represent the search condition samples and the third embedding vector used to represent the search item samples. The second embedding vector used to represent the search condition samples is generated by the pre-trained language model to be fine-tuned based on the first prompt text corresponding to the search condition samples, and the third embedding vector used to represent the search item samples is generated by the pre-trained language model to be fine-tuned based on the second prompt text corresponding to the search item samples. For details about the fine-tuning process, please refer to the above. Figure 2 The description of the embodiments will not be repeated here.
[0131] In another possible implementation, the first search model and the second search model are different models, and the parameter amount of the first search model is smaller than the parameter amount of the second search model.
[0132] The first search model and the second search model are obtained by jointly fine-tuning different pre-trained language models based on a number of search pair samples annotated with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the degree of matching between the search condition samples and the search item samples. The different pre-trained language models include a first pre-trained language model and a second pre-trained language model, and the number of parameters of the first pre-trained language model is less than the number of parameters of the second pre-trained language model.
[0133] Among them, the optimization goals in the joint fine-tuning process include: minimizing the difference between the predicted matching result and the matching label; the predicted matching result is determined based on the similarity between the second embedding vector used to represent the search condition sample and the third embedding vector used to represent the search term sample, the second embedding vector used to represent the search condition sample is generated by the first pre-trained language model to be fine-tuned based on the first prompt text corresponding to the search condition sample, and the third embedding vector used to represent the search term sample is generated by the second pre-trained language model to be fine-tuned based on the second prompt text corresponding to the search term sample. For the joint fine-tuning process, please refer to the above Figure 3 The description of the embodiments will not be repeated here.
[0134] In some embodiments, see Figure 6 After retrieving multiple target search items related to the search conditions, the server can determine the degree of matching between the search conditions and each target search item based on the matching model, so as to sort the relevance of the multiple target search items according to the degree of matching, ensuring that the most relevant target search item is ranked first.
[0135] In one implementation, the matching model is obtained by supervised training based on search pair samples annotated with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the degree of matching between the search condition samples and the search item samples; the optimization goal of the supervised training process includes: minimizing the difference between the predicted matching results and the matching labels; wherein the predicted matching results are generated by the matching model to be trained based on the matching prompt text corresponding to the search pair samples. For the supervised training process, please refer to the above-mentioned Figure 4A The description of the embodiments will not be repeated here.
[0136] In another implementation, the neural network model is a model based on multi-task learning, and the neural network model is used to simultaneously perform a matching task and at least one quality detection task; in the neural network model, the matching task and at least one quality detection task share some model parameters; wherein the matching task is used to evaluate the degree of matching between the search condition and the target search item according to the first embedding vector to obtain a matching result; the quality detection task is used to detect the quality of the target search item according to the first embedding vector to obtain a quality detection result.
[0137] The matching model is obtained by supervised training based on search pair samples annotated with matching labels and at least one quality label. The search pair samples include search condition samples and search item samples. The matching labels are used to describe the degree of matching between the search condition samples and the search item samples. Different quality labels are used to describe the quality of the search item samples in different evaluation dimensions. The optimization goals of the supervised training process include: minimizing the difference between the predicted matching results and the matching labels, and minimizing the difference between the quality detection results and the quality labels; wherein the predicted matching results and the quality detection results are generated by the matching model to be trained based on the matching prompt text corresponding to the search pair samples. For details about the supervised training process, please refer to the above. Figure 4B The description of the embodiments will not be repeated here.
[0138] Exemplarily, after obtaining the matching results between the search conditions and each target search item based on any of the above matching models, the server can determine the display order of each target search item based on the matching results between the search conditions and each target search item, so as to display each target search item in the search page according to the display order. The display order can be arranged from high to low according to the matching degree indicated by the matching results, ensuring that the most relevant search items are displayed to the user first, allowing the user to find the required information faster and improving the user's search experience. The display order also reflects the relevance of the target search item to the user's search conditions, helping the user to intuitively understand which results are most relevant, thereby improving the effectiveness of the search results.
[0139] For example, the server is based on Figure 4B After the matching model shown obtains the matching results between the search condition and each target search item, and at least one quality detection result of each target search item, it can also output the search results of the search condition based on the matching results between the search condition and each target search item, and the quality detection results of each target search item. For example, the display order of each target search item can be comprehensively determined based on the matching results between the search condition and each target search item, and the quality detection results of each target search item, so as to display each target search item in the search page according to the display order. In this embodiment, the server not only considers the matching results between the search condition and the target search item, but also incorporates the quality detection results of the target search item into the decision of the display order, so as to more comprehensively evaluate which search items are most worthy of display, reduce the possibility of low-quality content occupying a prominent position, and users will not only see the content most relevant to their query, but also see higher-quality content, thereby improving the user experience.
[0140] In some embodiments, see Figure 1B as well as Figure 7 The embodiment of this specification also provides another search method, which is applied to the client (or terminal) shown in FIG. 1 , and the method includes:
[0141] In S701, the search condition entered by the user in the search box is obtained.
[0142] The user enters the search criteria in the search box, which is the starting point of the entire search process. The user's search criteria can be simple keywords, complex phrases, or even natural language questions. For example, in the medical field, the user may enter "latest treatment plan for diabetes" to find relevant information.
[0143] In S702, the search condition is sent to the server, so that the server executes the above-mentioned search method based on the search condition.
[0144] When the user clicks the search button or presses the Enter key or other confirmation controls, the search criteria will be sent to the server. After receiving the search criteria, the server begins to execute a complex search algorithm, including steps such as data retrieval and text matching.
[0145] In S703, the search results returned by the server are received and displayed on the search page.
[0146] In this step, after receiving the search results returned by the server, the client displays them on the search page. The user can browse the relevant information step by step according to the display order and quickly find the most relevant content.
[0147] In an exemplary application scenario, the search condition is a search condition for medical documents; the search results include at least one medical document.
[0148] For example, suppose a user enters a search condition in the search box, such as "latest treatment method for diabetes". The client sends the search condition to the server.
[0149] The server first retrieves multiple target medical documents related to "latest treatment methods for diabetes" from a database that pre-stores a large number of medical documents, research papers, medical records, and other medical documents. Specifically, the server can use the pre-trained first search model to process the search condition "latest treatment methods for diabetes" to generate a second embedding vector for representing the search condition. The medical documents in the database correspond to a predetermined third embedding vector; the server can determine multiple candidate third embedding vectors located within a preset range centered on the second embedding vector from a number of third embedding vectors for representing medical documents; calculate the similarity between the second embedding vector and each candidate third embedding vector; and determine the medical document corresponding to the candidate third embedding vector whose similarity is higher than a preset threshold as the target medical document.
[0150] Next, the server generates matching prompt text based on the search condition "latest treatment methods for diabetes" and each target medical document (such as a medical paper). For example, the prompt text may be "[start] Please determine the relevance of the following article to 'latest treatment methods for diabetes': [content of the target medical document][end]". Each matching prompt text is input into a pre-trained matching model, which includes a pre-trained language model and a neural network model, and is responsible for generating a first embedding vector for characterizing the degree of matching between the query condition and each target query item, and finally generating a matching result based on the first embedding vector.
[0151] Among them, the neural network model is a model based on multi-task learning, and the neural network model is used to perform matching tasks and at least one quality detection task simultaneously. The matching task is used to evaluate the degree of match between the search condition "latest treatment methods for diabetes" and the target medical document according to the first embedding vector to obtain a matching result; the quality detection task is used to detect the quality of the target medical document according to the first embedding vector to obtain a quality detection result. In medical scenarios, quality detection tasks may include evaluating whether the source of the target medical document is authoritative (such as whether it is from a top medical journal), the publication time of the article or material (the newer the better), and whether the content has been peer-reviewed. These quality detection tasks ensure that only high-quality and reliable medical information is displayed.
[0152] After obtaining the matching results and quality detection results corresponding to the target medical documents, the server comprehensively considers the impact of the two to determine the order of the target medical documents. Suppose that two papers are highly relevant to "The Latest Treatment Methods for Diabetes", but one is from a top medical journal and was published in recent months, while the other is from a less well-known journal and is older, the server can determine that the first paper is displayed first, and the second paper is displayed later. After determining the display order of each target medical document, the server returns the retrieved target medical documents and their display order to the client. Finally, the client displays each target medical document on the search page according to the display order of the target medical documents, so that users can see the latest, most relevant and authoritative medical information.
[0153] The various technical features in the above embodiments can be arbitrarily combined as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, any combination of the various technical features in the above embodiments also falls within the scope of this specification.
[0154] Based on the same concept as the above method, an embodiment of this specification also provides an electronic device, including: a processor; a memory for storing processor executable instructions; wherein the processor implements any of the above methods by running the executable instructions.
[0155] Figure 8 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 8 At the hardware level, the device includes a processor 802, an internal bus 804, a network interface 806, a memory 808, and a non-volatile memory 810, and may also include hardware required for other functions. One or more embodiments of this specification may be implemented based on software, such as the processor 802 reading the corresponding computer program from the non-volatile memory 810 into the memory 808 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0156] Exemplarily, the search device can be applied to Figure 8 The device shown in the figure is used to implement the technical solution of this specification. The search device may include:
[0157] A search condition acquisition module is used to acquire the search condition entered by the user in the search box;
[0158] A retrieval module, used to retrieve a plurality of target search items related to the search condition from a database pre-stored with a plurality of search items;
[0159] A matching prompt text generation module, used to generate each matching prompt text based on the search condition and each target search item; the matching prompt text is used to prompt the trained matching model to judge the matching degree between the search condition and each target search item; the matching model includes a pre-trained language model and a neural network model;
[0160] A matching module, configured to input each of the matching prompt texts into the matching model, so that the pre-trained language model generates a first embedding vector for representing the degree of matching between the search condition and each of the target search items based on the matching prompt text, and the neural network model obtains a matching result based on the first embedding vector;
[0161] The search result output module is used to output the search result of the search condition based on the matching results between the search condition and each of the target search items.
[0162] As for the device embodiment, since it basically corresponds to the method embodiment, the relevant parts may refer to the partial description of the method embodiment.
[0163] Based on the same concept as the above method, this specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0164] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change 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), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0165] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.
[0166] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information.
[0167] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A search method, comprising: Get the search criteria entered by the user in the search box; Retrieving a plurality of target search items related to the search condition from a database pre-stored with a plurality of search items; Based on the search condition and each of the target search items, each matching prompt text is generated; the matching prompt text is used to prompt the trained matching model to judge the matching degree between the search condition and each of the target search items; the matching model includes a pre-trained language model and a neural network model; Input each of the matching prompt texts into the matching model, so that the pre-trained language model generates a first embedding vector for representing the degree of matching between the search condition and each of the target search items based on the matching prompt text, and the neural network model obtains a matching result based on the first embedding vector; Based on the matching results between the search condition and each of the target search terms, a search result of the search condition is output.
2. The method according to claim 1, wherein the step of retrieving a plurality of target search terms related to the search condition from a database pre-stored with a plurality of search terms comprises: The search condition is processed using a pre-trained first search model to generate a second embedding vector for representing the search condition; wherein the database is used to store a plurality of third embedding vectors representing the search terms; Determining, from the plurality of third embedding vectors for representing the search term, a plurality of candidate third embedding vectors located within a preset range centered on the second embedding vector; Calculating the similarity between the second embedding vector and each of the candidate third embedding vectors respectively; The search item corresponding to the candidate third embedding vector whose similarity is higher than a preset threshold is determined as the target search item.
3. The method according to claim 2, wherein the step of processing the search condition using the pre-trained first search model comprises: Embed the search condition into a preset first prompt template to generate a first prompt text, wherein the first prompt text is used to prompt the first search model to generate a second embedding vector for representing the search condition; The first prompt text is input into the first search model so that the first search model generates a second embedding vector for representing the search condition based on the first prompt text.
4. The method according to claim 3, obtaining the third embedding vector comprises: Embed each of the search terms into a preset second prompt template to generate a second prompt text corresponding to each of the search terms, wherein the second prompt text is used to prompt a pre-trained second search model to generate a third embedding vector for representing the search term; The second prompt text is input into the second search model so that the second search model generates a third embedding vector for representing the search term based on the second prompt text.
5. The method according to claim 4, wherein the first search model and the second search model are the same model; in, The first search model and the second search model are obtained by fine-tuning the same pre-trained language model based on a number of search pair samples annotated with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the degree of matching between the search condition samples and the search item samples; The optimization objectives during fine-tuning include: minimizing the difference between the predicted matching result and the matching label; The predicted matching result is determined based on the similarity between a second embedding vector used to characterize the search condition sample and a third embedding vector used to characterize the search term sample, wherein the second embedding vector used to characterize the search condition sample is generated by the pre-trained language model to be fine-tuned based on a first prompt text corresponding to the search condition sample, and the third embedding vector used to characterize the search term sample is generated by the pre-trained language model to be fine-tuned based on a second prompt text corresponding to the search term sample.
6. The method according to claim 4, wherein the first search model and the second search model are different models, and the parameter amount of the first search model is smaller than the parameter amount of the second search model; in, The first search model and the second search model are obtained by jointly fine-tuning different pre-trained language models based on a number of search pair samples annotated with matching labels, the search pair samples include search condition samples and search item samples, and the matching labels are used to describe the degree of matching between the search condition samples and the search item samples; The different pre-trained language models include a first pre-trained language model and a second pre-trained language model, and the parameter amount of the first pre-trained language model is smaller than the parameter amount of the second pre-trained language model; The optimization objectives in the joint fine-tuning process include: minimizing the difference between the predicted matching result and the matching label; The predicted matching result is determined based on the similarity between a second embedding vector used to characterize the search condition sample and a third embedding vector used to characterize the search term sample, wherein the second embedding vector used to characterize the search condition sample is generated by the first pre-trained language model to be fine-tuned based on a first prompt text corresponding to the search condition sample, and the third embedding vector used to characterize the search term sample is generated by the second pre-trained language model to be fine-tuned based on a second prompt text corresponding to the search term sample.
7. A search method, applied to a client, comprising: Get the search criteria entered by the user in the search box; Sending the search condition to a server, so that the server executes the search method according to any one of claims 1 to 6 based on the search condition; The search results returned by the server are received and displayed on the search page.
8. An electronic device comprising: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method according to any one of claims 1 to 7 by executing the executable instructions.
9. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Cited By
Searching method and device and arbitration problem searching method
CN119719313A
Data matching display method and device, computer equipment and storage medium
CN121210776A