Searching method and device, electronic equipment and storage medium
By using sample corpus in multiple search scenarios to train the corpus generation model in the search model, the problem of high search model training costs is solved, effective search services in multiple search scenarios are achieved, and training costs and time are reduced.
Patent Information
- Application Number
- CN202310143990.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, the training cost of search models gradually increases, which hinders the promotion and development of search services, and model training data and application data for different search scenarios cannot be reused, resulting in a significant increase in the number and cost of models.
Using a corpus generation model trained based on sample corpus generated in at least two search scenarios, by converting the media content search task into a corpus prediction task, the model's dependence on the scenario is reduced, training time is shortened, and costs are reduced.
It realizes the basic knowledge of media content search in multiple search scenarios, shortens the training time of the search model, reduces the training cost, and improves the convergence speed and training of the search model through the reuse of the semantic generation network in the pre-training stage. Effect.
Smart Images

Figure CN118535673A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence, and in particular to search methods, devices, electronic devices, and storage media. Background Art
[0002] With the increasing development of media technology and Internet technology, the recommendation and search of media content have become the main content of Internet applications. In order to meet people's search needs for media content, Internet applications can provide a variety of search services to meet the needs of multi-scenario search. However, in the related technology, each search scenario needs to train a corresponding search model. The training process, training data and application data of the search models corresponding to different search scenarios cannot be reused. With the expansion of search scenarios, the number of search models is increasing, and the training cost of search models is also increasing. The use of search models with high training costs has also hindered the effective promotion and development of search services. Summary of the invention
[0003] In order to solve at least one of the above-mentioned technical problems, the embodiments of the present application provide a search method, an apparatus, an electronic device and a storage medium to solve the problem of increasing training costs of search models in related technologies, and provide an effective solution for search services based on low-cost search models.
[0004] On the one hand, an embodiment of the present application provides a search method, the method comprising:
[0005] When a search term is obtained, determining search scenario information to which the search term is adapted according to the search term;
[0006] Generate search corpus according to the search term and the search scenario information;
[0007] Inputting the search corpus into a search model to obtain search results;
[0008] The search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, wherein the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios.
[0009] On the other hand, an embodiment of the present application provides a search device, the device comprising:
[0010] A search information acquisition module, configured to determine search scenario information adapted to the search term based on the search term when the search term is acquired;
[0011] A search module, configured to generate a search corpus according to the search term and the search scenario information; and input the search corpus into a search model to obtain search results;
[0012] The search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, wherein the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios.
[0013] On the other hand, an embodiment of the present application provides a computer-readable storage medium, in which at least one instruction or at least one program is stored, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned search method.
[0014] On the other hand, an embodiment of the present application provides an electronic device, comprising at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the above-mentioned search method by executing the instructions stored in the memory.
[0015] On the other hand, an embodiment of the present application provides a computer program product, including a computer program or instructions, which implement the above-mentioned search method when executed by a processor.
[0016] Embodiments of the present application provide a search method, device, electronic device, and storage medium. The search model used in the method is a corpus generation model obtained by training based on sample corpora generated in at least two search scenarios, wherein the sample corpus includes sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios. The training process of the search model uses sample corpora in multiple search scenarios, so the search model has the basic knowledge of performing media content search in each search scenario, and the search model is a corpus generation model. By converting the media content search task into a corpus prediction task, the dependence of the search model on the scenario can be reduced, so that the training process of the search model in the specific scenario stage can shorten the training time and reduce the training cost of the search model. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or related technologies, the following is a brief introduction to the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 1 is a schematic diagram of search results of media contents corresponding to three search scenarios in a video vertical search scenario provided in an embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of the implementation framework of the search method provided in the embodiment of the present application;
[0020] Figure 3 It is a flowchart of a search method provided in an embodiment of the present application;
[0021] Figure 4 It is a schematic diagram of the search model training method provided in an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of a semantic destruction method provided in an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a recording method of a second sample corpus provided in an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of an end-to-end search provided in an embodiment of the present application;
[0025] Figure 8 is a block diagram of a search device provided in an embodiment of the present application;
[0026] Fig. 9 It is a schematic diagram of the hardware structure of a device provided in an embodiment of the present application for implementing the method provided in an embodiment of the present application;
[0027] Fig.10 It is a block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the embodiments of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0030] In order to make the purpose, technical solution and advantages disclosed in the embodiments of the present application more clearly understood, the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the embodiments of the present application and are not used to limit the embodiments of the present application.
[0031] In the following, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "multiple" means two or more. In order to facilitate the understanding of the above-mentioned technical solutions and the technical effects produced by the embodiments of the present application, the embodiments of the present application first explain the relevant professional terms:
[0032] Cloud technology: refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing. It is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application, which can form a resource pool and be used on demand, flexibly and conveniently. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, each resource may have its own identification mark in the future, and all resources need to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0033] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is also the study of the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0034] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / switching systems, mechatronics and other technologies. Artificial intelligence software technology includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0035] Machine learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0036] Deep learning: The concept of deep learning originates from the study of artificial neural networks, which belongs to the field of machine learning. A multi-layer perceptron with multiple hidden layers is a deep learning structure. Deep learning discovers distributed feature representations of data by combining low-level features to form more abstract high-level representations of attribute categories or features.
[0037] Convolutional Neural Networks: CNN. It is a type of feedforward neural network with deep structure and convolutional calculation, and is one of the representative algorithms of deep learning. Convolutional neural network has the ability of representation learning and can classify input information in a translation-invariant manner according to its hierarchical structure, so it is also called translation-invariant artificial neural network.
[0038] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes corpus processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies. Generally, it is generally believed that NLP = NLU + NLG, NLU, namely Natural Language Understanding, refers to natural language understanding, and NLG, namely Natural Language Generation, refers to natural language generation. The two complement each other. Only by doing a good job in NLU can you do a good job in NLG, and only by doing a good job in NLU and NLG can you do a good job in NLP.
[0039] Transformer: A model that uses a self-attention structure to extract the interaction between each element of a sequence. It is widely used in natural language processing, image processing, and time series prediction. Transformer is a model based on a multi-head attention mechanism, which is essentially an Encoder-Decoder model. The input of the TransformerEncoder model is the word embedding representation of a sentence and its corresponding position encoding information. The core layer of the model is a multi-head attention mechanism. The multi-head attention mechanism uses multiple attention mechanisms to perform separate calculations to obtain more levels of semantic information, and then splices and combines the results obtained by each attention mechanism to obtain the final result. The Add&Norm layer sums and normalizes the input and output of the Multi-Head Attention layer, passes it to the Feed Forward layer, and finally performs another Add&Norm process to output the final word vector matrix. Transformer is a combination of full connection (or one-dimensional convolution) plus Attention. The algorithm has good parallelism and is in line with the current hardware environment.
[0040] The full name of the BERT model is Bidirectional Encoder Representations from Transformer. The BERT model is an encoder of a bidirectional Transformer. The goal is to use large-scale unlabeled corpus training to obtain a representation of the text that contains rich semantic information, that is, the semantic representation of the text, and then fine-tune the semantic representation of the text in a specific NLP task, and finally apply it to the NLP task. The main input of the BERT model is the original word vector of each word in the text, and the output is the vector representation of each word in the text after integrating the semantic information of the entire text.
[0041] When searching for media content, the related technology can obtain media content that is suitable for the search scenario and highly relevant to the search term based on the search term and the search scenario. In other words, the search results of the media content are not only relevant to the search term, but also highly relevant to the search scenario.
[0042] Please refer to Figure 1 , which shows a schematic diagram of search results of media content corresponding to three search scenarios in video vertical search scenarios. Figure 1 (1) shows the search results when performing main demand prediction in the video vertical search scenario. Main demand prediction is a search scenario in the video vertical search scenario. The main purpose of this search scenario is to accurately identify the fine-grained intent related to the search term based on the search term, so as to output the corresponding search results according to the fine-grained intent. For example, if the search term is represented as Query1, and Query1 is the name of a movie, the corresponding fine-grained intent can be identified as wanting to watch the movie named Query1, and the clear main demand result corresponding to Query1 is defined as the main demand, and the main demand result - the movie named Query1, is displayed at the top of the result page. This search method can quickly and intuitively hit the user's viewing needs for media content and improve the click-through rate of media content.
[0043] Figure 1(2) The search results in the intent search scenario are displayed. The main purpose of intent search is to accurately identify the coarse-grained intent related to the search term based on the search term, so as to output the corresponding search results according to the coarse-grained intent. For example, if the search term is represented as Query2, and Query2 is the category name of a type of film, the corresponding coarse-grained intent can be identified as the desire to watch the film of the category name Query2, identify the film and television results related to Query2, and sort the results and display them on the result page. At the same time, filter items can be given to further help users select films. These filter items are not limited, as long as they can help users further narrow the search scope. For example, they can be year, sub-category under Query2 category, rating, popularity, etc. This search method can improve the recommendation effect of media content by optimizing the relevance between the recommended media content and the user's intent when the user's viewing demand for media content is a relatively broad demand.
[0044] Figure 1 (3) The search results in the comprehensive search scenario are displayed. The main purpose of the comprehensive search is to accurately search for film and television works related to the search terms based on the search terms. Other media content related to the film and television works can also be searched, such as media content that belongs to the same author as the film and television work, or media content that is similar to the film and television work. For example, if the search term is represented as Query3, and Query3 is the name of a TV series, the TV series can be displayed on the result page, and some other similar TV series can also be displayed. This search method makes the presentation of the result page more diverse and can also improve the comprehensive click-through rate of media content and improve the media content recommendation effect.
[0045] It can be seen that search results are not only related to search terms, but also to search scenarios. Different search scenarios correspond to different search tasks. Different search tasks in related technologies need to train corresponding search models respectively, so as to achieve the technical purpose of obtaining search results that meet the search scenarios according to the corresponding search scenarios and search terms. For example, related technologies usually use technical solutions based on text keyword recall or model generalization combined with deep semantic matching to build search models. The search model built based on this idea does not add search scenario information from the construction link of training data during training, which makes it impossible for the search model to adapt the search scenario based on the input data. Therefore, it is difficult for the search model to adapt to multiple search scenarios and can only be applied to specific search scenarios. When the search scenario changes, the input data cannot reflect the change of the search scenario, and the search model itself cannot adaptively adapt the search scenario based on the input data, resulting in a significant decrease in the search performance of the search model after the search scenario changes. As search scenarios continue to grow, the number of search models that are not adaptable to multiple search scenarios will need to increase as the number of search scenarios grows. Moreover, different search models may use different training data and application data, and the training and use processes of each search model cannot be reused.
[0046] Undoubtedly, the related technology of training a corresponding search model for each search scenario will lead to a significant increase in the training cost and application cost of the search model. The inability to reuse data caused by the lack of intercommunication between search models will further increase the training cost and application cost. In view of this, the embodiments of the present application provide a search method, device, electronic device and storage medium.
[0047] The search model used in the method is a corpus generation model trained based on sample corpora generated in at least two search scenarios, wherein the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios. The training process of the search model uses sample corpora in multiple search scenarios, so the search model has the basic knowledge of performing media content search in various search scenarios, and the search model is a corpus generation model. By converting the media content search task into a corpus prediction task, the search model's dependence on the scenario can be reduced, so that the training process of the search model in the specific scenario stage can shorten the training time and reduce the training cost of the search model.
[0048] During the training process of the search model, the embodiment of the present application can construct the original corpus text based on the media content information in the search space corresponding to multiple search scenarios. After the original corpus text is semantically destroyed, a first sample corpus can be obtained. The initial network is used to generate corpus for the first sample corpus, and the initial network is trained based on the difference between the generated result and the original corpus text to obtain a semantic generation network, which has at least two capabilities. The first capability is a strong predictive ability for the media content information in the search space, that is, the semantic generation network has completed the learning of each media content information in the search space, and is sensitive to each media content information. The media content information in the search space is the information needed for the search model learning in each scenario. The semantic generation network already has the knowledge after learning the media content information. Therefore, the training of the search model in each search scenario based on the semantic generation network can significantly improve the convergence speed of the search model. The stage for obtaining the semantic generation network can be considered as a pre-training stage, and the pre-training stage of each search model can be reused. The second ability is that the semantic generation network can reconstruct the destroyed corpus, that is, it has the basic ability of corpus prediction, and corpus prediction is the main learning ability in the training process of the search model in each search scenario in the embodiments of the present application. This further enables the semantic generation network to improve the convergence speed of the search model and achieve better training results.
[0049] On the basis of the semantic generation network, a second sample corpus can be constructed for a specific search scenario, and the second sample corpus can be input into the pre-training model to obtain the second corpus generation result. The second corpus generation result represents the search result, that is, the media content search problem is converted into a corpus generation problem, and the search model is obtained by letting the pre-training model learn the corpus generation ability in the specific search scenario. This stage is the parameter fine-tuning (F inetune) stage for the search scenario. Since the semantic generation network in the pre-training stage already has basic corpus prediction capabilities, the fine-tuning (F i netune) stage will converge quickly. The fine-tuning (F i netune) stage improves the training speed by reusing the training results of the pre-training stage. Compared with related technologies, it can significantly reduce the training cost. In fact, since the semantic generation network in the pre-training stage has basic corpus prediction capabilities, it can actually be directly used as a search model in various search scenarios. In this way, the search data in various search scenarios can be directly connected to achieve full-link end-to-end search services.
[0050] See also Figure 2 , Figure 2 is a schematic diagram of an implementation framework of the search method provided in the embodiments of this specification, such as Figure 2As shown, the implementation framework may include at least a client 10 and a server 20, wherein the client 10 and the server 20 communicate via a network 30, and the implementation framework may also be considered as a search system, which is used to train a search model and provide a media content search service based on the search model. The server 20 may be located in a cloud environment, and the server 20 is a node in the search system in the cloud environment, and the node is any node in the cloud environment.
[0051] The server 20 can, when obtaining a search term from the client 10, determine the search scenario information to which the search term is adapted based on the search term; generate a search corpus based on the search term and the search scenario information; input the search corpus into a search model to obtain search results; the search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, and the sample corpus includes sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios.
[0052] The server 20 may train the search model. Specifically, the training process may include: first obtaining an initial model, and training the search model based on the initial model. In a macro sense, the original corpus text can be obtained according to the media content information in the search space corresponding to at least two search scenarios; the original corpus text is semantically destroyed to obtain at least one first sample corpus corresponding to the original corpus text; for each of the first sample corpus, the sample corpus is input into the initial network for corpus generation to obtain a first corpus generation result; based on the difference between the first corpus generation result and the original corpus text, the parameters of the initial network are adjusted to obtain a semantic generation network; a second sample corpus is constructed, the second sample corpus includes target search terms, information on target search scenarios, and target search results of the target search terms in the target search scenarios under the search space, and the target search scenarios are any of the at least two search scenarios; the second sample corpus is input into the pre-trained network for corpus generation to obtain a second corpus generation result, and the second corpus generation result indicates the predicted search results under the search space; wherein the pre-trained network is determined based on the semantic generation network; based on the difference between the second corpus generation result and the target search results, the parameters of the pre-trained network are adjusted to obtain a search model.
[0053] The above framework of the embodiment of the present application can provide the media content search capability required by applications in various scenarios, including but not limited to cloud technology, cloud games, cloud rendering, artificial intelligence, smart transportation, assisted driving, video media, smart communities, instant messaging, etc. Each component in the framework can be a terminal device or a server. Terminal devices include but are not limited to mobile phones, computers, intelligent voice exchange devices, smart home appliances, vehicle-mounted terminals, etc.
[0054] A search method according to an embodiment of the present application is described below. Figure 3 A flowchart of a search method provided by an embodiment of the present application is shown, and the search method can be executed based on the server 20 described above. The embodiment of the present application provides method operation steps as described in the embodiment or flowchart, but more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the actual system, terminal device or server product is executed, it can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment) according to the method shown in the embodiment or the accompanying drawings. The above method may include:
[0055] S301. When a search term is obtained, search scenario information to which the search term is adapted is determined based on the search term.
[0056] The search terms in the embodiment of the present application may come from the client 10, and the user obtains the search results provided by the server 20 by entering the search terms in the client 10. The search scenario information in the embodiment of the present application is information that matches the search terms and points to a specific search scenario, and is related to the specific search scenario. The embodiment of the present application does not limit the adaptation relationship, and the adaptation relationship can be set according to the specific search scenario provided. For example, the main demand scenario and the intention scenario are mentioned above. The intention scenario is a coarse-grained scenario corresponding to a type of media content, and the main demand scenario is a fine-grained scenario corresponding to a certain media content. If the search term hits the category of media content, the corresponding search scenario information is the information pointing to the intention scenario. If the search term hits the name of a certain media content, the corresponding search scenario information is the information pointing to the main demand scenario.
[0057] S302. Generate search corpus according to the search terms and the search scenario information.
[0058] Since the purpose of the search model is to output the search results corresponding to the search terms in the search space, a question-and-answer model can be used to construct the search corpus. Based on the above search terms and the above search scenario information, a search question is constructed. The above search question is used to ask questions about the search results obtained by searching for media content based on the above search terms in the search scenario pointed to by the above search scenario information. Taking the main demand scenario as an example, the search purpose of this search scenario is to output the closest media content related to the search term. In this scenario, the search corpus generated based on the search term "term A1" can be "What is the file corresponding to the first part of the TV series term A1?". Taking the intention scenario as an example, the search purpose of this search scenario is to output the closest intention related to the search term. In this scenario, the search corpus generated based on the search term "term A2" can be "What is the intention result corresponding to the movie term A2?".
[0059] S303. Input the above search corpus into the search model to obtain search results; the above search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, and the above sample corpus includes sample search terms, search scenarios corresponding to the above sample search terms, and sample search results of the above sample search terms in the corresponding search scenarios.
[0060] The embodiments of the present application do not limit the structure of the search model, and only require that it can perform semantic extraction operations and semantic generation operations as a corpus generation model. In one embodiment, the above-mentioned search corpus can be input into the above-mentioned search model for semantic extraction to obtain semantic representation information; the above-mentioned semantic representation information can be input into the above-mentioned search model for semantic generation to obtain search result information, and the above-mentioned search result information includes at least one predicted probability corresponding to a predicted media content, and the above-mentioned predicted probability represents the probability that the corresponding predicted media content belongs to the above-mentioned search result. Based on the above-mentioned search result information, the above-mentioned search result is obtained.
[0061] In one embodiment, when the search result information indicates a single predicted media content and a predicted probability corresponding to the predicted media content, if the predicted probability satisfies a preset probability threshold, the corresponding predicted media content may be output as a search result. If not, an empty search result may be output, indicating that there is no media content that meets the search requirement.
[0062] In another embodiment, the search results are obtained based on the search result information, including: determining a target number based on the search term, the target number indicating the number of media contents in the search results; determining the target number of predicted media contents in the search result information based on the target number and the prediction probability corresponding to each of the predicted media contents; and outputting the target number of predicted media contents as the search results.
[0063] In some embodiments, the search term itself may include a target number, for example, if the search term is "3 comedies", the target number is 3, or in some scenarios, the target number can be preset for each search scenario, for example, the target number for the main scenario is 1, the target number for the intention scenario is 6, etc. The search results can be filtered according to the target number. For example, if the search term limits the output of 3 media contents, the target number is 3, and the predicted media contents can be sorted in descending order of predicted probability to obtain the top 3 predicted media contents, which are output as search results.
[0064] The embodiments of the present application can provide corresponding search services for each search scenario, thereby meeting the user's search needs for multi-scenario searches. Moreover, for any search scenario, the search model used by the method is a corpus generation model obtained by training based on sample corpora generated in at least two search scenarios, and the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios. The training process of the search model uses sample corpora in multiple search scenarios, so the search model has the basic knowledge of performing media content search in each search scenario, and the search model is a corpus generation model. By converting the media content search task into a corpus prediction task, the search model's dependence on the scenario can be reduced, so that the training process of the search model in the specific scenario stage can shorten the training time and reduce the training cost of the search model.
[0065] In one embodiment, please refer to Figure 4 , which shows a search model training method. The above search model is trained by the following method, which includes:
[0066] S401. Obtain original corpus text according to media content information in a search space commonly corresponding to at least two search scenarios.
[0067] The embodiment of the present application does not limit the search space corresponding to at least two search scenarios. It can be a media content library corresponding to the target application that provides search services in the above-mentioned at least two search scenarios. That is to say, the target application provides corresponding search results by searching for search terms in each search scenario in the above-mentioned media content library. The media content library is the above-mentioned search space, and the information related to the media content library is the above-mentioned media content information. For example, the media content information may include search records in each search scenario, and may also include all data in the video field, such as video introductions, bullet screen comments, film reviews, film and television spectrum knowledge, etc.
[0068] The embodiments of the present application do not limit the specific content of the media content information, which may include data in a media content library or a usage record formed by using the media content library. The original corpus text can be constructed based on the media content information. The embodiments of the present application do not limit the specific form of the media content, which may be a long video, a short video, or a gif, etc. The embodiments of the present application do not limit the video duration threshold for distinguishing between long videos and short videos.
[0069] For example, the media content library includes subtitle data and media content introductions corresponding to multiple media contents. These subtitle data and media content introductions are in text form. By intercepting these text-form data, the original corpus text can be obtained. For another example, a usage record can be generated by using the media content library. For example, when the search term "search term 1" is input, the search result "search result 1" is output, and the text pair formed by "'search term 1', 'search result 1'" can also be used as the above-mentioned original corpus text.
[0070] S402. Perform semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text.
[0071] In order to train the corpus prediction ability of the initial network, the present application needs to first destroy the original corpus text to obtain a first sample corpus with missing information or semantic noise. In the embodiments of the present application, the corpus that has been semantically destroyed is referred to as the first sample corpus.
[0072] The embodiments of the present application do not limit the specific method of semantic destruction. In one embodiment, performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text includes performing at least one of the following operations:
[0073] (1) Perform mask replacement processing on any position in the original corpus text to obtain the first sample corpus.
[0074] The embodiment of the present application does not limit the mask mark. For example, [MASK] can be used as the mask mark. In the mask replacement operation, any position can be randomly replaced with [MASK]. Please refer to Figure 5 , which shows a schematic diagram of the semantic destruction method. Figure 5 The first row and the first column show the results of performing two mask replacements on the original corpus text "ABCDE". "_" represents the position corresponding to the [MASK] tag. The information at the [MASK] tag is considered to be cleared, but the position information of the cleared position is retained, resulting in semantic destruction.
[0075] (2) Deleting characters at any position in the original corpus text to obtain the first sample corpus.
[0076] In the embodiments of the present application, there is no limitation on the location of deletion, and information at any location can be randomly deleted. Figure 5 The first column of the second row shows the result of performing two character deletions on the original corpus text "ABCDE". The information of "B" and "D" is deleted, and the position information of the deleted positions is not retained, resulting in further semantic damage.
[0077] (3) Performing mask-based text replacement processing on a text of a preset length starting from a preset position in the original corpus text to obtain the first sample corpus, wherein the preset length conforms to a Poisson distribution.
[0078] Mask-based text replacement processing can also be considered as a text filling operation. A text segment in the original corpus text can be randomly determined. For example, the length of the text segment can conform to the Poisson distribution of λ=3. For the content in the text segment, [MASK] is used to replace it. Please refer to Figure 5 The second row and third column in FIG. 1 show the result of performing text replacement on the original corpus text "ABCDE". The information of "BC" is deleted, but the position information of the deleted position is retained, thus forming semantic destruction.
[0079] (4) A sentence sequence is obtained based on the original text corpus, and the sentence sequence is shuffled to obtain the first sample corpus.
[0080] Out-of-order processing can be achieved by randomly scrambling the order, please refer to Figure 5 The first row and second column in show the result of performing a shuffle process on the original corpus text "ABCDE", thereby causing semantic destruction.
[0081] (5) Rearranging the text using the target position in the original corpus as the text head to obtain the first sample corpus. The target position is any position in the original corpus except the head position.
[0082] Text rearrangement can also be called document rotation. A position is randomly selected as a token, and then the text is rotated, that is, the selected token is used as the head of the text. This semantic destruction method is conducive to enabling the initial network to learn the head information of the corpus.
[0083] S403. For each of the first sample corpora, input the first sample corpora into the initial network to generate corpora, and obtain a first corpus generation result.
[0084] The initial network can be set as a neural network for predicting the output corpus based on the input corpus. That is to say, the purpose of the initial network training process is to enable the trained semantic generation network to have the ability to predict the original corpus text before the destruction based on the destroyed sample corpus as much as possible. The first corpus generation result can include the probability of each position being a certain character for each position in the first sample corpus, and the prediction content of the initial network is expressed through such a first corpus generation result. The second corpus generation result and the third corpus generation result below also have similar content, which will not be repeated here.
[0085] The embodiment of the present application does not limit the source and structure of the initial network. Generally speaking, a neural network in the related technology with corpus prediction capability can be selected to construct the initial network. In the embodiment of the present application, the above-mentioned initial network may include a shared encoding layer for performing an encoding operation based on self-attention, and a generative decoding layer for performing a decoding operation based on masked self-attention. In a specific embodiment, the shared encoding layer is a Shared Encoder (encoding layer, S-Enc), which is a Transform encoder based on a self-attention mechanism, which is intended to capture the semantic representation of language understanding and generation. The generative decoding layer is a Generat i on Decoder (decoding layer, G-Dec), which is a Transformer decoder with masked self-attention, and the output of S-Enc is used as the input of S-Enc, which is a decoding structure designed for a generation task with an autoregressive method. The embodiment of the present application does not limit the number of layers of S-Enc and S-Enc. In a specific embodiment, S-Enc and S-Enc each have six layers.
[0086] In a specific implementation, BART Chinese base can be used. The basic version of BART (Bidirectional Text Encoder + Autoregressive Decoder) is used as the initial model. The model is based on the Encode-Decode model (encoding-decoding mode) of Transformer. Traditional BERT uses bidirectional interactive encoding, which is usually used for NLU, but not for NLG. GPT uses autoregression and has no bidirectional interactive capability. It is usually used for NLG, while BART integrates bidirectional interactive Encode capability with autoregressive Decode capability based on NLG. GPT is an autoregressive generative pre-trained language model. In a specific implementation, CPT can also be used as the initial model, namely Chinese Pre-trained Unba l anced Transformer (CPT), which is an upgraded version of the BART model.
[0087] S404. Based on the difference between the first corpus generation result and the original corpus text, adjust the parameters of the initial network to obtain a semantic generation network.
[0088] The embodiment of the present application does not limit the measurement method of the difference between the above-mentioned first corpus generation result and the above-mentioned original corpus text. For example, cross entropy loss or smoothed cross entropy loss can be used for measurement. In the embodiment of the present application, the parameters of the initial network can be adjusted based on the gradient descent method to obtain a semantic generation network. The gradient descent method is a method for first-order optimization adjustment of network parameters by gradient descent, which is often used in the field of machine learning and deep learning when adjusting network parameters. In the embodiment of the present application, the gradient descent method can guide the above-mentioned parameters to be adjusted in the direction of reducing losses. When the number of adjustments reaches a preset number threshold, or when the loss is less than a preset loss threshold, the parameter adjustment is stopped to obtain the above-mentioned semantic generation network.
[0089] After semantic destruction of the original corpus text, a first sample corpus can be obtained. The initial network is used to generate corpus for the first sample corpus, and the initial network is trained based on the difference between the generated result and the original corpus text to obtain a semantic generation network, which has at least two capabilities. The first capability is a strong predictive capability for media content information in the search space, that is, the semantic generation network has completed the learning of each media content information in the search space and is sensitive to each media content information. The media content information in the search space is the information required for the search model learning in each scenario. The semantic generation network already has the knowledge of the learned media content information. Therefore, the training of search models in various search scenarios based on the semantic generation network can significantly improve the convergence speed of the search model. The stage for obtaining the semantic generation network can be considered as a pre-training stage, and the pre-training stage of each search model can be reused. The second ability is that the semantic generation network can reconstruct the destroyed corpus, that is, it has the basic ability of corpus prediction, and corpus prediction is the main learning ability in the training process of the search model in each search scenario in the embodiment of the present application. This further enables the semantic generation network to improve the convergence speed of the search model and achieve better training results.
[0090] S405. Obtain the above search model based on the above semantic generation network.
[0091] In one embodiment, the semantic generation network can be directly used as the above-mentioned search model. The search model has the ability to provide non-differentiated search services in various search scenarios, connecting various search scenarios. Compared with related technologies, the same search model can be reused in multiple search scenarios, reducing the training cost of the search model.
[0092] In one embodiment, the search model is obtained based on the semantic generation network, including:
[0093] S4051. Construct a second sample corpus, wherein the second sample corpus includes target search terms, information about target search scenarios, and target search results of the target search terms in the target search scenarios under the search space, wherein the target search scenarios are any one of the at least two search scenarios.
[0094] The second sample corpus in the embodiment of the present application is a sample corpus generated based on search data related to a specific search scenario, and is used to train a specific search model in the search scenario. In the embodiment of the present application, corresponding second sample corpora can be constructed for different search scenarios respectively, so as to train search models corresponding to each search scenario respectively. The embodiment of the present application does not limit the search data related to the search scenario. For example, it may include the graph data corresponding to the search scenario, the log data generated by the user performing the search in the search scenario, and the manually annotated data.
[0095] Since the purpose of the search model is to output the search results corresponding to the search terms in the search space, the question-answering model can be used to construct the second sample corpus, that is, the above-mentioned construction of the second sample corpus includes: constructing a search question based on the information of the above-mentioned target search terms and the above-mentioned target search scenario, the above-mentioned search question is used to ask questions about the search results obtained by searching the media content based on the above-mentioned target search terms in the above-mentioned target search scenario; and using the above-mentioned search question as the above-mentioned second sample corpus. By using the search question as the second sample corpus and the corresponding search results as the expected output content for corpus prediction for the second sample corpus, the search question of the media content is successfully converted into a corpus prediction problem. The search questions of the media content in each search scenario are converted into corpus prediction problems. The modeling of the search model of each search scenario can be completed by training a model with corpus prediction capabilities, thereby realizing end-to-end modeling of the search model, without the need to train the corresponding search model for each search scenario separately and independently, as in the related technology, thereby realizing the model connection between each search scenario, and each search scenario can realize data connection by constructing search questions. In this way, data reuse and capability migration are realized, thereby improving the search effect and reducing the cost of search model modeling.
[0096] Taking the main demand scenario as an example, the search purpose of this search scenario is to output the closest media content related to the search term. In this scenario, the second sample corpus generated according to the search term "term A1" can be "What is the file corresponding to the first part of the TV series term A1?", and the search result is "file number D1".
[0097] Taking the intent scenario as an example, the search purpose of this search scenario is to output the closest intent related to the search term. In this scenario, the second sample corpus generated based on the search term "term A2" can be "What is the intent result corresponding to the term A2 movie?", and the search result is "file number D2".
[0098] Taking the scenario of associative media content search as an example, the search purpose of this search scenario is to output media content that users related to the search term are likely to click on. In this scenario, the second sample corpus generated based on the search term "term A3" can be "What is the file name that users of term A3 tend to click on?", and the search result is "file number D3".
[0099] Taking the scenario of searching for media content based on entities as an example, the search purpose of this search scenario is to output media content related to the entity of the search term. In this scenario, the second sample corpus generated based on the search term "term A4" can be "What are the two file names of the TV series whose actor is term A4?", and the search result is "file number D4, file number D5".
[0100] The embodiment of the present application does not limit the recording method of the second sample corpus in the server 20, for example, it can be recorded in the form of a string or JSON. Figure 6 , which shows a schematic diagram of the recording method of the second sample corpus. Figure 6 (1) shows the content of the second sample corpus in the main demand scenario. The search question (query) determined according to the sample search term in the second sample corpus is "What is the file corresponding to the first TV series of word A1?", and the search result is the file number (target) of the media content corresponding to the search question. Figure 6 (2) shows the content of the second sample corpus in the intent scenario. The search question (query) determined based on the sample search term in the second sample corpus is "What is the intent result corresponding to the word A2 movie?", and the search result is the file number (target) of the media content corresponding to the search question. Figure 6 (3) shows the content of the second sample corpus in the associative scenario. The search question (query) determined according to the sample search term in the second sample corpus is "What is the file name that users of word A3 tend to click?", and the search result is the file number (target) of the media content corresponding to the search question. JSON (JavaScript Object Notation, JS object notation) is a lightweight data exchange format. It uses a text format that is completely independent of the programming language to store and represent data. The concise and clear hierarchical structure makes JSON an ideal data exchange language. It is easy for people to read and write, and it is also easy for machines to parse and generate, and effectively improves network transmission efficiency. Figure 6 The source corresponds to the search question, the target is the corresponding search result, and other tags contain other information, which will not be described in detail in the embodiments of this application.
[0101] S4052. Input the second sample corpus into the pre-trained network for corpus generation to obtain a second corpus generation result, wherein the second corpus generation result indicates the predicted search result under the search space; wherein the pre-trained network is determined based on the semantic generation network.
[0102] The embodiments of the present application do not limit the method for determining the pre-trained network. For example, in one embodiment, the semantic generation network can be directly used as the pre-trained network.
[0103] In another embodiment, a third sample corpus can also be constructed according to the search data corresponding to each of the above-mentioned search scenarios, wherein the third sample corpus includes search terms, information about search scenarios, and search results of the search terms in the above-mentioned search scenarios under the above-mentioned search space; the third sample corpus is input into the above-mentioned semantic generation network for corpus generation to obtain a third corpus generation result, wherein the third corpus generation result indicates the predicted search results associated with the search terms in the above-mentioned search scenarios; according to the difference between the third corpus generation result and the above-mentioned search results, the parameters of the semantic generation network are adjusted to obtain the above-mentioned pre-trained network. The method of training a pre-trained network based on the third sample corpus is based on the same inventive concept as the method of training a search network based on the second sample corpus. The method of training a search network based on the second sample corpus will be described in detail below and will not be repeated here.
[0104] In one embodiment, the third sample corpus is constructed according to the search data corresponding to each of the above search scenarios, including: constructing the third sample corpus based on the target corpus construction method and the search data corresponding to each of the above search scenarios, and the target corpus construction method is the method of constructing the second sample corpus. In other words, the construction method of the third sample corpus is consistent with the construction method of the second sample corpus, that is, the third sample corpus is a sample corpus covering various search scenarios, and the second sample corpus is a sample corpus for a specific search scenario. This also shows from the data perspective that the third sample corpus is the result of realizing the data connection in various search scenarios. The pre-trained model obtained by training the third sample corpus after the data is connected has the ability to be applicable to various search scenarios. In other words, each search scenario can obtain its own adaptive search model based on the reuse of the pre-trained model. Since the pre-trained network has the basic ability to predict search results based on search questions, it can actually be used directly in various search scenarios as a search model. In this way, the search data in various search scenarios can be directly connected to achieve a full-link end-to-end search service.
[0105] In an embodiment of the present application, the second sample corpus is input into the pre-trained network for corpus generation to obtain a second corpus generation result, including: inputting the second sample corpus into the shared encoding layer for semantic extraction to obtain sample semantic representation information; inputting the sample semantic representation information into the generative decoder for autoregressive semantic generation to obtain the second corpus generation result. The method for obtaining the second corpus generation result, the method for obtaining the first corpus generation result, and the method for obtaining the third corpus generation result are all based on the same inventive concept, and will not be described in detail in the embodiment of the present application.
[0106] S4053. According to the difference between the second corpus generation result and the target search result, the parameters of the pre-trained network are adjusted to obtain a search model.
[0107] The embodiment of the present application does not limit the measurement method of the difference between the above-mentioned second corpus generation result and the above-mentioned target search result. For example, smooth cross entropy loss can be used for measurement. Of course, measuring by smooth cross entropy can prevent overfitting and increase the generalization ability of the model. In the embodiment of the present application, the parameters of the pre-trained network can be adjusted based on the gradient descent method to obtain a search model. The implementation method and conditions of the gradient descent method have been described above and will not be repeated here.
[0108] In one embodiment, the above-mentioned method of adjusting the parameters of the pre-trained network according to the difference between the result generated by the second corpus and the target search result to obtain the search model includes: calculating the smoothed cross entropy loss according to the difference between the predicted media content in the result generated by the second corpus and the true media content in the target search result; and adjusting the parameters of the pre-trained network based on the smoothed cross entropy loss to obtain the search model.
[0109] The smoothed cross entropy loss can be obtained by Representation, where K represents the number of positions that need to be predicted in the corpus, y k is the true value at position k, p k is the predicted value at position k, where k and t both represent a certain position, where t can be understood as the position that needs to be predicted, and α is a smoothing parameter used to enhance the generalization ability of the model. The embodiment of the present application does not limit its value, for example, it can be set to 0.1.
[0110] By constructing a second sample corpus for a specific search scenario, the second sample corpus is input into the pre-training model to obtain the second corpus generation result, which represents the search result. In other words, the media content search problem is converted into a corpus generation problem, and the search model is obtained by letting the pre-training model learn the corpus generation ability in the specific search scenario. This stage is the parameter fine-tuning (Fi netune) stage for the search scenario. Since the semantic generation network in the pre-training stage already has basic corpus prediction capabilities, the fine-tuning (Fi netune) stage will converge quickly. The fine-tuning (Fi netune) stage improves the training speed by reusing the training results of the pre-training stage. Compared with related technologies, it can significantly reduce the training cost. In fact, since the semantic generation network in the pre-training stage has basic corpus prediction capabilities, it can actually be directly used as a search model in various search scenarios. In this way, the search data in various search scenarios can be directly connected to achieve full-link end-to-end search services.
[0111] In fact, the embodiment of the present application obtains a semantic generation network by training the initial network, obtains a pre-trained network based on the semantic generation network, and obtains a search network for each search scenario based on the pre-trained network. If the third sample corpus in the previous text is used to obtain the pre-trained network in the pre-training stage, the pre-trained network itself actually has the ability to provide search services for each search scenario and can be used as a search model for each search scenario, that is, end-to-end search is achieved. Please refer to Figure 7 , which shows a schematic diagram of end-to-end search. According to the search terms and the model with end-to-end search capabilities, the search results for various search scenarios can be output, such as main demand results, intent results and recommended results. The search tasks corresponding to each search scenario of the target application are converted into NLP tasks for modeling, and a unified pre-trained model is pre-trained to solve the tasks of various media content searches end-to-end. A pre-trained model connects multiple search scenarios, realizes data reuse and capability migration, and thus improves the effect. Compared with the related technology of independently training the search models for each search scenario, it can better reduce costs.
[0112] Please refer to Figure 8 , which shows a block diagram of a search device in this embodiment, the device includes:
[0113] The search information acquisition module 801 is used to determine the search scenario information adapted to the search word according to the search word when the search word is acquired;
[0114] A search module 802 is used to generate a search corpus according to the search words and the search scenario information; and input the search corpus into a search model to obtain search results;
[0115] The above search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios. The above sample corpora include sample search terms, search scenarios corresponding to the above sample search terms, and sample search results of the above sample search terms in the corresponding search scenarios.
[0116] In one embodiment, the search module 802 is used to perform the following operations:
[0117] Input the search corpus into the search model to perform semantic extraction to obtain semantic representation information;
[0118] Inputting the semantic representation information into the search model for semantic generation to obtain search result information, wherein the search result information includes a prediction probability corresponding to at least one predicted media content, wherein the prediction probability represents a probability that the corresponding predicted media content belongs to the search result;
[0119] According to the search result information, the search result is obtained.
[0120] In one embodiment, the search module 802 is configured to perform the following operations: determining a target quantity according to the search term, where the target quantity indicates the quantity of media content in the search result;
[0121] Determining the target number of predicted media contents in the search result information according to the target number and the predicted probabilities corresponding to the predicted media contents;
[0122] The target number of predicted media contents are output as the search results.
[0123] In one embodiment, the search module 802 is used to perform the following operations:
[0124] Obtaining original corpus text according to media content information in a search space corresponding to at least two search scenarios;
[0125] Performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text;
[0126] For each of the first sample corpora, input the first sample corpora into the initial network to generate corpora, and obtain a first corpus generation result;
[0127] Based on the difference between the first corpus generation result and the original corpus text, adjusting the parameters of the initial network to obtain a semantic generation network;
[0128] The above search model is obtained based on the above semantic generation network.
[0129] In one embodiment, the search module 802 is used to perform the following operations:
[0130] Constructing a second sample corpus, wherein the second sample corpus includes information about a target search term, a target search scenario, and target search results of the target search term in the target search scenario under the search space, wherein the target search scenario is any one of the at least two search scenarios;
[0131] Inputting the second sample corpus into the pre-trained network for corpus generation to obtain a second corpus generation result, wherein the second corpus generation result indicates the predicted search result under the search space; wherein the pre-trained network is determined based on the semantic generation network;
[0132] According to the difference between the second corpus generation result and the target search result, the parameters of the pre-trained network are adjusted to obtain a search model.
[0133] In one embodiment, the search module 802 is used to perform the following operations:
[0134] The semantic generation network is used as the pre-trained network;
[0135] or,
[0136] Constructing a third sample corpus according to the search data corresponding to each of the search scenarios, wherein the third sample corpus includes search terms, information about the search scenarios, and search results of the search terms in the search space in the search scenarios;
[0137] Inputting the third sample corpus into the semantic generation network to generate corpus, and obtaining a third corpus generation result, wherein the third corpus generation result indicates a predicted search result associated with the search term in the search scenario;
[0138] According to the difference between the third corpus generation result and the search result, the parameters of the semantic generation network are adjusted to obtain the pre-trained network.
[0139] In one embodiment, the search module 802 is used to perform the following operations:
[0140] Based on the target corpus construction method and the search data corresponding to each of the above search scenarios, the above third sample corpus is constructed. The above target corpus construction method is the same as the method for constructing the above second sample corpus.
[0141] In one embodiment, the search module 802 is configured to perform at least one of the following operations:
[0142] Performing mask replacement processing on any position in the original corpus text to obtain the first sample corpus;
[0143] Deleting characters at any position in the original corpus text to obtain the first sample corpus;
[0144] Performing a mask-based text replacement process on a text of a preset length starting from a preset position in the original corpus text to obtain the first sample corpus, wherein the preset length conforms to a Poisson distribution;
[0145] Obtaining a sentence sequence based on the original text corpus, and performing shuffling on the sentence sequence to obtain the first sample corpus;
[0146] The target position in the original corpus text is used as the text head to perform text rearrangement processing to obtain the first sample corpus. The target position is any position in the original corpus text except the head position.
[0147] In one embodiment, the initial network includes a shared encoding layer for performing a self-attention-based encoding operation and a generative decoding layer for performing a masked self-attention-based decoding operation, and the search module 802 is used to perform the following operations:
[0148] Inputting the second sample corpus into the shared encoding layer to perform semantic extraction to obtain sample semantic representation information;
[0149] The sample semantic representation information is input into the generative decoder to perform autoregressive semantic generation to obtain the second corpus generation result.
[0150] In one embodiment, the search module 802 is used to perform the following operations:
[0151] Constructing a search question based on the target search term and the target search scenario information, wherein the search question is used to ask a question about the search results obtained by searching for media content based on the target search term in the target search scenario;
[0152] The above search question is used as the second sample corpus.
[0153] In one embodiment, the search module 802 is configured to perform the following operations: calculating a smoothed cross entropy loss according to a difference between the predicted media content in the second corpus generation result and the true media content in the target search result;
[0154] Based on the above smoothed cross entropy loss, the parameters of the above pre-trained network are adjusted to obtain the search model.
[0155] The device part and the method embodiment in the embodiment of the present application are based on the same inventive concept and will not be described in detail here.
[0156] Further, Fig. 9 A schematic diagram of the hardware structure of a device for implementing the method provided in the embodiment of the present application is shown. The above device may participate in constituting or include the apparatus or system provided in the embodiment of the present application. Fig. 9 As shown, the device 10 may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Fig. 9 The structure shown is for illustration only and does not limit the structure of the electronic device. Fig. 9 More or fewer components as shown, or with Fig. 9 Different configurations shown.
[0157] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the device 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0158] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the above-mentioned method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, to implement the above-mentioned search method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0159] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the device 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0160] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of device 10 (or mobile device).
[0161] Fig.10 is a block diagram of an electronic device according to an exemplary embodiment. The electronic device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown, the electronic device is used to implement or participate in the implementation of a search method. The electronic device includes a processor, a memory and a network interface connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a search method is implemented.
[0162] Those skilled in the art will understand that Fig.10 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present disclosure, and does not constitute a limitation on the electronic device to which the scheme of the present disclosure is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0163] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program. The above program may be stored in a computer-readable storage medium, and the above storage medium may be a read-only memory, a disk or an optical disk, etc.
[0164] The instructions in the above storage medium can execute a search method, and the above method includes:
[0165] When the search term is obtained, the search scenario information to which the search term is adapted is determined according to the search term;
[0166] Generate search corpus according to the search terms and the search scenario information;
[0167] Input the above search corpus into the search model to obtain search results;
[0168] The above search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios. The above sample corpora include sample search terms, search scenarios corresponding to the above sample search terms, and sample search results of the above sample search terms in the corresponding search scenarios.
[0169] In one embodiment, the above-mentioned inputting the search corpus into the search model to obtain search results includes:
[0170] Input the search corpus into the search model to perform semantic extraction to obtain semantic representation information;
[0171] Inputting the semantic representation information into the search model for semantic generation to obtain search result information, wherein the search result information includes a prediction probability corresponding to at least one predicted media content, wherein the prediction probability represents a probability that the corresponding predicted media content belongs to the search result;
[0172] According to the search result information, the search result is obtained.
[0173] In one embodiment, obtaining the search results according to the search result information includes:
[0174] Determine a target quantity according to the search term, wherein the target quantity indicates the quantity of media content in the search result;
[0175] Determining the target number of predicted media contents in the search result information according to the target number and the predicted probabilities corresponding to the predicted media contents;
[0176] The target number of predicted media contents are output as the search results.
[0177] In one embodiment, the search model is trained by the following method:
[0178] Obtaining original corpus text according to media content information in a search space corresponding to at least two search scenarios;
[0179] Performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text;
[0180] For each of the first sample corpora, input the first sample corpora into the initial network to generate corpora, and obtain a first corpus generation result;
[0181] Based on the difference between the first corpus generation result and the original corpus text, adjusting the parameters of the initial network to obtain a semantic generation network;
[0182] The above search model is obtained based on the above semantic generation network.
[0183] In one embodiment, the search model is obtained based on the semantic generation network, including:
[0184] Constructing a second sample corpus, wherein the second sample corpus includes information about a target search term, a target search scenario, and target search results of the target search term in the target search scenario under the search space, wherein the target search scenario is any one of the at least two search scenarios;
[0185] Inputting the second sample corpus into the pre-trained network for corpus generation to obtain a second corpus generation result, wherein the second corpus generation result indicates the predicted search result under the search space; wherein the pre-trained network is determined based on the semantic generation network;
[0186] According to the difference between the second corpus generation result and the target search result, the parameters of the pre-trained network are adjusted to obtain a search model.
[0187] In one embodiment, after obtaining the semantic generation network, the method further includes:
[0188] The semantic generation network is used as the pre-trained network;
[0189] or,
[0190] Constructing a third sample corpus according to the search data corresponding to each of the search scenarios, wherein the third sample corpus includes search terms, information about the search scenarios, and search results of the search terms in the search space in the search scenarios;
[0191] Inputting the third sample corpus into the semantic generation network to generate corpus, and obtaining a third corpus generation result, wherein the third corpus generation result indicates a predicted search result associated with the search term in the search scenario;
[0192] According to the difference between the third corpus generation result and the search result, the parameters of the semantic generation network are adjusted to obtain the pre-trained network.
[0193] In one embodiment, the third sample corpus is constructed according to the search data corresponding to each of the above search scenarios, including:
[0194] Based on the target corpus construction method and the search data corresponding to each of the above search scenarios, the above third sample corpus is constructed. The above target corpus construction method is the same as the method for constructing the above second sample corpus.
[0195] In one embodiment, performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text includes performing at least one of the following operations:
[0196] Performing mask replacement processing on any position in the original corpus text to obtain the first sample corpus;
[0197] Deleting characters at any position in the original corpus text to obtain the first sample corpus;
[0198] Performing a mask-based text replacement process on a text of a preset length starting from a preset position in the original corpus text to obtain the first sample corpus, wherein the preset length conforms to a Poisson distribution;
[0199] Obtaining a sentence sequence based on the original text corpus, and performing shuffling on the sentence sequence to obtain the first sample corpus;
[0200] The target position in the original corpus text is used as the text head to perform text rearrangement processing to obtain the first sample corpus. The target position is any position in the original corpus text except the head position.
[0201] In one embodiment, the initial network includes a shared encoding layer for performing an encoding operation based on self-attention, and a generative decoding layer for performing a decoding operation based on masked self-attention, and the second sample corpus is input into the pre-trained network for corpus generation to obtain a second corpus generation result, including:
[0202] Inputting the second sample corpus into the shared encoding layer to perform semantic extraction to obtain sample semantic representation information;
[0203] The sample semantic representation information is input into the generative decoder to perform autoregressive semantic generation to obtain the second corpus generation result.
[0204] In one embodiment, the second sample corpus is constructed as follows:
[0205] Constructing a search question based on the target search term and the target search scenario information, wherein the search question is used to ask a question about the search results obtained by searching for media content based on the target search term in the target search scenario;
[0206] The above search question is used as the second sample corpus.
[0207] In one embodiment, adjusting the parameters of the pre-trained network according to the difference between the second corpus generation result and the target search result to obtain the search model includes:
[0208] Calculating a smoothed cross entropy loss based on a difference between the predicted media content in the second corpus generation result and the true media content in the target search result;
[0209] Based on the above smoothed cross entropy loss, the parameters of the above pre-trained network are adjusted to obtain the search model.
[0210] It should be noted that the above-mentioned sequence of the embodiments of the present application is only for description and does not represent the advantages and disadvantages of the embodiments. And the above-mentioned specific embodiments of the embodiments of the present application are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0211] Each embodiment in the embodiments of the present application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and server embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0212] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0213] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A search method, It is characterized in that The method comprises: When a search term is obtained, determining search scenario information to which the search term is adapted according to the search term; Generate search corpus according to the search term and the search scenario information; Inputting the search corpus into a search model to obtain search results; The search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, wherein the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios.
2. The method according to claim 1, It is characterized in that The step of inputting the search corpus into a search model to obtain search results includes: Inputting the search corpus into the search model for semantic extraction to obtain semantic representation information; Inputting the semantic representation information into the search model for semantic generation to obtain search result information, wherein the search result information includes a prediction probability corresponding to at least one predicted media content, wherein the prediction probability represents a probability that the corresponding predicted media content belongs to the search result; The search result is obtained according to the search result information.
3. The method according to claim 2, It is characterized in that Obtaining the search result according to the search result information includes: determining a target quantity according to the search term, the target quantity indicating the quantity of media content in the search result; Determining the target number of predicted media contents in the search result information according to the target number and the prediction probabilities respectively corresponding to the predicted media contents; The target number of predicted media contents are output as the search results.
4. The method according to any one of claims 1 to 3, It is characterized in that The search model is trained by the following method: Obtaining original corpus text according to media content information in a search space corresponding to at least two search scenarios; Performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text; For each of the first sample corpora, inputting the first sample corpora into an initial network to generate corpora, and obtaining a first corpus generation result; Based on the difference between the first corpus generation result and the original corpus text, adjusting the parameters of the initial network to obtain a semantic generation network; The search model is obtained based on the semantic generation network.
5. The method according to claim 4, It is characterized in that The step of obtaining the search model based on the semantic generation network includes: Constructing a second sample corpus, wherein the second sample corpus includes a target search term, information about a target search scenario, and a target search result of the target search term in the target search scenario in the search space, wherein the target search scenario is any one of the at least two search scenarios; Inputting the second sample corpus into a pre-trained network for corpus generation to obtain a second corpus generation result, wherein the second corpus generation result indicates a predicted search result under the search space; wherein the pre-trained network is determined based on the semantic generation network; According to the difference between the second corpus generation result and the target search result, the parameters of the pre-trained network are adjusted to obtain a search model.
6. The method according to claim 5, It is characterized in that After obtaining the semantic generation network, the method further includes: Using the semantic generation network as the pre-trained network; or, Constructing a third sample corpus according to the search data corresponding to each of the search scenarios, wherein the third sample corpus includes search terms, information about the search scenarios, and search results of the search terms in the search space in the search scenarios; Inputting the third sample corpus into the semantic generation network to generate corpus, and obtaining a third corpus generation result, wherein the third corpus generation result indicates a predicted search result associated with the search term in the search scenario; According to the difference between the third corpus generation result and the search result, the parameters of the semantic generation network are adjusted to obtain the pre-trained network.
7. The method according to claim 6, It is characterized in that The step of constructing a third sample corpus according to the search data corresponding to each of the search scenarios includes: The third sample corpus is constructed based on a target corpus construction method and search data corresponding to each of the search scenarios. The target corpus construction method is the same as the method for constructing the second sample corpus.
8. The method according to claim 4, It is characterized in that The performing semantic destruction on the original corpus text to obtain at least one first sample corpus corresponding to the original corpus text includes performing at least one of the following operations: Performing mask replacement processing on any position in the original corpus text to obtain the first sample corpus; Deleting characters at any position in the original corpus text to obtain the first sample corpus; Performing a mask-based text replacement process on a text of a preset length starting from a preset position in the original corpus text to obtain the first sample corpus, wherein the preset length conforms to a Poisson distribution; Obtaining a sentence sequence based on the original text corpus, and performing shuffling processing on the sentence sequence to obtain the first sample corpus; The target position in the original corpus text is used as the text head to perform text rearrangement processing to obtain the first sample corpus, and the target position is any position in the original corpus text except the head position.
9. The method according to claim 4, It is characterized in that The initial network includes a shared encoding layer for performing an encoding operation based on self-attention, and a generative decoding layer for performing a decoding operation based on masked self-attention, and the second sample corpus is input into the pre-trained network for corpus generation to obtain a second corpus generation result, including: Inputting the second sample corpus into the shared encoding layer for semantic extraction to obtain sample semantic representation information; The sample semantic representation information is input into the generative decoder for autoregressive semantic generation to obtain the second corpus generation result.
10. The method according to claim 5, It is characterized in that The constructing of the second sample corpus includes: Constructing a search question based on the target search term and information about the target search scenario, wherein the search question is used to ask a question about a search result obtained by searching for media content based on the target search term in the target search scenario; The search question is used as the second sample corpus.
11. The method according to claim 5, It is characterized in that The step of adjusting the parameters of the pre-trained network according to the difference between the result generated by the second corpus and the target search result to obtain the search model comprises: Calculating a smoothed cross entropy loss based on a difference between the predicted media content in the second corpus generation result and the true media content in the target search result; Based on the smoothed cross entropy loss, the parameters of the pre-trained network are adjusted to obtain a search model.
12. A search device, It is characterized in that The device comprises: A search information acquisition module, configured to determine search scenario information adapted to the search term based on the search term when the search term is acquired; A search module, configured to generate a search corpus according to the search term and the search scenario information; and input the search corpus into a search model to obtain search results; The search model is a corpus generation model trained based on sample corpora generated in at least two search scenarios, wherein the sample corpora include sample search terms, search scenarios corresponding to the sample search terms, and sample search results of the sample search terms in the corresponding search scenarios.
13. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement a search method as described in claims 1 to 11.
14. An electronic device, It is characterized in that It includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements a search method as described in claims 1 to 11 by executing the instructions stored in the memory.
