Information search method, device, equipment and storage medium
By introducing the focus loss function in the rewriting model and modulating the factor weighted sample difficulty, the imbalance problem of difficult and easy samples is solved, the accuracy of search results is improved, and the accuracy of search results is ensured.
Patent Information
- Application Number
- CN202010158350.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-09
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2040-03-09
AI Technical Summary
When existing search engines train rewriting models, the imbalance between difficult and easy samples causes the model to overfit on easy samples and fail to effectively utilize difficult samples, affecting the accuracy of search results.
The rewritten model is trained using the focused loss function. The sample difficulty is weighted by the modulation factor, the weight of easy samples is reduced, the weight of difficult samples is increased, the learning of difficult samples is optimized, the rewritten model focuses on difficult samples, and the model effect is improved.
By rewriting the model, difficult samples are effectively utilized, the accuracy of search results is improved, errors in the original query information are corrected, and the correctness of search results is ensured.
Smart Images

Figure CN111368525B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to an information search method, apparatus, device and storage medium. Background Art
[0002] Applying query rewriting technology to search engines can effectively improve search engine accuracy. Specifically, when users use search engines, they may enter incorrect or incomplete queries due to cognitive or typing errors. In this case, it is necessary to find candidate queries with similar semantics to the original query and conduct searches based on these candidate queries to ensure the accuracy of search results.
[0003] Currently, using rewriting models for information search has become a hot research topic. Specifically, during the training phase, a sample set is trained using a cross-entropy loss function to generate a rewriting model. During the prediction phase, several candidate queries are mined based on the original query information entered by the user into the search engine. The original query information and the mined candidate queries are then fed into the rewriting model. The rewriting model processes the original query information and candidate queries, and outputs a predicted value. If a candidate query has the highest predicted value among the candidate queries, it is determined as the rewritten query of the original query, and the search is performed based on this candidate query.
[0004] The difficulty of rewriting different samples in a sample set is often significantly imbalanced, meaning that the sample set often contains a large proportion of easy samples, while the sample set contains a small proportion of difficult samples. When using the above approach, due to this imbalance, the model often overfits on the easy samples when training the model based on the sample set. This results in the model being unable to effectively learn from the difficult samples, resulting in inaccurate rewriting of the original query information determined by the model, which in turn affects the accuracy of search results. Summary of the Invention
[0005] The embodiments of the present application provide an information search method, apparatus, device, and storage medium that can improve the accuracy of search results. The technical solution is as follows:
[0006] In one aspect, an information search method is provided, the method comprising:
[0007] Acquire, based on the original query information, at least one candidate query information that matches the original query information;
[0008] Inputting the original query information and the at least one candidate query information into a rewriting model, wherein the rewriting model is trained on a sample set based on a focused loss function, wherein the focused loss function includes a first loss function and a modulation factor for weighting the first loss function, wherein a value of the modulation factor is positively correlated with a rewriting difficulty of samples in the sample set;
[0009] Processing the original query information and the at least one candidate query information using the rewriting model, and outputting a prediction value for the at least one candidate query information, the prediction value being used to indicate a probability that the corresponding candidate query information is a rewritten query information of the original query information;
[0010] The search is performed based on candidate query information whose predicted value satisfies the first condition in the at least one candidate query information.
[0011] In another aspect, an information search device is provided, the device comprising:
[0012] An acquisition module, configured to acquire, based on the original query information, at least one candidate query information that matches the original query information;
[0013] an input module, configured to input the original query information and the at least one candidate query information into a rewriting model, wherein the rewriting model is trained on a sample set based on a focused loss function, wherein the focused loss function includes a first loss function and a modulation factor for weighting the first loss function, wherein a value of the modulation factor is positively correlated with a rewriting difficulty of a sample in the sample set;
[0014] a processing module, configured to process the original query information and the at least one candidate query information using the rewriting model, and output a prediction value for the at least one candidate query information, the prediction value being used to indicate a probability that the corresponding candidate query information is a rewritten query information of the original query information;
[0015] The search module is configured to search for candidate query information whose predicted value satisfies a first condition in the at least one candidate query information.
[0016] Optionally, the modulation factor includes a focusing parameter, and the focusing parameter is used to adjust a weight reduction rate of easy samples in the sample set, and the rewriting difficulty of the easy samples meets the second condition.
[0017] Optionally, the focusing parameter is an exponential part of the modulation factor.
[0018] Optionally, the modulation factor includes an indicator function, and a value of the indicator function is used to indicate a deviation between a predicted value of the sample and a label of the sample.
[0019] Optionally, the indicator function is the base part of the modulation factor.
[0020] Optionally, the focusing loss function also includes a balancing factor for weighting the first loss function, the value of the balancing factor for the positive samples in the sample set is different from the value of the balancing factor for the negative samples in the sample set, the sample candidate query information included in the positive samples is the rewritten query information of the corresponding sample original query information, and the sample candidate query information included in the negative samples is not the rewritten query information of the corresponding sample original query information.
[0021] Optionally, the focusing loss function is the product of the modulation factor, the balance factor and the first loss function.
[0022] Optionally, the rewriting model includes a neural network and the focusing loss function connected to the output layer of the neural network, and the processing module is used to perform feature extraction on the original query information through the neural network to obtain a first semantic representation vector of the original query information; perform feature extraction on the at least one candidate query information through the neural network to obtain a second semantic representation vector of the at least one candidate query information; and perform operations on the first semantic representation vector and the second semantic representation vector of the at least one candidate query information through the focusing loss function to obtain a predicted value of the at least one candidate query information.
[0023] On the other hand, an electronic device is provided, which includes one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the operations performed by the above-mentioned information search method.
[0024] On the other hand, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the operations performed by the above-mentioned information search method.
[0025] The beneficial effects of the technical solutions provided in the embodiments of the present application include at least:
[0026] The method and apparatus provided in the embodiments of the present application, by introducing the focus loss function into the rewriting model, apply the rewriting model based on the focus loss function to perform information search. Since the focus loss function is weighted by the modulation factor, the modulation factor of the easy sample with low rewriting difficulty is small, and the modulation factor of the difficult sample with high rewriting difficulty is large, so that the weight of the easy sample is relatively reduced, and the weight of the difficult sample is relatively increased. Therefore, the rewriting model focuses on optimizing the loss caused by the difficult sample. Therefore, the rewriting model will choose the difficult sample to learn first, thereby solving the imbalance problem of easy and difficult samples. Since the rewriting model can effectively use the difficult sample for learning, the effect of the rewriting model is improved, then the candidate query information found by the rewriting model will be more appropriate as the rewritten query information, and can accurately correct the errors contained in the original query information. Therefore, when the candidate query information found by the rewriting model is used for searching, the accuracy of the search results can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0028] Figure 1 is a schematic diagram of an implementation environment of an information search method provided in an embodiment of the present application;
[0029] Figure 2 This is a flowchart of a training method for a rewriting model provided in an embodiment of the present application;
[0030] Figure 3 This is a schematic diagram of the principle of query rewriting provided by an embodiment of the present application;
[0031] Figure 4 This is a structural diagram of a rewriting model provided in an embodiment of the present application;
[0032] Figure 5 is a schematic diagram of a focusing loss function provided in an embodiment of the present application;
[0033] Figure 6 This is a flow chart of an information search method provided by an embodiment of the present application;
[0034] Figure 7 This is a flowchart of a method for searching for information in an instant messaging application provided by an embodiment of the present application;
[0035] Figure 8 This is a schematic diagram of the structure of an information search device provided in an embodiment of the present application;
[0036] Figure 9 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;
[0037] Figure 10 This is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0039] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items having substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is the quantity and execution order limited. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of various examples, the first condition can be referred to as the second condition, and similarly, the second condition can be referred to as the first condition. Both the first condition and the second condition can be conditions, and in some cases, can be separate and different conditions.
[0040] In this application, the term "at least one" means one or more, and the term "plurality" means two or more. For example, a plurality of candidate query information refers to two or more candidate query information.
[0041] It should be understood that the terms used in the description of the various examples herein are for the purpose of describing the particular examples only and are not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0042] It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the listed items. The term "and / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this application generally indicates that the associated objects are in an "or" relationship.
[0043] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0044] It should also be understood that determining B based on A does not mean determining B solely based on A. B can also be determined based on A and / or other information.
[0045] It will also be understood that the term “comprise” (also known as “inCludes,” “inCluding,” “Comprises,” and / or “Comprising”) when used in this specification specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0046] It should also be understood that the term "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, the phrase "if it is determined that..." or "if [stated condition or event] is detected" may be interpreted to mean "upon determining that..." or "in response to determining that..." or "upon detecting [stated condition or event]" or "in response to detecting [stated condition or event]," depending on the context.
[0047] It should also be understood that the term "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, the phrase "if it is determined that..." or "if [stated condition or event] is detected" may be interpreted to mean "upon determining that..." or "in response to determining that..." or "upon detecting [stated condition or event]" or "in response to detecting [stated condition or event]," depending on the context.
[0048] Since the embodiments of the present application involve the application of artificial intelligence, for ease of understanding, the relevant concepts in the artificial intelligence technology involved in the embodiments of the present application are first introduced below.
[0049] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0050] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0051] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0052] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.
[0053] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, autonomous driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0054] Query rewriting is the process of rewriting one query into another. Query rewriting is a crucial module of search engines. Specifically, when users use search engines on mobile devices, they may enter queries that contain errors, synonyms, or even inaccuracies due to cognitive or typing errors. In these cases, the search engine's query rewriting module often needs to rewrite these inaccurate queries into queries with similar semantics but that can retrieve more target documents. These queries are then sent to the backend engine, hoping to return search results for the correct query to the user. Query rewriting essentially involves finding candidate queries that are similar to the original query.
[0055] The solutions provided in the embodiments of this application involve technologies such as NLP and query rewriting based on artificial intelligence, which are specifically illustrated by the following embodiments.
[0056] Figure 1 1 is a schematic diagram of an implementation environment of an information search method provided in an embodiment of the present application. The implementation environment includes: a terminal 101 and an information search platform 102. The terminal 101 is connected to the information search platform 102 via a wireless network or a wired network.
[0057] Terminal 101 may be at least one of a smart phone, a game console, a desktop computer, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player or an MP4 (Moving Picture Experts Group Audio Layer IV) player and a laptop computer. Terminal 101 has installed and runs an application that supports information search, for example, the application may be an instant messaging application, a news push application, a shopping application, an online video application, a social application, and the social application may be a social application that aggregates people based on topics, channels or circles, or other applications with social attributes. Exemplarily, terminal 101 is a terminal used by a first user, and a first account is logged in to the application running in terminal 101, and the first account is the user account of the first user.
[0058] The information search platform 102 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. The information search platform 102 provides backend services for applications that support information search. Optionally, the information search platform 102 performs primary processing, while the terminal 101 performs secondary processing. Alternatively, the information search platform 102 performs secondary processing, while the terminal 101 performs primary processing. Alternatively, the information search platform 102 or the terminal 101 can each independently perform processing. Alternatively, the information search platform 102 and the terminal 101 can collaboratively perform computing using a distributed computing architecture.
[0059] Optionally, the information search platform 102 includes: a server 1021 and a database 1022. The server 1021 is used to provide background services related to information search. The server 1021 can be one or more servers. When there are multiple servers 1021, there are at least two servers 1021 used to provide different services, and / or there are at least two servers 1021 used to provide the same service, such as providing the same service in a load balancing manner, which is not limited in this embodiment of the present application. The database 1022 stores the data required to process the task. When the server 1021 needs data, it can access the database 1022 and read the data stored in the database 1022. When the server processes the task and obtains the result of the information search, the result of the information search can be written to the database 1022, thereby persistently storing the result of the information search through the database 1022.
[0060] Those skilled in the art will appreciate that the number of the terminals 101 and servers 1021 may be more or less. For example, the terminal 101 and server 1021 may be only one, or the terminal 101 and server 1021 may be dozens or hundreds, or more. Figure 1 Not shown, the above implementation environment also includes other terminals, and the other terminals have logged in a second account that has a friend relationship with the first account. The embodiment of the present application does not limit the number and device type of terminals or servers.
[0061] The embodiment of this application involves the application of the focus loss function in the rewriting model, which can be widely used in various information search scenarios. The rewriting model based on the focus loss function involves the model training stage and the model prediction stage. Please refer to the attached figure for the process of the model training stage. Figure 2 For the example shown, please refer to the attached Figure 6 In other words, the attached Figure 2 The embodiment shown is about how to use the sample set to train the rewriting model. Figure 6The embodiment shown is about how to use the trained rewriting model to search for information. It should be understood that the model prediction stage and the model training stage have the same or corresponding features. Figure 6 Examples and Figure 2 For similar implementation details, please refer to Figure 2 Example, in Figure 6 No further description is given in the embodiments.
[0062] Figure 2 This is a flow chart of a training method for a rewriting model provided in an embodiment of the present application. Figure 2 , the method includes S101 to S105.
[0063] S101: The server obtains a sample set.
[0064] Sample sets can be constructed from a variety of sources. For example, they can be constructed using sound-similar corpora, form-similar corpora, synonymous corpora, missing word corpora, changed word corpora, query sessions, and manual annotation. Sample sets also include at least one sample query. Sample query information refers to a query that serves as a sample. For example, sample query information is a historical query received by a search engine at a historical point in time. Another example is a query input by a sample user.
[0065] The server can obtain the sample set in a variety of ways. For example, the sample set can be pre-stored in a database, and the server can read the sample set from the database. Alternatively, the server can download the sample set from a website. Alternatively, the server can input the sample set into the server through configuration. This embodiment does not limit the method for obtaining the sample set.
[0066] S102: The server obtains at least one candidate query information of a sample that matches the original query information of the sample according to the original query information of the sample in the sample set.
[0067] The sample original query information refers to the original query information used as the sample. The original query information is also called the original query, original string, original query, query before rewriting, or query to be rewritten.
[0068] Sample candidate query information refers to candidate query information that serves as a sample. Candidate query information is also referred to as candidate query, potential target text, potential error correction string, or potential error correction string. The candidate query information and the sample original query information meet matching conditions. For example, the text similarity between the candidate query information and the original query information is higher than a first threshold. For another example, the behavioral similarity between the click behavior corresponding to the candidate query information and the click behavior corresponding to the original query information is higher than a second threshold. For another example, the semantic similarity between the semantic representation vector of the candidate query information and the semantic representation vector of the original query information is higher than a third threshold.
[0069] An original query information optionally has one or more candidate query information. In this embodiment, by training a rewriting model, it helps to find the most suitable candidate query information from each candidate query information matched by the original query information as the rewritten query information of the original query information, so as to perform a search using the rewritten query information.
[0070] Among them, the rewritten query information is also called an error correction string, a rewritten Query, an error correction Query, a target Query or a target string. The rewritten query information refers to the query information that is most matched with the sample original query information among at least one candidate query information matched by the sample original query information.
[0071] Optionally, the samples in the sample set are in the form of Query pairs. A sample includes two Queries. One Query is the sample original query information, and the other Query is the sample candidate query information. For the sample original query information included in the sample, according to the different difficulties of determining the rewritten query information and whether the sample candidate query information is the rewritten query information, the samples in the sample set are divided into multiple types. The types of samples are introduced exemplarily below.
[0072] Referring to Table 1 below, according to the four characteristics of positive, negative, difficult, and easy, the samples can be divided into four categories shown in Table 1. Specifically, from the perspective of positive and negative, the samples include positive samples and negative samples. From the perspective of difficult and easy, the samples include difficult samples and easy samples. Generally speaking, the samples include positive difficult samples, positive easy samples, negative difficult samples, and negative easy samples.
[0073] Table 1
[0074] Sample type Difficult samples Easy Sample Positive samples Positive and difficult samples Positive sample Negative samples Negative difficult samples Negative exchange samples
[0075] Among them, a positive difficult sample means that the sample is both a positive sample and a difficult sample. A positive easy sample means that the sample is both a positive sample and an easy sample. A negative difficult sample means that the sample is both a negative sample and a difficult sample. A negative easy sample means that the sample is both a negative sample and an easy sample.
[0076] A positive sample is a term in the field of machine learning. A positive sample generally refers to a sample belonging to the category to be predicted. Applied to the information search scenario based on query rewriting provided in this embodiment, a positive sample includes the sample original query information and the sample candidate query information, and the sample candidate query information is the rewritten query information corresponding to the sample original query information. For example, the sample includes the original Query "Jixiang Hun Dun" and the candidate Query "Jixiang Huntun", where "Jixiang Huntun" is the rewritten Query of "Jixiang Hun Dun", and this sample can be called a positive sample.
[0077] Negative sample is a term in the field of machine learning. A negative sample generally refers to a sample that does not belong to the category to be predicted. Applied to the information search scenario based on query rewriting provided in this embodiment, the negative sample includes the original query information of the sample and the candidate query information of the sample, and the candidate query information of the sample is not the rewritten query information corresponding to the original query information of the sample. For example, the sample includes the original Query "汽车改" (Car modification) and the candidate Query "汽车改装" (Automobile modification), where "汽车改装" is not the rewritten Query of "汽车改", and this sample can be called a negative sample.
[0078] Easy example is a term in the field of machine learning. An easy example generally refers to a sample that is easy to classify (well-classified example). An easy example is a sample that the model can easily predict accurately. In other words, an easy example is a sample with a high confidence level in the sample set. Applied to the information search scenario based on query rewriting provided in this embodiment, an easy example is a sample in the sample set that is easy to rewrite. The rewriting difficulty of an easy example is less than that of a difficult example. Specifically, the rewriting difficulty of an easy example satisfies the second condition. Satisfying the second condition may optionally include multiple situations.
[0079] For example, if the sample is a phonetic input error type sample, then this sample can be called an easy example, and the rewriting difficulty of this sample satisfies the second condition. Among them, the phonetic input error type sample includes the original query information of the sample and the candidate query information of the sample, and the similarity between the pronunciation of the candidate query information and the pronunciation of the candidate query information is higher than the fourth threshold. For example, the sample includes the original Query "诸葛亮" (Zhuge Liang) and the candidate Query "猪哥亮" (Zhu Ge Liang). The pronunciation of "诸葛亮" is similar to that of "猪哥亮". If "诸葛亮" should be rewritten as "猪哥亮", then "诸葛亮" and "猪哥亮" are phonetic input error type samples, and this sample is an easy example.
[0080] For example, if the sample is a shape input error type sample, then the rewriting difficulty of this sample satisfies the second condition, and this sample can be called an easy example. Among them, the shape input error type sample includes the original query information of the sample and the candidate query information of the sample, and the similarity between the glyph of the candidate query information and the glyph of the candidate query information is higher than the fifth threshold. For example, the sample includes the original Query "小呈序游侠" (Xiaochengxu Youxia) and the candidate Query "小程序游戏" (Xiaochengxu Game). The glyph of "小呈序游侠" is similar to that of "小程序游戏". The user wanted to input "小程序游戏" but entered "小呈序游侠" by mistake due to typing errors. If "小呈序游侠" should be rewritten as "小程序游戏", then "小呈序游侠" and "小程序游戏" are shape input error type samples, and this sample is an easy example.
[0081] Among them, confidence is a term in the field of machine learning. Confidence is the probability that the category predicted by the model for the sample is the same as the label of the sample. Applied to the information search scenario based on query rewriting provided in this embodiment, for a positive sample, the confidence is the probability that the rewriting model predicts that the type of the positive sample is rewritten. For example, after the positive sample is input into the rewriting model, the probability predicted by the rewriting model is close to 1, then the confidence is high. For a negative sample, the confidence is the probability that the rewriting model predicts that the type of the negative sample is not rewritten. For example, after the negative sample is input into the rewriting model, the probability predicted by the rewriting model is close to 0, then the confidence is high.
[0082] Hard examples are a term used in the field of machine learning. Hard examples generally refer to samples that are difficult to classify (hard, miss-classified examples). Hard examples are samples that are difficult for a model to accurately predict. Hard examples are samples with low confidence in a sample set. In the information search scenario based on query rewriting provided in this embodiment, hard examples are samples in a sample set that are difficult to rewrite, and the difficulty of rewriting hard examples is greater than that of easy examples. Specifically, the difficulty of rewriting hard examples satisfies the third condition. Satisfying the third condition can optionally include multiple situations.
[0083] For example, if the sample is a sample with incorrect input at the semantic level, that is, the sample is a sample that does not express the meaning, then the sample can be called a difficult sample, and the difficulty of rewriting the sample meets the third condition. Among them, the sample with incorrect input at the semantic level includes the sample original query information and the sample candidate query information, and the semantic similarity between the semantics of the sample candidate query information and the semantics of the sample candidate query information is lower than the fifth threshold. In other words, the semantics of the candidate query have changed compared to the original query, so the conversion from the original query to the candidate query must go through the semantic level, which makes it very difficult. For example, the sample includes the original query "the last night" and the candidate query "a night after being drunk". The semantics of "the last night" are different from those of "a night after being drunk". This sample is a difficult sample.
[0084] For example, considering that the rewriting difficulty of mid- to long-tail queries is generally greater than that of head queries, if the original query information and candidate query information in a sample are mid- to long-tail queries, then the sample can be considered a difficult sample. The rewriting difficulty of this sample meets the third condition. Here, mid- to long-tail queries are mid- to long-tail keywords.
[0085] Exemplarily, please refer to Table 2 below. Table 2 shows the samples included in the sample set and the labels of the samples. In Table 2, the positive samples are the samples with the label "error correction". The negative samples are the samples with the label "no error correction". The samples with the note "difficult samples" show difficult samples. Specifically, one row in Table 2 shows one sample, and each sample is a Query pair. || is the separator between the original Query and the candidate Query in the same Query pair. Before ||, the original Query in the sample is shown, that is, the original query information of the sample. After ||, the candidate Query in the sample is shown, that is, the candidate query information of the sample. Among them, "吉祥混沌" and "吉祥馄饨" form a Query pair, and this Query pair is a positive sample, where "混沌" in "吉祥混沌" should be rewritten as "馄饨". "电视遥万器" and "电视遥控器" form a Query pair, and this Query pair is a positive sample, where "万" in "电视遥万器" should be rewritten as "控". "cf活动枪" (cf is the name of a game) and "cf活动" form a Query pair, and this Query pair is a positive sample, where "枪" in "cf活动枪" should be deleted. "汽车改" and "汽车改装" form a Query pair, and this Query pair is a negative sample, and "汽车改装" is not the rewritten Query of "汽车改". "宛草" and "莞草" form a Query pair, and this Query pair is a negative sample, and "莞草" is not the rewritten Query of "宛草". "路地巡航舰" and "路地巡洋舰" form a Query pair, and this Query pair is a positive sample, where "航" in "路地巡航舰" should be rewritten as "洋". "是个" and "诗歌" form a Query pair, and this Query pair is a positive sample, where "是个" should be rewritten as "诗歌". "菲律宾世界" and "菲律宾时间" form a Query pair, and this Query pair is a positive sample, where "世界" in "菲律宾世界" should be rewritten as "时间". "广告场大全" and "广告词大全" form a Query pair, and this Query pair is a positive sample, where "场" in "广告场大全" should be rewritten as "词". "超级校园霸王" and "超级学校霸王" form a Query pair, and this Query pair is a positive sample, where "校园" in "超级校园霸王" should be rewritten as "学校". "婴儿肺炎" and "小儿肺炎" form a Query pair, and this Query pair is a positive sample, where "婴儿" in "婴儿肺炎" should be rewritten as "小儿".
[0086] Table 2
[0087]
[0088]
[0089] Samples of different types often present an imbalance within a sample set. This imbalance is also known as unevenness or uneven quantity. Sample imbalance has two main aspects: an imbalance between positive and negative samples, and an imbalance between easy and difficult samples.
[0090] The problem of positive-negative sample imbalance refers to an imbalance in the ratio of negative to positive samples in a sample set. Typically, if the number of positive samples in a sample set far exceeds the number of negative samples, or vice versa, this will lead to positive-negative sample imbalance. This example describes how to address this problem by introducing a balancing factor into the loss function.
[0091] The imbalance problem of difficult and easy samples refers to the situation where the ratio of difficult samples to easy samples in the sample set is unbalanced. Under normal circumstances, the number of easy samples in the sample set is much greater than the number of difficult samples, which will lead to an imbalance of difficult and easy samples. Applied to the information search scenario based on query rewriting provided in this embodiment, the imbalance problem of difficult and easy samples is, for example, such a situation: samples with low rewriting difficulty account for a large proportion in the sample set, while samples with high rewriting difficulty account for a small proportion in the sample set. For example, the proportion of samples of the head rewriting type and the proportion of samples of the medium and long tail rewriting type are often as high as 5:1. Obviously, the samples of the head rewriting type are very unbalanced compared with the samples of the medium and long tail rewriting type. For example, most of the samples in the sample set are easy-to-rewrite sound-like input error samples and shape-like input error samples, while samples with semantic input errors are less distributed in the sample set. These situations will cause the imbalance problem of difficult and easy samples.
[0092] During the model training phase, due to the extremely unbalanced number of easy and difficult samples, the number of easy samples is relatively large, which causes the easy samples to dominate the overall loss. That is, in the process of calculating the loss value, the proportion of the loss caused by easy samples in the overall loss of the sample set is much greater than the proportion of the loss caused by difficult samples in the overall loss of the sample set. This causes the rewriting model to often overfit on "simple" and more common rewriting types during overall optimization, while the "difficult" rewriting types that the model itself needs to solve are still not effectively learned. In this embodiment, considering that the improvement effect of easy samples on the model is very small, the model should focus mainly on those difficult samples. By improving the loss function, the problem of the machine learning model not being able to effectively converge to a better solution due to the imbalance of sample difficulty in complex rewriting scenarios is solved, thereby solving the problem of suboptimal model performance. In this embodiment, we will introduce how to solve the problem of imbalance between easy and difficult samples by introducing a modulation factor in the loss function.
[0093] S103: The server inputs the sample original query information and at least one sample candidate query information into the rewriting model.
[0094] This embodiment provides a rewriting model based on deep learning. This rewriting model is also called a Query rewriting model. By performing the task of Query rewriting through this rewriting model, the recall rate can be effectively improved in the information search scenario.
[0095] See Figure 3 , the principle of the rewriting model is similar to the noise-channel model in the field of communication technology. Figure 3 In [reference], Query-I represents the real Query input by the user, and Query-I can be provided as the original query information. Figure 3 In [reference], Query-O represents the Query output after Query-I passes through the noise channel. Query-O can be understood as the Query with noise added to Query-I. Here, the noise is, for example, typing errors, cognitive errors, etc. Query-I’ represents the error-corrected Query, and Query-I’ can be provided as the rewritten query information. The decoder is used to map Query-O to Query-I’. Figure 3 The decoder in [reference] is optionally implemented using a machine learning algorithm. Figure 3 The decoder in [reference] can be mapped to Figure 4 the neural network 301 in the rewriting model 300 in [reference].
[0096] Combined with Figure 3 the principle of the rewriting model shown in [reference], the Query rewriting problem can be decomposed into the following recall task and sorting task.
[0097] The recall task includes calculating the prior probability that the sample candidate query information is the rewritten query information of the sample original query information. The prior probability is P(I). For example, according to features such as the popularity of the sample candidate query information, language model, etc., calculate P(I). For example, according to features such as the popularity of "Zhu Geliang" and the language model, calculate the prior probability that "Zhu Geliang" is the rewritten query information of "Zhu Geliang", and obtain the P(I) corresponding to "Zhu Geliang".
[0098] The sorting task includes calculating the transition probability between the sample original query information and the sample candidate query information, sorting each candidate query information matching the sample original query information according to the magnitude of the transition probability, and according to the sorting result, selecting the candidate query information as the rewritten query information. For example, calculate the transition probability from "Xiaochengxu game" to "Xiaochengxu game", and if it is found that the transition probability is high, then determine that "Xiaochengxu game" is the rewritten Query of "Xiaochengxu game".
[0099] The rewriting model provided in this embodiment optimizes Figure 3 the maximum loss of the transition probability P(O / I) in [reference]. Specifically, the method of obtaining the maximum loss can be expressed by the following formula (1).
[0100]
[0101] In formula (1), argmax is a function. For example, when there is another function y = f(x), if the result x0 = argmax(f(x)), it means that when the function f(x) takes x = x0, the maximum value of the value range of f(x) is obtained. In other words, the result of argmax is the set of x points that makes f(x) reach the maximum value. I is the abbreviation of input, I represents the query input by the user, that is, the original query information (original string). P represents probability. P(I) represents the probability of the original query information. O is the abbreviation of output, O represents the rewritten query information (error correction string). P(O) represents the prior probability that the sample candidate query information is the rewritten query information. P(O / I) represents the transition probability, specifically the probability from the original query information (original string) to the rewritten query information (rewritten string).
[0102] The following is an exemplary introduction to the structure of the rewriting model.
[0103] Optionally, the rewriting model includes a machine learning model and a focus loss function connected to the machine learning model. The predicted value output by the rewriting model is, for example, a loss value calculated by the focus loss function. The machine learning model may be, for example, a neural network, a logistic regression (LR) model, a gradient boosting decision tree (GBDT) model, etc. Of course, the machine learning model may also be other machine learning models trained by supervised learning.
[0104] Rewrite the model as Figure 4 The rewritten model 300 in FIG. 3 includes a neural network 301 and a focus loss function 302. The neural network 301 is followed by the focus loss function 302. For example, the output layer of the neural network 301 is connected to the focus loss function.
[0105] The neural network 301 is, for example, a convolutional neural network (CNN) or a long short-term memory (LSTM) network. Optionally, the neural network 301 applies an attention mechanism. The neural network 301 is used to extract features from the query information to obtain a semantic representation vector of the query information. The neural network 301 includes an input layer, a hidden layer, and an output layer. Each layer may include a number of neurons, and each neuron is used to perform linear mapping and nonlinear mapping on the input parameters. Among them, the neurons may include at least one of a convolution kernel, a Gaussian kernel, a kernel structure, a gate structure, and a memory unit.
[0106] The rewriting model is trained on the sample set based on the Focal Loss (FL) function. The following is an example introduction to the Focal Loss function.
[0107] A loss function is a term used in machine learning models. It calculates the loss value, which indicates the deviation between the model's predicted value for a sample and the true value. During model training, the model's parameters are adjusted to minimize the loss of the entire sample set. If the sample set consists of N samples, the overall loss of the sample set is the average or sum of the losses of the N samples. N is an integer greater than or equal to 1.
[0108] The focus loss function is a new loss function, also known as the focal loss function. The focus in the focus loss function refers to the model focusing on learning difficult samples during the training process. In general, the focus loss function is weighted by a modulation factor, which relatively reduces the weight of easy samples and relatively increases the weight of difficult samples. Through this clever design, when there is an imbalance between difficult and easy samples in the sample set, since the weight of easy samples is reduced, even if the number of easy samples is large, the overall contribution of easy samples to the total loss of the sample set will be very small. Therefore, the model focuses on optimizing the loss caused by difficult samples, so that the model will continuously and dynamically select difficult samples (such as positive samples with low prediction probability) for learning first, thereby solving the imbalance problem between difficult and easy samples and optimizing the training effect when the difference in difficulty and easy distribution is large.
[0109] In this embodiment, by introducing the focus loss function into the query rewriting task in the NLP field, the focus loss function is applied in the rewriting model, so that the rewriting model will give priority to samples with high rewriting difficulty for learning.
[0110] The focus loss function optionally includes multiple parts. In one possible implementation, the focus loss function includes a first loss function and a modulation factor for weighting the first loss function. Optionally, the focus loss function also includes a balance factor for weighting the first loss function. In the focus loss function, the modulation factor and the balance factor can be considered as two different weight terms.
[0111] The first loss function is used to calculate the deviation between the model's predicted value and the label for the sample. The types of the first loss function include various cases. For example, the first loss function includes but is not limited to a cross entropy (CE) loss function, a conditional entropy loss function, a mean square error (MSE), a relative entropy loss function, and the like. In the following, the first loss function is described as a cross entropy loss function, and the same applies to cases where the first loss function is other types of loss functions.
[0112] The cross entropy loss function is used to indicate the difference between two distributions. The loss value calculated by the cross entropy loss function can be called the cross entropy loss. For a sample, the closer the model's predicted value for the sample output is to the sample's label, the smaller the cross entropy loss of the sample; the farther the model's predicted value for the sample output is from the sample's label, the greater the cross entropy loss of the sample. For positive samples, the label of the positive sample is usually represented by 1. The greater the probability that the model outputs the positive sample, the smaller the cross entropy loss of the positive sample. For negative samples, the label of the negative sample is usually represented by 0. The smaller the probability that the model outputs the negative sample, the smaller the cross entropy loss of the negative sample. The cross entropy loss function is shown in the following formula (2).
[0113]
[0114] In formula (2), CE represents the cross entropy loss function, y represents the sample label, and the value of y is 0 or 1. The value of y for a positive sample is 1. The value of y for a negative sample is 0. p represents probability, and p is, for example, the output of the machine learning model in the rewritten model, such as the output of neural network 301. The value range of p is (0, 1), and log represents the logarithm.
[0115] Research has found that directly using the cross-entropy loss function as the rewriting model's loss function can lead to a slow iteration process for large numbers of easy samples due to the imbalance between easy and difficult samples, and may not be optimized to the optimal state. Furthermore, due to the imbalance between positive and negative samples, the rewriting model struggles to effectively learn from a relatively small number of negative or positive samples.
[0116] In this embodiment, a balancing factor and a modulation factor are added before the cross-entropy loss function. The balancing factor can solve the problem of imbalance between positive and negative samples, and the modulation factor can solve the problem of imbalance between difficult and easy samples. The following describes the balancing factor and the modulation factor respectively.
[0117] The balance factor has different values for positive samples in the sample set than for negative samples in the sample set. For example, if the proportion of positive samples in the sample set is greater than the proportion of negative samples, the balance factor has a smaller value for positive samples than for negative samples. If the proportion of positive samples in the sample set is less than the proportion of negative samples, the balance factor has a larger value for positive samples than for negative samples. Through this design, the weight of the positive or negative sample with an excessively high proportion is reduced, which relatively increases the proportion of the loss of the positive or negative sample with an excessively low proportion in the overall loss of the sample set. This balances the importance of positive and negative samples and reconciles the imbalance between positive and negative samples, allowing the model to effectively use the positive or negative sample with an excessively low proportion for learning, thereby improving the model's effectiveness and making the rewritten query information found by the model more accurate, thereby improving the accuracy of searches using the model.
[0118] The balance factor includes hyperparameters. In one possible implementation, the balance factor is represented by α. After adding the balance factor before the cross entropy loss function, the cross entropy loss function changes from the above formula (2) to the following formula (3). In formula (3), the form of the balance factor for positive samples (i.e., when y = 1) is α, and the form of the balance factor for negative samples (i.e., when y = 0) is (1-α). If α is 0.25, when the focus loss function is used to calculate the positive sample, the value of the balance factor is equal to α, so the value of the balance factor is 0.25. When the focus loss function is used to calculate the negative sample, the value of the balance factor is equal to (1-α), so the value of the balance factor is (1-0.25) = 0.75.
[0119]
[0120] In addition, similar to formula (2), in formula (3), CE represents the cross entropy loss function, y represents the sample label, and the value of y is 0 or 1. The value of y for a positive sample is 1. The value of y for a negative sample is 0. P represents probability, and P is, for example, the output result of the machine learning model in the rewritten model, such as P is the output result of the neural network 301. The value range of p is (0, 1), and log represents the logarithm.
[0121] The modulation factor for easy samples is smaller than the modulation factor for difficult samples. The value of the modulation factor is positively correlated with the difficulty of rewriting the sample in the sample set. In other words, when the focused loss function is used to calculate samples with low rewriting difficulty, the modulation factor is small. When the focused loss function is used to calculate samples with high rewriting difficulty, the modulation factor is large.
[0122] Optionally, the modulation factor comprises an indicator function and a focus parameter.
[0123] The indicator function is, for example, denoted as pt. The value of the indicator function is used to indicate the deviation between the sample's predicted value and the sample's label. The indicator function ranges from [0, 1]. For example, for a positive sample, the indicator function is p(x), and for a negative sample, the indicator function is 1-p(x). Optionally, an easy sample is a sample for which the value of the indicator function is greater than 0.5.
[0124] The focusing parameter is represented by γ, for example. The focusing parameter is used to adjust the rate of weight reduction of easy samples in the sample set. Specifically, through the focusing parameter, the gradient of difficult samples can be relatively amplified and the gradient of easy samples can be relatively reduced. Optionally, the focusing parameter is a hyperparameter. The focusing parameter is, for example, a value greater than or equal to 0. When the focusing parameter is 0, the value of the focusing loss function is equal to the value of the cross entropy loss function. In other words, when the focusing parameter is 0, the focusing loss function is equivalent to the cross entropy loss function. As the focusing parameter increases, the influence of the modulation factor will increase synchronously.
[0125] Optionally, the modulation factor is in the form of an exponential function, and the modulation factor includes an exponential part and a base part. The focusing parameter is the exponential part of the modulation factor. The indicator function is the base part of the modulation factor. For example, for a positive sample, the modulation factor is in the form of (1-p) γ For negative samples, the modulation factor is in the form of p γ . Taking the positive sample as an example, when the positive sample is misclassified, p is too small and the modulation factor is close to 1. At this time, the loss value is not affected, that is, the product of the cross-entropy loss and the modulation factor is not much different from the cross-entropy loss. When the positive sample is correctly classified, p is close to 1 and the modulation factor is close to 0, which is equivalent to the weight of the cross-entropy loss being greatly attenuated, that is, the product of the modulation factor and the cross-entropy loss is much smaller than the cross-entropy loss. For example, for positive sample 1 and positive sample 2, the probability p predicted by the neural network for positive sample 1 is 0.95, and the probability predicted by the neural network for positive sample 2 is 0.3. The power of (1-0.95) is much smaller than the power of (1-0.3). Therefore, the loss value calculated by the focus loss function for positive sample 2 is relatively larger, causing the model to focus more on the difficult-to-distinguish positive sample 2.
[0126] In summary, the modulation factor reduces the loss of easy examples, thereby increasing the weight of the loss of hard examples in the overall loss of the sample set, allowing the rewritten model to focus on training hard examples. Furthermore, increasing the modulation factor increases the importance of hard examples. Furthermore, the modulation factor can expand the range of examples that yield low loss.
[0127] For example, in the focus loss function, the first loss function and the modulation factor are combined by multiplication. Taking the first loss function as the cross entropy loss function as an example, the focus loss function is shown in the following formula (4).
[0128]
[0129] In addition, similar to formula (3), in formula (4), y represents the label of the sample, and the value of y is 0 or 1. The value of y for a positive sample is 1. The value of y for a negative sample is 0. P represents probability, and P is, for example, the output result of the machine learning model in the rewritten model, such as P is the output result of neural network 301. The value range of p is (0, 1), and log represents the logarithm.
[0130] Combining the modulation factor, smoothing factor, and first loss function described above, the focus loss function is optionally the product of the modulation factor, the balance factor, and the first loss function. For example, the focus loss function is shown in the following formula (5). Formula (5) can be regarded as a combination of formula (3) and formula (4), which can simultaneously solve the problem of imbalance between positive and negative samples and the problem of imbalance between easy and difficult samples.
[0131]
[0132] In formula (5), FL represents the focus loss function, y represents the sample label, and the value of y is 0 or 1. P is the output of the machine learning model in the rewritten model, and the value range of p is (0, 1). Log represents the logarithm. γ ≥ 0.
[0133] For example, when r is 2, if p = 0.968, and is substituted into the above formula (5), the modulation factor is (1-0.968)2≈0.001. Then, by multiplying 0.001 and the CE loss, the loss is attenuated by a factor of 1000.
[0134] In addition, by taking the focusing parameter as the exponential part of the modulation factor and taking the indicator function as the base part of the modulation factor, the rate at which the weight value of the easy sample is reduced can be smoothly adjusted.
[0135] For example, see Figure 5 , Figure 5 The figure shows the focusing loss function when the focusing parameter γ is configured with different values. Figure 5 Five curves are shown, each representing a focus loss function. Among them, the focus loss function when γ = 0 is shown as ①. The focus loss function when γ = 0.5 is shown as ②. The focus loss function when γ = 1 is shown as ③. The focus loss function when γ = 2 is shown as ④. The focus loss function when γ = 5 is shown as ⑤. Figure 5 It can be seen that the larger γ is, the greater the degree to which the loss of easy samples is attenuated. Figure 5The meaning of the expression includes: providing a new loss function, called the focus loss function. The focus loss function adds a factor (1-p t ) γ , reducing the number of samples that are easy to classify (such as p t >0.5), placing more attention on samples that are difficult to classify. Experiments have shown that the focused loss function makes it possible to rewrite the model with high accuracy when there are a large number of easy samples.
[0136] S104: The server processes the sample original query information and at least one sample candidate query information through the rewriting model, and outputs a predicted value of the at least one sample candidate query information.
[0137] During the training phase of the rewriting model, each time a query pair is input to the rewriting model, the query pair comprising the sample original query information and one sample candidate query information. The rewriting model processes the query pair and outputs a predicted value for the sample candidate query information in the query pair. For example, if the sample original query information corresponds to N sample candidate query information, the rewriting model processes the sample original query information and the i-th sample candidate query information and outputs a predicted value for the i-th sample candidate query information, thereby obtaining predicted values for N sample candidate query information. N is a positive integer, and i is an integer not greater than n.
[0138] The prediction value indicates the probability that the corresponding sample candidate query information is a rewritten query information of the sample original query information. Each sample candidate query information in the N sample candidate query information corresponds to a prediction value. For example, for the i-th sample candidate query information in the N sample candidate query information, the greater the prediction value of the i-th sample candidate query information, the greater the probability that the i-th sample candidate query information is a rewritten query information of the sample original query information. In other words, it is more appropriate to rewrite the sample original query information into the i-th sample candidate query information, and it is more appropriate to use the i-th sample candidate query information instead of the sample original query information for search.
[0139] The process of rewriting the internal operation of the model includes multiple implementations. Optionally, the machine learning model within the rewriting model is a neural network, and the process of performing the operation by the rewriting model includes the following S1041 to S1043.
[0140] S1041. The server extracts features from the original query information of the sample through a neural network to obtain a first semantic representation vector of the original query information of the sample.
[0141] The semantic representation vector is, for example, a word embedding. A semantic representation vector is a list of numbers that represents a word and captures its semantic meaning. The first semantic representation vector is the semantic representation vector of the original query information of the sample.
[0142] S1042: The server performs feature extraction on at least one sample candidate query information through a neural network to obtain a second semantic representation vector of the at least one sample candidate query information.
[0143] The second semantic representation vector refers to the semantic representation vector of the sample candidate query information. Each sample candidate query information in the N sample candidate query information corresponds to a second semantic representation vector. For example, for the i-th sample candidate query information in the N sample candidate query information, the server performs a neural network operation on the i-th sample candidate query information to obtain the second semantic representation vector of the i-th sample candidate query information.
[0144] S1043. The server operates the first semantic representation vector and the at least one second semantic representation vector respectively through a focus loss function to obtain a predicted value of at least one sample candidate query information.
[0145] For example, for the i-th sample candidate query information among N sample candidate query information, the server performs operations by focusing the loss function, the first semantic representation vector and the second semantic representation vector of the i-th sample candidate query information to obtain the predicted value of the i-th sample candidate query information.
[0146] See attached Figure 4 , combined with Figure 4 In the model structure shown, the above-mentioned S1041 to S1043 include, for example, the following steps a to d.
[0147] Step a: The server performs word segmentation on the sample candidate query information (i.e., the original query) to obtain a first word set. The server also performs word segmentation on the sample candidate query information (i.e., the potential rewritten query) to obtain a second word set.
[0148] For example, the first word set includes Figure 4 w in 11 、w 12…… w 1m Among them, w 11 Indicates the first word in the original query information, w 12 Indicates the second word in the original query information, w 1m Indicates the mth word in the original query information. The ellipsis indicates that the original query information includes Figure 4 Other words not shown in . For example, the second word set is Figure 4 w in21 、w 22…… w 2m .w 21 represents the first word in the sample candidate query information, w 22 represents the second word in the sample candidate query information, w 2m Indicates the mth word in the sample candidate query information, and the ellipsis indicates that the sample candidate query information includes Figure 4 Other words not shown.
[0149] Step b: The server performs word embedding on the first word set to obtain word embedding (QueryEmbedding) of the original query information, and performs word embedding on the second word set to obtain word embedding (QueryEmbedding) of the candidate query information.
[0150] Step c: The server inputs the word embedding of the original query information into a CNN or LSTM, performs feature extraction on the word embedding of the original query information through the CNN / LSTM, and obtains a first semantic representation vector (Query Embedding). The server inputs the word embedding of the candidate query information into a CNN or LSTM, performs feature extraction on the word embedding of the candidate query information through the CNN / LSTM, and obtains a second semantic representation vector (Query Embedding).
[0151] in, Figure 4 303 in FIG. 303 shows the first semantic representation vector, and each circle in 303 represents the value of a dimension in the first semantic representation vector. The ellipsis in 303 indicates that the first semantic representation vector includes Figure 4 Dimensions not shown. Figure 4 304 in the figure shows the second semantic representation vector, and each circle in 304 represents the value of a dimension in the second semantic representation vector. The ellipsis in 304 indicates that the second semantic vector includes Figure 4 Dimensions not shown.
[0152] Step d: The server calculates a prediction value based on the first semantic representation vector, the second semantic representation vector, and the focus loss function.
[0153] For example, the server operates on the first semantic representation vector and the second semantic representation vector through CNN or LSTM to obtain the transition probability from the first semantic representation vector to the second semantic representation vector, and operates on the transition probability through the focus loss function to obtain a predicted value.
[0154] In some embodiments, in addition to using the focus loss function, other loss functions can be optionally used in the rewritten model to address the imbalance between difficult and easy samples. For example, the focus loss function is replaced with a gradient harmonizing mechanism (GHM) function, which is an improvement based on the focus loss function and can optimize the training effect of the model.
[0155] S105: The server adjusts parameters of the rewriting model according to the predicted value of at least one sample candidate query information and the label of at least one sample candidate query information.
[0156] During the training of the rewritten model, due to the use of a focus loss function (see Table 3 below), the loss of positive easy examples is attenuated by γ, while the loss of negative easy examples is attenuated by γ and α, resulting in a relatively amplified loss of difficult examples. Thus, the model prioritizes the following order of focus within the sample set: positive difficult examples > negative difficult examples > positive easy examples > negative easy examples. For example, positive difficult examples are examples where the words do not express the intended meaning. For example, positive difficult examples include the original query "last night" and the candidate query "a night after getting drunk." For example, negative difficult examples are examples where excessive corrections are caused by search popularity. The candidate queries in these negative difficult examples are hot words. For example, negative difficult examples include the original query "protests in a certain country" and the candidate query "epidemic prevention in a certain country." For example, positive easy examples are examples with similar appearances. For example, positive easy examples include the original query "small sequence ranger" and the candidate query "mini program game." Negative easy examples are examples of common miscorrections. This is achieved by randomly constructing two unrelated queries, using one as the original query and the other as the candidate query. The original query and the candidate query form a correction pair, resulting in a negative easy example. For example, the negative exchange sample includes the original query "university" and the candidate query "college". For another example, the negative exchange sample includes the original query "Shaanxi" and the candidate query "Shanxi".
[0157] Table 3
[0158] Sample type Difficult samples Easy Sample Positive samples ① Positive and difficult samples ③ Positive sample γ decay Negative samples ②Negative hard sample α decay ④ Negative sample α and γ attenuation
[0159] There are various ways to train a rewriting model. For example, the server uses a backpropagation algorithm to adjust the weights of each convolution kernel in the neural network based on the loss value calculated by the focus loss function. This weight adjustment improves the accuracy of the neural network's predictions, reducing the gap between the predicted value output by the rewriting model and the label of the sample candidate query information during the next prediction. The loss value calculated by the focus loss function is the predicted value output by the rewriting model.
[0160] The above shows an iterative process of training. After each iteration, the server can detect whether the training termination condition has been met. When the training termination condition is not met, the server executes the next iterative process to obtain a new loss value, and adjusts the model parameters again according to the new loss value until the training termination condition is met. The neural network used in this iterative process can be output as a trained neural network, and the rewritten model including the trained neural network and the focus loss function can be output as a trained rewritten model.
[0161] Among them, the training termination condition can be that the number of iterations reaches the target number or the focus loss function meets the preset conditions, or it can be that its ability has not been improved within a period of time when verified based on the verification data set. Among them, the target number of iterations can be a preset number of iterations to determine the timing of the end of training to avoid wasting training resources. The preset condition can be that the loss value calculated by the focus loss function during training does not change or decrease for a period of time. When the training termination condition is met, it means that the training process has achieved the training effect, that is, the rewriting model has the function of predicting whether the candidate query information is the rewritten query information of the original query information based on the original query information and the candidate query information.
[0162] It should be understood that this embodiment is merely an example of the same server executing S101 to S105. In some embodiments, S101 to S105 can be collaboratively executed by multiple devices. For example, multiple servers form a distributed computing architecture and execute S101 to S105 in parallel. In some embodiments, the information search platform 102 can undertake the primary processing work, and the terminal 101 can undertake the secondary processing work. For example, the terminal 101 obtains the query that the user has historically entered into the search engine as a sample set and sends it to the information search platform 102. The information search platform 102 executes S102 to S104. In other embodiments, the information search platform 102 undertakes the secondary processing work, and the terminal 101 undertakes the primary processing work. Alternatively, the information search platform 102 or the terminal 101 can each independently undertake the processing work.
[0163] The method provided in this embodiment introduces the focus loss function into the rewriting model in the NLP field. Since the focus loss function is weighted by the modulation factor, the weight of the easy samples is relatively reduced, and the weight of the difficult samples is relatively increased. Therefore, when the focus loss function is applied to the rewriting model, the rewriting model will focus on optimizing the loss caused by difficult samples during the training phase. Therefore, it will give priority to learning samples with high rewriting difficulty, thereby solving the imbalance problem of difficult and easy samples, optimizing the training effect when the difference in difficulty distribution is large, and improving the effect of the rewriting model obtained by training.
[0164] above Figure 2 The embodiment introduces the training process of rewriting the model. Figure 6 Example, application Figure 2 The process of information search using the rewriting model provided in the embodiment is introduced.
[0165] See also Figure 6 , Figure 6 This is a flow chart of an information search method provided by an embodiment of the present application. The method includes S201 to S205. The method is applied to an electronic device. The electronic device can be Figure 1 The terminal 101 in the system architecture shown can also be Figure 1 The information search platform 102 in the system architecture shown is, for example, a server 1021. Figure 6 Electronic devices and implementations of embodiments Figure 2 The servers of the embodiment can be the same device or different devices. Figure 6 Electronic devices and implementations of embodiments Figure 2 The servers of the embodiments are different, and the electronic devices in the two method embodiments can interact and collaboratively complete the task of information search. For example, the training step of the rewriting model can be performed by the server, and the step of detecting using the prediction model can be performed by the terminal. Of course, the training step and the detection step of the prediction model can also be performed on the terminal side, or both on the server side. It should also be understood that Figure 6 The embodiment focuses on describing Figure 2 The difference between the embodiment and Figure 2 For similar steps, see Figure 2 Example, in Figure 6 No further description is given in the embodiments.
[0166] Figure 6 This is a flow chart of an information search method provided by an embodiment of the present application. Figure 6 , the method comprising:
[0167] S201. The electronic device obtains original query information.
[0168] For example, a user inputs a query through a search engine, and the electronic device obtains the query input through the search engine as original query information.
[0169] S202: The electronic device obtains at least one candidate query information that matches the original query information based on the original query information.
[0170] For example, the electronic device reads the query information stored in the database, and if the query information stored in the database and the candidate query information meet the matching condition, the query information meeting the matching condition is determined as the candidate query information.
[0171] S203: The electronic device inputs the original query information and at least one candidate query information into the rewriting model.
[0172] S204. The electronic device processes the original query information and at least one candidate query information through the rewriting model, and outputs a prediction value of at least one candidate query information, where the prediction value indicates a probability that the corresponding candidate query information is a rewritten query information of the original query information.
[0173] During the prediction phase of the rewriting model, each time a query pair is input to the rewriting model, the rewriting model processes the query pair, outputting a predicted value for the candidate query in the query pair. For example, if N candidate queries are found in the database based on the original query, the rewriting model processes the original query and the i-th candidate query, outputting a predicted value for the i-th candidate query. After N processing steps, N predicted values for the candidate queries are obtained.
[0174] Similar to the training phase, the process of performing calculations by rewriting the model in the prediction phase includes the following S2041 to S2043.
[0175] S2041. The electronic device extracts features from the original query information using a neural network to obtain a first semantic representation vector of the original query information.
[0176] S2042. The electronic device extracts features from the at least one candidate query information using a neural network to obtain a second semantic representation vector for the at least one candidate query information.
[0177] S2043. The electronic device performs operations on the first semantic representation vector and the at least one second semantic representation vector respectively through a focus loss function to obtain a predicted value of at least one candidate query information.
[0178] S205. The electronic device searches for candidate query information whose predicted value satisfies a first condition in at least one candidate query information.
[0179] After obtaining a predicted value for at least one candidate query, the electronic device selects a candidate query whose predicted value satisfies a first condition from the at least one candidate query, uses the candidate query whose predicted value satisfies the first condition as rewritten query, and performs a search based on the candidate query whose predicted value satisfies the first condition. For example, the predicted value satisfies the first condition when the predicted value of the candidate query is the highest among the predicted values of the at least one candidate query. In another example, the predicted value satisfies the first condition when the predicted value of the candidate query is greater than a prediction value threshold.
[0180] Optionally, after searching for candidate query information whose predicted value satisfies the first condition in at least one candidate query information, search results are provided through a search engine. For example, the search engine is provided through a browser or client, and the search results are displayed on a web page or client interface. Optionally, in the process of displaying the search results, candidate query information whose predicted value satisfies the first condition and the original query information are displayed to prompt the user that the current search results are obtained using the candidate query information rather than the original query information. For example, the original query information entered by the user in the search engine is Xiao Yunxu, and the candidate query information whose predicted value satisfies the first condition found based on Xiao Yunxu is Mini Program. A search is performed based on Mini Program, and "The following search results contain Mini Programs. Still searching: Xiao Yunxu" is displayed in the search results interface.
[0181] It should be understood that this embodiment is only described by taking the execution of the above S201 to S205 by the same electronic device as an example. In some embodiments, the above S201 to S205 can be executed collaboratively by multiple devices. For example, the terminal 101 executes S201 to S204 to determine the candidate query information whose predicted value meets the first condition in at least one candidate query information, and sends the candidate query information whose predicted value meets the first condition to the information search platform 102. The information search platform 102 receives the candidate query information whose predicted value meets the first condition from the terminal 101, executes S205, obtains the search results, and the information search platform 102 sends the search results to the terminal 101.
[0182] The method provided in this embodiment introduces a focus loss function into the rewriting model, and applies the rewriting model based on the focus loss function to perform information search. Since the focus loss function is weighted by a modulation factor, the modulation factor of the easy sample with low rewriting difficulty is small, and the modulation factor of the difficult sample with high rewriting difficulty is large, so that the weight of the easy sample is relatively reduced, and the weight of the difficult sample is relatively increased. Therefore, the rewriting model focuses on optimizing the loss caused by the difficult sample. Therefore, the rewriting model will choose the difficult sample to learn first, thereby solving the imbalance problem of easy and difficult samples. Since the rewriting model can effectively use difficult samples for learning, the effect of the rewriting model is improved, then the candidate query information found by the rewriting model will be more appropriate as the rewritten query information, and can accurately correct the errors contained in the original query information. Therefore, when the candidate query information found by the rewriting model is used for searching, the accuracy of the search results can be effectively improved.
[0183] Figure 6 The information search method provided in the embodiment can be applied to the scenario of searching through a search engine. The search engine is set in, for example, an instant messaging application, a web page, an e-commerce application, an advertising application, etc., and accordingly, Figure 6The information search method provided in the embodiment can be applied to search in instant messaging applications, web page search, e-commerce search, advertising search and other search scenarios.
[0184] The following Figure 7 Embodiment, the embodiment of this application is attached Figure 6 The information search method described is applied to the process of instant messaging application as an example. Figure 7 In the embodiment shown, the original query information comes from the user's input in the instant messaging application client, and the search results are provided to the user through the instant messaging application client. Figure 7 The method described is about how instant messaging applications use rewriting models to search for information. It should be understood that Figure 7 Examples and Figure 6 For similar steps, see Figure 6 Example, in Figure 7 No further description is given in the embodiments.
[0185] Figure 7 This is a flow chart of a method for searching for information in an instant messaging application provided by an embodiment of the present application. Figure 7 The execution subject of the method includes the client of the instant messaging application and the server of the background of the instant messaging application. The method includes S301 to S308.
[0186] S301: The client of the instant messaging application receives original query information input in the search box.
[0187] For example, the terminal displays the interface of an instant messaging application on the client, which may be a discovery page that includes items such as Moments and Shake. The instant messaging application interface includes a search button. After the user clicks the search button, the terminal displays a search box. The user enters text in the search box. The terminal detects the user's input operation and uses the text entered by the user as the original query.
[0188] S302: The client of the instant messaging application sends the original query information to the server of the instant messaging application.
[0189] Optionally, the instant messaging application interface includes at least one tag, which is used to specify the type of search results, with each tag representing a type of search result. For example, the tags include a friend circle tag, an article tag, a sub-program of the instant messaging application (which may be called a "mini-program") tag, a public social network identifier (which may be called a "public account") tag, a music tag, and an emoticon tag. If a user triggers an action on one of the at least one tags, the terminal sends the identifier of the tag to the server.
[0190] S303: The server obtains at least one candidate query information matching the original query information from the database of the instant messaging application according to the original query information.
[0191] Optionally, if the user triggers an operation on a Moments tag, the terminal sends the original query information and the identifier of the Moments tag to the server. The server obtains at least one Moments information that matches the original query information from the Moments information corresponding to the user account of the user based on the original query information as the at least one candidate query information.
[0192] Optionally, if the user triggers an action on an article tag, the terminal sends the original query information and the identifier of the article tag to the server. The server then retrieves, based on the original query information, at least one article information matching the original query information from the article information corresponding to the user account, as at least one candidate query information. The article information corresponding to the user account includes article information that the user has historically browsed, article information that the user's friends have historically browsed, article information that the user has historically shared, and so on.
[0193] Optionally, if the user triggers an action on a mini-program tag, the terminal sends the original query information and the identifier of the mini-program tag to the server. Based on the original query information, the server retrieves at least one mini-program information matching the original query information from the mini-program information corresponding to the user's account, as at least one candidate query information. The mini-program information corresponding to the user account includes mini-programs registered by the user account, mini-programs followed by the user account, and so on.
[0194] Optionally, if the user triggers an action on a public account tag, the terminal sends the original query information and the identifier of the public account tag to the server. The server then retrieves, based on the original query information, at least one public account information that matches the original query information from the public account information corresponding to the user account, as at least one candidate query information. The public account information corresponding to the user account includes, for example, public accounts that the user account has subscribed to.
[0195] Optionally, if the user triggers an operation on a music tag, the terminal sends the original query information and the identifier of the music tag to the server. The server retrieves, based on the original query information, at least one piece of music information that matches the original query information from the music information corresponding to the user account of the user, as at least one candidate query information. The music information corresponding to the user account includes music information played by the user account, music information downloaded by the user account, and the like.
[0196] Optionally, if the user triggers an action on an emoticon tag, the terminal sends the original query information and the identifier of the emoticon tag to the server. The server then retrieves, based on the original query information, at least one emoticon information matching the original query information from the emoticon information corresponding to the user's user account, as at least one candidate query information. The emoticon information corresponding to the user account includes emoticons that the user account has collected, emoticons that the user's friends have sent to the user in the past, emoticons that the user has sent to the user's friends in the past, and so on.
[0197] Optionally, if the user does not trigger an operation on the tag, the server obtains at least one candidate query information matching the original query information from the circle of friends information, article information, mini program information, public account information, music information, and emoticon information corresponding to the user account based on the original query information.
[0198] S304: The server inputs the original query information and at least one candidate query information into the rewriting model.
[0199] S305: The server processes the original query information and at least one candidate query information through the rewriting model, and outputs a predicted value of the at least one candidate query information.
[0200] S306: The server searches for resources matching the candidate query information in the instant messaging application based on the candidate query information whose predicted value satisfies the first condition in the at least one candidate query information.
[0201] The resources matched by the candidate query information include but are not limited to at least one of the friend circle information matched by the candidate query information, article information matched by the candidate query information, mini-program messages in instant messaging applications that match the candidate query information, public social network identifiers matched by the candidate query information, music information matched by the candidate query information, and emoticon information matched by the candidate query information.
[0202] S307: The server sends the resources matching the candidate query information to the client of the instant messaging application.
[0203] S308: The client of the instant messaging application provides resources matching the candidate query information in the instant messaging application.
[0204] In this embodiment, by using a rewriting model based on a focused loss function to search within an instant messaging application, the focused loss function addresses the imbalance between easy and difficult samples, allowing the rewriting model to effectively leverage difficult samples for learning. Therefore, the candidate query information found by the rewriting model is more appropriate as the rewritten query information, accurately correcting errors contained in the original query information. This effectively improves the accuracy of search results provided by the instant messaging application. For example, when a user enters an article title as the original query in an instant messaging application to search for articles within the instant messaging application, even if the entered article title contains a typo, the instant messaging application corrects the error using the rewriting model. Therefore, searching based on the correct article title will result in more matching articles. For another example, when a user enters the name of a mini-program as the original query to search within the instant messaging application, even if the entered mini-program name contains an error, the instant messaging application corrects the error using the rewriting model. Therefore, searching based on the correct mini-program name will result in more matching mini-programs.
[0205] It should be understood that Figure 7 The embodiment is an example of an application scenario of information search based on the rewriting model. In other embodiments, Figure 2 The rewriting model based on the focus loss function trained in the embodiment is applied in other scenarios.
[0206] For example, in a web search scenario, a terminal displays a webpage through a browser. The webpage includes a search box, and the user can enter text in the search box. The browser uses the user's input as the original query, and the browser's backend server searches the webpage based on the original query. In this scenario, if the text entered in the search box contains an error, the rewriting model can find a rewritten query from the candidate queries, and then search using the rewritten query, thereby recalling more matching webpages.
[0207] For example, in a scenario where a user searches through an e-commerce app, the terminal displays the shopping app's interface, which includes a search button. After the user clicks the search button, the terminal displays a search box where the user can enter a product title. The e-commerce app uses the product title as the original query, and the backend server searches for products based on the original query. In this scenario, if the product title entered by the user in the search box contains an error, the rewriting model can find a rewritten query from the candidate queries and use the rewritten query for the search, thereby recalling more matching products.
[0208] Figure 8 This is a schematic diagram of the structure of an information search device provided by an embodiment of the present application. Figure 8 , the device comprises:
[0209] An acquisition module 801 is configured to acquire, based on the original query information, at least one candidate query information that matches the original query information;
[0210] An input module 802 is configured to input the original query information and at least one candidate query information into a rewriting model, where the rewriting model is trained on a sample set based on a focused loss function, where the focused loss function includes a first loss function and a modulation factor for weighting the first loss function, where the value of the modulation factor is positively correlated with the rewriting difficulty of samples in the sample set;
[0211] A processing module 803 is configured to process the original query information and at least one candidate query information using a rewriting model, and output a prediction value of the at least one candidate query information, where the prediction value indicates a probability that the corresponding candidate query information is a rewritten query information of the original query information;
[0212] The search module 804 is configured to search for candidate query information whose predicted value satisfies a first condition in at least one candidate query information.
[0213] The device provided by the embodiment of the present application introduces a focus loss function into the rewriting model, and applies the rewriting model based on the focus loss function to perform information search. Since the focus loss function is weighted by a modulation factor, the modulation factor of the easy sample with low rewriting difficulty is small, and the modulation factor of the difficult sample with high rewriting difficulty is large, so that the weight of the easy sample is relatively reduced, and the weight of the difficult sample is relatively increased. Therefore, the rewriting model focuses on optimizing the loss caused by the difficult sample. Therefore, the rewriting model will choose the difficult sample to learn first, thereby solving the imbalance problem of easy and difficult samples. Since the rewriting model can effectively utilize difficult samples for learning, the effect of the rewriting model is improved, then the candidate query information found by the rewriting model will be more appropriate as the rewritten query information, and can accurately correct the errors contained in the original query information. Therefore, when the candidate query information found by the rewriting model is used for searching, the accuracy of the search results can be effectively improved.
[0214] Optionally, the modulation factor includes a focusing parameter, and the focusing parameter is used to adjust the weight reduction rate of easy samples in the sample set, and the rewriting difficulty of the easy samples meets the second condition.
[0215] Optionally, the focusing parameter is the exponential part of the modulation factor.
[0216] Optionally, the modulation factor includes an indicator function, and the value of the indicator function is used to indicate the deviation between the predicted value of the sample and the label of the sample.
[0217] Optionally, the indicator function is the base part of the modulation factor.
[0218] Optionally, the focusing loss function also includes a balancing factor for weighting the first loss function, the value of the balancing factor for the positive samples in the sample set is different from the value of the balancing factor for the negative samples in the sample set, the sample candidate query information included in the positive samples is the rewritten query information of the corresponding sample original query information, and the sample candidate query information included in the negative samples is not the rewritten query information of the corresponding sample original query information.
[0219] Optionally, the focusing loss function is the product of the modulation factor, the balance factor and the first loss function.
[0220] Optionally, the rewriting model includes a neural network and a focusing loss function connected to the output layer of the neural network, and a processing module 803 is used to extract features of the original query information through the neural network to obtain a first semantic representation vector of the original query information; extract features of at least one candidate query information through the neural network to obtain a second semantic representation vector of at least one candidate query information; and operate the first semantic representation vector and the at least one second semantic representation vector through the focusing loss function to obtain a predicted value of at least one candidate query information.
[0221] All of the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here.
[0222] It should be noted that the information search device provided in the above embodiment is merely illustrated by the division of the above functional modules when performing information search. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the information search device can be divided into different functional modules to complete all or part of the functions described above. In addition, the information search device provided in the above embodiment and the information search method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0223] The electronic device in the above method embodiment can be implemented as a terminal. For example, Figure 9 The following is a block diagram of a terminal 900 according to an exemplary embodiment of the present application. Terminal 900 may be a smartphone, tablet computer, MP3 (Moving Picture Experts Group Audio Layer III) player, MP4 (Moving Picture Experts Group Audio Layer IV) player, laptop computer, or desktop computer. Terminal 900 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other similar names.
[0224] Typically, the terminal 900 includes one or more processors 901 and one or more memories 902 .
[0225] The processor 901 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 901 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 901 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 901 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0226] The memory 902 may include one or more computer-readable storage media, which may be non-transitory. The memory 902 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 902 is used to store at least one program code, which is executed by the processor 901 to implement the information search method provided in the method embodiment of the present application.
[0227] In some embodiments, terminal 900 may optionally include a peripheral device interface 903 and at least one peripheral device. The processor 901, memory 902, and peripheral device interface 903 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 903 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 904, a touchscreen display 905, a camera assembly 906, an audio circuit 907, a positioning assembly 908, and a power supply 909.
[0228] The peripheral device interface 903 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 901 and the memory 902. In some embodiments, the processor 901, the memory 902, and the peripheral device interface 903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 901, the memory 902, and the peripheral device interface 903 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0229] The RF circuit 904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 904 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 904 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 904 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 904 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 904 may also include circuits related to Near Field Communication (NFC), which is not limited in this application.
[0230] Display screen 905 is used to display a user interface (UI). This UI can include graphics, text, icons, videos, or any combination thereof. When display screen 905 is a touchscreen display, it can also capture touch signals on or above the surface of display screen 905. These touch signals can be input as control signals to processor 901 for processing. Display screen 905 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be a single display screen 905, located on the front panel of terminal 900. In other embodiments, there can be at least two display screens 905, located on different surfaces of terminal 900 or in a foldable design. In still other embodiments, display screen 905 can be a flexible display, located on a curved or foldable surface of terminal 900. Display screen 905 can also be configured as a non-rectangular, irregular shape, i.e., a special-shaped screen. Display screen 905 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0231] The camera assembly 906 is used to capture images or videos. Optionally, the camera assembly 906 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 906 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0232] The audio circuit 907 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals to be input into the processor 901 for processing, or input into the radio frequency circuit 904 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 900. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 901 or the radio frequency circuit 904 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 907 may also include a headphone jack.
[0233] The positioning component 908 is used to locate the current geographical location of the terminal 900 to implement navigation or LBS (Location Based Service).
[0234] Power supply 909 is used to power various components in terminal 900. Power supply 909 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 909 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0235] In some embodiments, the terminal 900 further includes one or more sensors 910 , including but not limited to: an acceleration sensor 911 , a gyroscope sensor 912 , a pressure sensor 913 , a fingerprint sensor 914 , an optical sensor 915 , and a proximity sensor 916 .
[0236] The accelerometer 911 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal 900. For example, the accelerometer 911 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 901 can control the touch screen display 905 to display the user interface in a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 911. The accelerometer 911 can also be used to collect game or user motion data.
[0237] The gyroscope sensor 912 can detect the orientation and rotation angle of the terminal 900. It can work with the accelerometer 911 to collect the user's 3D movements on the terminal 900. Based on the data collected by the gyroscope sensor 912, the processor 901 can implement the following functions: motion sensing (for example, changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0238] The pressure sensor 913 can be set on the side frame of the terminal 900 and / or the lower layer of the touch screen display 905. When the pressure sensor 913 is set on the side frame of the terminal 900, it can detect the user's grip signal of the terminal 900, and the processor 901 performs left and right hand recognition or shortcut operations based on the grip signal collected by the pressure sensor 913. When the pressure sensor 913 is set on the lower layer of the touch screen display 905, the processor 901 controls the operable controls on the UI interface based on the user's pressure operation on the touch screen display 905. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0239] The fingerprint sensor 914 is used to collect the user's fingerprint. The processor 901 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 914, or the fingerprint sensor 914 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 901 authorizes the user to perform relevant sensitive operations, such as unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. The fingerprint sensor 914 can be set on the front, back, or side of the terminal 900. When a physical button or manufacturer logo is set on the terminal 900, the fingerprint sensor 914 can be integrated with the physical button or manufacturer logo.
[0240] The optical sensor 915 is used to detect ambient light intensity. In one embodiment, the processor 901 can control the display brightness of the touchscreen display 905 based on the ambient light intensity detected by the optical sensor 915. Specifically, when the ambient light intensity is high, the display brightness of the touchscreen display 905 is increased; when the ambient light intensity is low, the display brightness of the touchscreen display 905 is decreased. In another embodiment, the processor 901 can also dynamically adjust the shooting parameters of the camera assembly 906 based on the ambient light intensity detected by the optical sensor 915.
[0241] Proximity sensor 916, also known as a distance sensor, is typically located on the front panel of terminal 900. Proximity sensor 916 is used to detect the distance between the user and the front of terminal 900. In one embodiment, when proximity sensor 916 detects that the distance between the user and the front of terminal 900 is gradually decreasing, processor 901 controls touchscreen display 905 to switch from the screen-on state to the screen-off state. When proximity sensor 916 detects that the distance between the user and the front of terminal 900 is gradually increasing, processor 901 controls touchscreen display 905 to switch from the screen-off state to the screen-on state.
[0242] Those skilled in the art will understand that Figure 9 The structure shown in the figure does not constitute a limitation on the terminal 900, and the terminal 900 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0243] The electronic device in the above method embodiment can be implemented as a server. For example, Figure 10 This is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server 1000 may vary greatly due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 1001 and one or more memories 1002, wherein the memory 1002 stores at least one program code, and the at least one program code is loaded and executed by the processor 1001 to implement the information search method provided in each of the above method embodiments. Of course, the server may also have components such as wired or wireless network interfaces and input and output interfaces for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0244] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including at least one program code. The at least one program code is executable by a processor to perform the information search method of the above embodiment. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, or an optical data storage device.
[0245] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0246] It should be understood that determining B based on A does not mean determining B based solely on A. B can also be determined based on A and / or other information.
[0247] Those skilled in the art will understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or by hardware related to program code, and the program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.
[0248] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. An information search method, characterized in that: The method comprises: obtaining, based on the original query information, at least one candidate query information that matches the original query information, where a semantic similarity between a semantic representation vector of the candidate query information and a semantic representation vector of the original query information is greater than a third threshold, and the at least one candidate query information is used to determine rewritten query information for the original query information to correct an error contained in the original query information; The original query information and the at least one candidate query information are input into a rewriting model, the rewriting model is obtained by training a sample set based on a focusing loss function, the focusing loss function includes a first loss function and a modulation factor for weighting the first loss function, the value of the modulation factor is positively correlated with the rewriting difficulty of the samples in the sample set, the value of the modulation factor for the easy samples in the sample set is smaller than the value of the modulation factor for the difficult samples in the sample set, the rewriting difficulty of the easy samples is smaller than the rewriting difficulty of the difficult samples, the rewriting difficulty is used to indicate the difficulty of determining the rewriting query information, and the rewriting difficulty of the easy samples satisfies the second Condition, the case where the second condition is satisfied includes at least one of the following: the similarity between the pronunciation of the sample original query information in the easy sample and the pronunciation of the sample candidate query information is higher than a fourth threshold, the similarity between the glyphs of the sample original query information in the easy sample and the glyphs of the sample candidate query information is higher than a fifth threshold, the rewriting difficulty of the difficult sample meets the third condition, and the case where the third condition is satisfied includes at least one of the following: the semantic similarity between the semantics of the sample original query information in the difficult sample and the semantics of the sample candidate query information is lower than a fifth threshold, the sample original query information in the difficult sample and the sample candidate query information are medium and long tail words; Processing the original query information and the at least one candidate query information using the rewriting model, and outputting a prediction value for the at least one candidate query information, the prediction value being used to indicate a probability that the corresponding candidate query information is a rewritten query information of the original query information; The search is performed based on candidate query information whose predicted value satisfies the first condition in the at least one candidate query information.
2. The method according to claim 1, characterized in that The modulation factor includes a focus parameter, which is used to adjust a weight reduction rate of easy samples in the sample set, and the rewriting difficulty of the easy samples meets the second condition.
3. The method according to claim 2, characterized in that The focusing parameter is the exponential part of the modulation factor.
4. The method according to claim 1, wherein The modulation factor includes an indicator function, and a value of the indicator function is used to indicate a deviation between a predicted value of the sample and a label of the sample.
5. The method according to claim 4, characterized in that The indicator function is the base part of the modulation factor.
6. The method according to claim 1, characterized in that The focusing loss function also includes a balancing factor for weighting the first loss function, the value of the balancing factor for positive samples in the sample set is different from the value of the balancing factor for negative samples in the sample set, the sample candidate query information included in the positive sample is the rewritten query information of the corresponding sample original query information, and the sample candidate query information included in the negative sample is not the rewritten query information of the corresponding sample original query information.
7. The method according to claim 6, characterized in that The focusing loss function is the product of the modulation factor, the balance factor and the first loss function.
8. The method according to claim 1, characterized in that The rewriting model includes a neural network and the focus loss function connected to an output layer of the neural network, and processing the original query information and the at least one candidate query information by the rewriting model to output a predicted value of the at least one candidate query information includes: Performing feature extraction on the original query information through the neural network to obtain a first semantic representation vector of the original query information; Performing feature extraction on the at least one candidate query information using the neural network to obtain a second semantic representation vector of the at least one candidate query information; The first semantic representation vector and the second semantic representation vector of the at least one candidate query information are respectively operated by the focus loss function to obtain a predicted value of the at least one candidate query information.
9. An information search device, characterized in that: The device comprises: an acquisition module, configured to acquire, based on original query information, at least one candidate query information that matches the original query information, wherein a semantic similarity between a semantic representation vector of the candidate query information and a semantic representation vector of the original query information is greater than a third threshold, and wherein the at least one candidate query information is used to determine a rewritten query information of the original query information to correct an error contained in the original query information; An input module is used to input the original query information and the at least one candidate query information into a rewriting model, wherein the rewriting model is obtained by training a sample set based on a focused loss function, wherein the focused loss function includes a first loss function and a modulation factor for weighting the first loss function, wherein the value of the modulation factor is positively correlated with the rewriting difficulty of the sample in the sample set, the value of the modulation factor for the easy sample in the sample set is smaller than the value of the modulation factor for the difficult sample in the sample set, the rewriting difficulty of the easy sample is smaller than the rewriting difficulty of the difficult sample, and the rewriting difficulty is used to indicate the difficulty of determining the rewriting query information, and the rewriting difficulty of the easy sample is sufficient. The second condition is satisfied, and the cases where the second condition is satisfied include at least one of the following: the similarity between the pronunciation of the sample original query information in the easy sample and the pronunciation of the sample candidate query information is higher than a fourth threshold, and the similarity between the glyphs of the sample original query information in the easy sample and the glyphs of the sample candidate query information is higher than a fifth threshold; the rewriting difficulty of the difficult sample satisfies the third condition, and the cases where the third condition is satisfied include at least one of the following: the semantic similarity between the semantics of the sample original query information in the difficult sample and the semantics of the sample candidate query information is lower than a fifth threshold, and the sample original query information in the difficult sample and the sample candidate query information are medium and long tail words; a processing module, configured to process the original query information and the at least one candidate query information using the rewriting model, and output a prediction value for the at least one candidate query information, the prediction value being used to indicate a probability that the corresponding candidate query information is a rewritten query information of the original query information; The search module is configured to search for candidate query information whose predicted value satisfies a first condition in the at least one candidate query information.
10. An electronic device, characterized in that: The electronic device includes one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the operations performed by the information search method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the operations performed by the information search method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Processing method and device of search request on the basis of search engine
CN105335391A
Aerially-photographed vehicle real-time detection method based on deep learning
CN108647665A
Classifier, neural network model training method, data processing device, and medium
CN109902722A