Language model training method, prediction method, device and electronic equipment

By constructing negative samples by deleting or replacing search words in language model training, and constructing corresponding loss functions, the problem of low accuracy of positive and negative labels in the existing technology is solved, and the accuracy of semantic completeness prediction is improved.

CN114386396BActive Publication Date: 2024-10-25BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111554325.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2024-10-25
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

In the existing technology, the accuracy of positive and negative labels in language model training samples is low, resulting in low accuracy of semantic completeness prediction.

Method used

By obtaining positive and negative samples in the preset search information, negative samples are obtained by deleting or replacing search terms, and constructing corresponding loss functions for training to ensure that the language model can distinguish positive and negative labels.

Benefits of technology

The accuracy and discrimination of negative labels are improved, allowing the language model to more accurately predict the semantic completeness of the search information to be identified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114386396B_ABST
    Figure CN114386396B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a language model training method, prediction method, device and electronic device, the method comprising: obtaining training positive samples and training negative samples; inputting the training positive samples and training negative samples into the language model to be trained, and training the language model to be trained; in the case where the loss function value obtained based on the output result of the trained language model is less than a preset threshold, determining the trained language model as a target language model; the target language model is used to predict the semantic completeness of the search information to be identified. Since the training negative samples are obtained by deleting and / or replacing at least one search term in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search terms, so that the negative labels are more accurate and have discriminativeness, so that the target language model can better distinguish between positive and negative labels, and then can more accurately predict the semantic completeness of the search information to be identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, and in particular to a language model training method, prediction method, device and electronic device. Background Art

[0002] The language model (LM) is a model of the probability distribution of sentences. In layman's terms, it is to determine whether a language sequence is a normal sentence. As an important basic module for understanding search information, it is mainly used in tasks such as identifying incomplete search information, correcting search information, and suppressing low-quality search information. The task of the language model is to predict the next word corresponding to the word at each position, and finally multiply the probability output of each position to score the semantic completeness of the search information.

[0003] In the related art, when training a language model, the accuracy of positive and negative labels in the training samples is low. Taking the weather in Beijing as an example, the positive label corresponding to "North" is "Beijing", and the rest are negative labels; but these so-called negative labels are not all true negative labels. For example, "The weather in Beihai is very good" is also a normal sentence, so "Sea" can also be a positive label for "North" instead of a negative label. As a result, when the language model scores the semantic completeness of the search information, the score given is less accurate. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present disclosure provides a model training method, a prediction method, an apparatus, an electronic device and a storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, a language model training method is provided, comprising:

[0006] Acquire training positive samples and training negative samples; the training positive samples include semantically complete preset search information, and the training positive samples are annotated with positive labels; the training negative samples are obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative samples are annotated with negative labels;

[0007] Inputting the training positive samples and the training negative samples into a language model to be trained, and training the language model to be trained;

[0008] When the loss function value obtained based on the output result of the trained language model is less than a preset threshold, the trained language model is determined as a target language model; the target language model is used to predict the semantic completeness of the search information to be identified.

[0009] Optionally, obtaining a training negative sample includes:

[0010] Obtaining the number of search terms in the preset search information;

[0011] At least one search term is deleted from the preset search information to obtain the deleted search information, and the deleted search information is determined as a training negative sample; the number of search terms deleted from the preset search information is less than the total number of search terms in the preset search information; the first search term after the deleted search term is marked with a negative label.

[0012] Optionally, obtaining a training negative sample includes:

[0013] Acquire a target search word in the preset search information; the target search word has the same pronunciation or a similar character shape as a target misspelled word in a pre-established misspelled word table;

[0014] The target search word in the preset search information is replaced with the target misidentified word to obtain the search information after the search word is replaced, and the search information after the search word is replaced is determined as a training negative sample; the target misidentified word is marked with a negative label.

[0015] Optionally, the method further includes:

[0016] Constructing a first sub-loss function; the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive sample;

[0017] Constructing a second sub-loss function; the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample; the target negative label is a negative label obtained after deleting the at least one search term, and the target positive label is the deleted search term;

[0018] Constructing a third sub-loss function; the third sub-loss function is used to determine the loss value of the target search term caused by the target typo in the training negative sample;

[0019] The first sub-loss function, the second sub-loss function, and the third sub-loss function are weightedly summed to obtain the loss function of the language model to be trained.

[0020] Optionally, the method further includes:

[0021] Acquire a test positive sample and a test negative sample, wherein the test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search term in the information to be searched in the test positive sample;

[0022] The test positive sample and the test negative sample are respectively input into the target language model to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample; the first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample;

[0023] When the first prediction score is greater than the second prediction score, it is determined that the target language model is accurately predicted.

[0024] Optionally, the method further includes:

[0025] Obtaining the number of accurate predictions and the total number of predictions of the target language model for the test positive sample and the test negative sample;

[0026] Based on the number of accurate predictions and the total number of predictions, a prediction accuracy rate of the target language model is determined.

[0027] According to a second aspect of an embodiment of the present disclosure, a prediction method is provided, including:

[0028] Obtaining search information to be identified;

[0029] The search information to be identified is input into the target language model described in the first aspect to obtain a target prediction score corresponding to the search information to be identified; wherein the target prediction score is used to characterize the semantic completeness of the search information to be identified.

[0030] According to a third aspect of an embodiment of the present disclosure, a language model training device is provided, including:

[0031] A training sample acquisition module is configured to execute acquisition of training positive samples and training negative samples; the training positive samples include semantically complete preset search information, and the training positive samples are annotated with positive labels; the training negative samples are obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative samples are annotated with negative labels;

[0032] A language model training module is configured to input the training positive samples and the training negative samples into a language model to be trained, so as to train the language model to be trained;

[0033] The language model determination module is configured to determine the trained language model as the target language model when the loss function value obtained based on the output result of the trained language model is less than a preset threshold; the target language model is used to predict the semantic completeness of the search information to be identified.

[0034] Optionally, the training sample acquisition module is specifically configured to execute:

[0035] Obtaining the number of search terms in the preset search information;

[0036] At least one search term is deleted from the preset search information to obtain the deleted search information, and the deleted search information is determined as a training negative sample; the number of search terms deleted from the preset search information is less than the total number of search terms in the preset search information; the first search term after the deleted search term is marked with a negative label.

[0037] Optionally, the training sample acquisition module is specifically configured to execute:

[0038] Acquire a target search word in the preset search information; the target search word has the same pronunciation or a similar character shape as a target misspelled word in a pre-established misspelled word table;

[0039] The target search word in the preset search information is replaced with the target misidentified word to obtain the search information after the search word is replaced, and the search information after the search word is replaced is determined as a training negative sample; the target misidentified word is marked with a negative label.

[0040] Optionally, the device further comprises:

[0041] A first construction module is configured to execute construction of a first sub-loss function; the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive sample;

[0042] A second construction module is configured to execute construction of a second sub-loss function; the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample; the target negative label is a negative label obtained after deleting the at least one search term, and the target positive label is the deleted search term;

[0043] A third construction module is configured to execute construction of a third sub-loss function; the third sub-loss function is used to determine the loss value of the target search term caused by the target typo in the training negative sample;

[0044] The loss function determination module is configured to perform weighted summation of the first sub-loss function, the second sub-loss function, and the third sub-loss function to obtain the loss function of the language model to be trained.

[0045] Optionally, the device further comprises:

[0046] A test sample acquisition module is configured to acquire a test positive sample and a test negative sample, wherein the test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search word in the information to be searched in the test positive sample;

[0047] A prediction module is configured to execute inputting the test positive sample and the test negative sample into the target language model respectively, to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample; the first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample;

[0048] The prediction result determination module is configured to determine whether the target language model is accurate in prediction when the first prediction score is greater than the second prediction score.

[0049] Optionally, the device further comprises:

[0050] A prediction times acquisition module is configured to execute to acquire the accurate prediction times and the total prediction times of the target language model for the test positive sample and the test negative sample;

[0051] The prediction accuracy determination module is configured to determine the prediction accuracy of the target language model based on the number of accurate predictions and the total number of predictions.

[0052] According to a fourth aspect of an embodiment of the present disclosure, there is provided a prediction device, including:

[0053] A search information acquisition module, configured to acquire the search information to be identified;

[0054] The prediction score determination module is configured to execute inputting the search information to be identified into the target language model described in the third aspect to obtain a target prediction score corresponding to the search information to be identified; wherein the target prediction score is used to characterize the semantic completeness of the search information to be identified.

[0055] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0056] processor;

[0057] a memory for storing processor-executable instructions;

[0058] The processor is configured to execute the method described in any one of the first aspect or the second aspect of the claim.

[0059] According to the sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a method, which includes the steps of the method described in the first aspect or the second aspect.

[0060] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, which, when executed on a computer, enables the computer to execute the steps of the method described in the first aspect or the second aspect.

[0061] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0062] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0064] Figure 1 is a flow chart of a language model training method according to an exemplary embodiment;

[0065] Figure 2 is a flowchart of an implementation method for obtaining training negative samples;

[0066] Figure 3 is a flowchart of another implementation method of obtaining training negative samples;

[0067] Figure 4 A flowchart of another language model training method according to an exemplary embodiment;

[0068] Figure 5 A flowchart of another language model training method according to an exemplary embodiment;

[0069] Figure 6 is a flow chart of a prediction method according to an exemplary embodiment;

[0070] Figure 7 is a block diagram of a language model training device according to an exemplary embodiment;

[0071] Figure 8 is a block diagram of a prediction device shown according to an exemplary embodiment;

[0072] Fig. 9 is a block diagram of an electronic device shown according to an exemplary embodiment;

[0073] Fig.10 is a block diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners

[0074] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0075] In the related art, when training a language model, the accuracy of the positive and negative labels annotated in the training samples is relatively low. Taking the Beijing weather as an example, the positive label corresponding to "North" is "Beijing", and the rest are negative labels; the positive label corresponding to "Beijing" is "Weather", and the rest are negative labels. The positive label corresponding to "Weather" is "Atmosphere", and the rest are negative labels; the positive label corresponding to "Atmosphere" is the end symbol [eos]. The rest are negative labels.

[0076] When training a language model in the related art, the negative labels determined by the training samples have the following two problems:

[0077] First, the negative labels are not accurate enough. Taking "North" as an example, the positive label of "North" is "Beijing". The negative labels are other words in the vocabulary except "Beijing", but these so-called negative labels are not all truly negative labels. For example, "The weather in Beihai is very good" is also a normal sentence. Therefore, "Sea" can also be the positive label of "North" rather than a negative label.

[0078] Second, the negative labels lack discrimination: Taking "Weather" as an example, the positive label of "Weather" is "Atmosphere", and the negative labels include a series of other characters such as "Peace", "Automobile", "Altar", etc. However, among them, "Automobile" should be more negative than the other two characters because "Tiananmen in Beijing" and "The Temple of Heaven in Beijing" are both normal sentences, and "Qi" in "Beijing Tianqi" should be a misspelling.

[0079] In view of the problem in the related art that the accuracy of the semantic integrity of the predicted search information is relatively low due to the inaccurate and less discriminative negative labels in the training samples, the embodiments of the present disclosure provide a language model training method, a prediction method, a device, and an electronic device.

[0080] In the first aspect, the language model training method provided by the embodiment of the present disclosure is first described in detail.

[0081] Figure 1 is a flow chart of a language model method according to an exemplary embodiment. Figure 1 As shown, the following steps may be included:

[0082] In step S110, training positive samples and training negative samples are obtained.

[0083] The training positive samples include semantically complete preset search information, and the training positive samples are marked with positive labels; the training negative samples are obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative samples are marked with negative labels.

[0084] Specifically, in the embodiment of the present disclosure, when training the language model to be trained, it is necessary to select training samples, which can be divided into training positive samples and training negative samples. The training positive samples are preset search information with complete semantics that includes normal input. These preset search information are fine, that is, the preset search information will not have the phenomenon of missing or incorrect search terms. In addition, since the training positive samples include semantically complete preset search information, the training positive samples are marked with positive labels.

[0085] In order to make negative labels more accurate and discriminative, when obtaining training negative samples, the preset search information in the training positive samples may be randomly deleted or replaced with search terms, and the search terms in the preset search information in the training positive samples may also be deleted and replaced at the same time. In addition, since the training positive samples are obtained by deleting and / or replacing at least one search term in the preset search information, that is, the training negative samples include semantically incomplete search information, the training negative samples are not only annotated with positive labels, but also annotated with negative labels.

[0086] In order to make the scheme description clear and complete, the specific implementation method of obtaining training negative samples will be described in detail in the following embodiments.

[0087] In step S120, the training positive samples and the training negative samples are input into the language model to be trained, and the language model to be trained is trained.

[0088] Specifically, after obtaining the training positive samples and the training negative samples, the training positive samples and the training negative samples can be input into the language model to be trained, and the speech model to be trained can be trained. The language model to be trained can be a signal enhanced language model AWD-LSTM. Of course, the speech model to be trained can also be other models, which is not specifically limited in the embodiments of the present disclosure.

[0089] In step S130, when the loss function value obtained based on the output result of the trained language model is less than a preset threshold, the trained language model is determined as the target language model.

[0090] Among them, the target language model is used to predict the semantic completeness of the search information to be identified.

[0091] In the process of training the language model to be trained, it is possible to determine whether the language model to be trained has converged by constructing a loss function of the language model. If converged, it is determined that the training of the language model to be trained is completed, otherwise, the language model to be trained continues to be trained.

[0092] Specifically, in the process of training the language model, the loss function value of the loss function can be calculated in real time based on the output results of the language model. If the loss function value is less than a preset threshold, it means that the language model has converged. At this time, the language model training is completed, and the trained language model is determined as the target language model. The target language model can be used to predict the semantic completeness of the search information to be identified.

[0093] It should be noted that in order to enable the target language model to more accurately predict the semantic completeness of the search information to be identified, when constructing the loss function, the loss value corresponding to the positive label in the training positive sample and the loss value caused by the negative label obtained by deleting or replacing the search term in the training negative sample to the positive label can be considered. In order to make the scheme description clear and complete, the loss function construction method of the language model to be trained will be described in detail in the following embodiments.

[0094] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0095] exist Figure 1 Based on the embodiment shown, in order to explain in more detail how to obtain training negative samples, in another embodiment provided by the present disclosure, as shown in FIG. Figure 2 As shown, obtaining training negative samples may include the following steps:

[0096] S210: Obtain the number of search terms in preset search information.

[0097] Specifically, the preset search information usually includes multiple search terms. For example, when the preset search information is "Beijing weather", the search terms included in the preset search information are respectively: Bei, Jing, Tian, and Qi. At this time, the number of search terms in the preset search information is 4.

[0098] S220, Delete at least one search term from the preset search information to obtain the search information after deletion, and determine the search information after deletion as a training negative sample.

[0099] Among them, the number of search terms deleted from the preset search information is less than the total number of search terms in the preset search information. The first search term after the deleted search term is labeled with a negative label.

[0100] Specifically, one or several search terms in the preset search information can be randomly deleted to obtain the search information after deletion, and the search information obtained after each deletion can be used as a training negative sample. It should be noted that in the embodiments of the present disclosure, a single search term, that is, a single character, can be deleted, or a search term formed by two or more characters can also be deleted. This is all reasonable, and the embodiments of the present disclosure do not make specific limitations.

[0101] In the embodiment, when deleting at least one search term from the preset search information, it can include two methods: "random position deletion" and "random number deletion". "Random position deletion" means that deletion can start from any position in the preset search information. "Random number deletion" means that any number of characters can be deleted.

[0102] For example, if the preset search information is "Beijing weather", after deleting the last character, the search information after deletion is "Beijing Tian". Therefore, the positive label corresponding to "Tian" is "Qi", and the negative label is "[eos]". "Beijing Tian" can be used as a training negative sample. The negative label constructed in this way has a relatively high confidence.

[0103] In addition, taking the preset search information "starry sky simple drawing" as an example, after deleting "simple drawing", the search information after deletion is "starry sky drawing", and the negative label corresponding to "kong" is "drawing". However, the search information "starry sky drawing" is also smooth. So, shouldn't the negative label of "kong" be "drawing"? The answer is no, because in the context of "starry sky simple drawing", "kong -> drawing" is not allowed, otherwise it would become "starry sky drawing drawing". Therefore, even if "kong -> drawing" is regarded as a negative label, this signal may still not be strong enough and may be biased by the positive label of "kong -> drawing" in the "starry sky drawing" in the training data. Therefore, additional strengthening is needed. That is to say, using the characters in the context to select negative labels all have relatively high confidence.

[0104] It can be seen that, through the technical solution provided in this embodiment, by deleting at least one search term in the preset search information to obtain a training negative sample, and the first search term after the deleted search term in the training negative sample is labeled with a negative label, that is, using the words in the context of the preset search information to construct the negative label. In this way, the confidence of the obtained negative label is relatively high, more accurate and distinguishable. Therefore, during the training of the language model to be trained, the language model can better distinguish between positive and negative labels, and further enable the target language model to more accurately predict the semantic integrity of the search information to be recognized.

[0105] Based on the Figure 1 embodiment shown, in order to more elaborately illustrate how to obtain the training negative sample, in another embodiment provided by the present disclosure, as Figure 3 shown, obtaining the training negative sample may include the following steps:

[0106] In S310, obtain the target search term in the preset search information.

[0107] Wherein, the target search term has the same pronunciation or similar glyph as the target misspelled word in the pre-established misspelled word list.

[0108] Specifically, the target search term may be a word that the user may misspell. For example, for the preset search information: Beijing weather, since the user may input "气" as "汽", the target search term in Beijing weather is "气"; for the preset search information: Hanging the head and stabbing the thigh, since the user may input "股" as "骨", the target search term in "Hanging the head and stabbing the thigh" can be "股". For another example, for the preset search information: The pulse beats very fast, since the user may input "搏" as "博", "薄", etc., the target search term in "The pulse beats very fast" can be "搏".

[0109] In S320, replace the target search term in the preset search information with the target misspelled word to obtain the search information after replacing the search term, and determine the search information after replacing the search term as the training negative sample.

[0110] Wherein, the target misspelled word is labeled with a negative label.

[0111] In this step, the target search term that the user may misspell in the misspelled word list can be replaced with the target misspelled word to perform data augmentation to obtain the training negative sample. Specifically, for the problem of misspelled words in the search information, an open-source misspelled word list is used to construct the negative label by designing a data augmentation method for misspelled word replacement.

[0112] For example, assume the search information is: Beijing weather. Then the positive label for "天" is "气", and there is exactly "北京天气 -> 北京天汽" in the misspelled word list. Then, "气" can be replaced with "汽" to construct a negative label, that is, using "汽" as the negative label for "天" for additional signal enhancement.

[0113] Assume the preset search information is: The story of hanging oneself from the beam and stabbing one's thigh. Then the positive label for "刺" is "股". And there is exactly "悬梁刺骨 -> 悬梁刺股" in the misspelled word list. Then, "股" can be replaced with "骨" to construct a negative label, that is, using "骨" as the negative label for "刺" for additional signal enhancement.

[0114] Since the misspelled word list usually does not cover all samples, in the embodiments, training negative samples can also be constructed through similar-shaped characters and homophonic characters. For example, assume the preset search information is: The pulse beats very fast. By replacing "搏" with "博" or "薄", the training negative samples obtained can be: 脉博跳动很快, or 脉薄跳动很快, and "博" or "薄" in the training negative samples is labeled with a negative label.

[0115] It can be seen that through the technical solution provided in this embodiment, by replacing the target search term in the preset search information with the target misspelled word, training negative samples are obtained, and the target misspelled word is labeled with a negative label. Since in the context, it is almost impossible for the semantics to still be smooth after replacing with a homophonic character or a similar-shaped character. Therefore, the constructed negative label has a relatively high confidence. Thus, during the training of the language model to be trained, the language model can better distinguish between positive and negative labels, and further enable the target language model to more accurately predict the semantic integrity of the search information to be recognized.

[0116] In Figure 2 or Figure 3 Based on the embodiment shown, in another embodiment provided by the present disclosure, in order to determine whether the training of the language model converges, it is determined by constructing a loss function of the language model in the embodiments. As Figure 4 shown, the method may further include the following steps:

[0117] Step S410, construct a first sub-loss function.

[0118] Among them, the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive samples.

[0119] Specifically, when training the language model, the positive label in the training positive samples corresponds to a loss value. Therefore, when constructing the loss function, it is necessary to consider the loss value corresponding to the positive label in the training positive samples, thereby constructing the first sub-loss function. This first sub-loss function can be denoted as lm_loss. This is a multi-classification loss, and the category size corresponds to the size of the word list.

[0120] Taking "Beijing weather" as an example, lm_loss = P(Beijing|North) * P(weather|North, Beijing) * P(qi|North, Beijing, weather) * P([eos]|North, Beijing, weather, qi). Among them, P(Beijing|North) represents the probability that the positive label of North is Beijing; P(weather|North, Beijing) represents the probability that the positive label of Beijing is weather under the condition that the positive label of North is Beijing; P(qi|North, Beijing, weather) represents the probability that the positive label of weather is qi under the condition that the positive label of North is Beijing and the positive label of Beijing is weather; P([eos]|North, Beijing, weather, qi) represents the probability that the positive label of qi is the end symbol [eos] under the condition that the positive label of North is Beijing, the positive label of Beijing is weather, and the positive label of weather is qi.

[0121] Taking P(Beijing|North) as an example, the calculation formula of P(Beijing|North) can be:

[0122]

[0123] Among them, the number of addition times in the denominator of the above formula corresponds to the category size, that is, the size of the vocabulary. Taking x(Beijing|North) as an example, it represents the probability value that the next position of North output by the language model is Beijing, and so on for others.

[0124] Step S420, construct the second sub-loss function.

[0125] Among them, the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample. The target negative label is the negative label obtained after deleting at least one search term, and the target positive label is the deleted search term.

[0126] Specifically, when training the language model, the negative label constructed in the training negative sample will cause a loss value to the positive label. Therefore, when constructing the loss function of the language model, a second sub-loss function will be constructed, and this second sub-loss function is used to determine the loss value that the negative label constructed in the training negative sample will cause to the positive label.

[0127] Among them, this second sub-loss function can be regarded as the deletion loss, denoted as del_loss. This is also a multi-classification loss, and the category size can be set as needed, and the category size depends on how many negative labels are constructed.

[0128] Taking the preset search information as "Beijing weather" as an example, after deleting "qi", a negative label "weather -> end symbol [eos]" is constructed, that is, the negative label of weather is the end symbol [eos]. At this time, del_loss can be a binary classification task, and the positive label of weather is qi. Then del_loss can be represented by the probability that the positive label of qi is the end symbol [eos], and specifically can be expressed as:

[0129]

[0130] Among them, x([eos]|qi) represents the probability value that the next position after "qi" output by the language model is the end symbol [eos], and x([eos]|tian) represents the probability value that the next position after "tian" output by the language model is the end symbol [eos].

[0131] Step S430: Construct the third sub-loss function.

[0132] Among them, the third sub-loss function is used to determine the loss value of the target search term caused by the target misspelling in the training negative samples.

[0133] Specifically, when training the language model, the negative label constructed in the training negative samples, that is, the target misspelling, will cause a loss value to the positive label, that is, the target search term. Therefore, when constructing the loss function of the language model, the third sub-loss function will be constructed, and this third sub-loss function is used to determine the loss value of the target search term caused by the target misspelling in the training negative samples.

[0134] Among them, the third sub-loss function can be regarded as a substitution loss, denoted as sub_loss. This is a multi-classification loss, and the class size can be set as needed, which depends on how many negative labels are constructed.

[0135] Still taking the preset search information "Beijing weather" as an example, after replacing "qi" with "qi (steam)", only one negative label "tian -> qi (steam)" is constructed, that is, the negative label of "tian" is "qi (steam)", then it can be a binary classification task. The positive label is "tian -> qi" that is, the positive label of "tian" is "qi". At this time, sub_loss can be represented by the probability that the positive label of "tian" is "qi", and specifically can be expressed as:

[0136]

[0137] Among them, taking x([qi]|tian) as an example, it represents the probability value that the next position after "tian" output by the language model is "qi", and x(qi (steam)|tian) represents the probability value that the next position after "tian" output by the language model is "qi (steam)".

[0138] Step S440: Perform weighted summation on the first sub-loss function, the second sub-loss function, and the third sub-loss function to obtain the loss function of the language model to be trained.

[0139] After obtaining the first sub-loss function, the second sub-loss function, and the third sub-loss function, weighted summation can be performed on these three sub-loss functions to obtain the loss function of the language model to be trained. Among them, the weighting coefficients corresponding to these three sub-loss functions can be set according to specific situations, and the embodiments of the present disclosure do not make specific limitations on this.

[0140] For example, in practical applications, the loss function of the model to be trained can be the total loss function, denoted as total_loss, total_loss = lm_loss + del_loss*scale1 + sub_loss*scale2

[0141] Among them, scale1 and scale2 are weight coefficients. The main function of the weight coefficients is to ensure that the loss function values ​​of the three sub-loss functions are at the same level.

[0142] It should be noted that if in the embodiment, when obtaining training negative samples, both the method of deleting the search word and the method of replacing the search word are adopted, then the loss function of the language model to be trained is the weighted sum of the three sub-loss functions mentioned above. If when obtaining training negative samples, only the method of deleting the search word is adopted, then the loss function of the language model to be trained is the weighted sum of the first sub-loss function and the second sub-loss function. If when obtaining training negative samples, only the method of replacing the search word is adopted, then the loss function of the language model to be trained is the weighted sum of the first sub-loss function and the third sub-loss function.

[0143] It can be seen that through the technical solution provided by this embodiment, when constructing the loss function of the language model to be trained, the loss value corresponding to the positive label in the training positive sample and the loss value caused to the positive label by the negative label constructed by deleting the search word or replacing the search word in the training negative sample are taken into account at the same time. Therefore, the constructed loss function is more accurate, which enables the target language model to more accurately predict the semantic completeness of the search information to be identified.

[0144] In summary, the embodiments of the present disclosure can achieve comparative learning through data enhancement and loss function transformation, so that the target language model can more accurately predict the semantic completeness of the search information to be identified, that is, it can more accurately identify search information with incomplete syntax and typos. In order to test whether the prediction results of the target language model are accurate, the language model training method provided in the embodiments of the present disclosure is as follows: Figure 5 As shown, the following steps may also be included:

[0145] S510, obtaining a test positive sample and a test negative sample.

[0146] The test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search word in the information to be searched in the test positive sample.

[0147] Specifically, in order to verify whether the target language model can accurately predict the semantic completeness of the search information to be identified, the target language model can be tested by a test sample, wherein the test sample includes a test positive sample and a test negative sample, the test positive sample includes semantically complete search information, that is, the search information has no missing words or wrong words. The test negative sample includes semantically incomplete search information, that is, there is a phenomenon of missing words or wrong words in the search information.

[0148] For example, the test positive sample can be: Chen Qianqian in the rumor, and the corresponding test negative sample can be: Chen Qianqian in the rumor. The test positive sample can be: Hanging from the beam and piercing the thigh, and the corresponding test negative sample can be: Hanging from the beam and piercing the thigh.

[0149] S520: Input the test positive sample and the test negative sample into the target language model respectively to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample.

[0150] The first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample.

[0151] After obtaining the test positive sample and the test negative sample, the test positive sample and the test negative sample are respectively input into the target language model, and the target language model outputs a first prediction score and a second prediction score respectively. The first prediction score and the second prediction score are used to represent the semantic completeness of the test positive sample and the test negative sample respectively.

[0152] It can be understood that the higher the test score output by the target language model, the higher the semantic integrity of the test sample. The lower the test score output by the target language model, the lower the semantic integrity of the test sample.

[0153] S530: When the first prediction score is greater than the second prediction score, determine that the target language model prediction is accurate.

[0154] Specifically, after obtaining the first prediction score and the second prediction score, the first prediction score and the second prediction score are compared. If the first prediction score is greater than the second prediction score, it means that the prediction result of the target language model is: the semantic integrity of the test positive sample is higher than the semantic integrity of the test negative sample, indicating that the target language model predicts accurately. On the contrary, if the first prediction score is less than the second prediction score, it means that the prediction result of the target language model is: the semantic integrity of the test positive sample is lower than the semantic integrity of the test negative sample, indicating that the target language model predicts incorrectly.

[0155] It can be seen that through the technical solution provided by this embodiment, by obtaining semantically complete test positive samples and semantically incomplete test negative samples to test the target language model, it is possible to effectively verify whether the test results of the target language model are accurate.

[0156] exist Figure 5 On the basis of the illustrated embodiment, in order to obtain the prediction accuracy of the target language model, the language training model may further include the following two steps:

[0157] Step a, obtaining the target language model's accurate prediction times and total prediction times for the test positive samples and the test negative samples.

[0158] Specifically, during the test of the target language model, each time a pair of test positive samples and test negative samples is input, a pair of first prediction scores and second prediction scores are correspondingly output. If the first prediction score is greater than the second prediction score, it means that the prediction is accurate, otherwise, the prediction is wrong. In this way, the number of accurate predictions and the total number of predictions can be obtained.

[0159] Step b: determining the prediction accuracy of the target language model based on the number of accurate predictions and the total number of predictions.

[0160] After obtaining the number of accurate predictions and the total number of predictions, the number of accurate predictions can be divided by the total number of predictions to obtain the prediction accuracy of the target language model. A high prediction accuracy indicates that the target language model can better predict the semantic completeness of the information to be searched. Otherwise, the target language model needs to be further trained to improve its prediction accuracy.

[0161] It can be seen that through the technical solution provided by this embodiment, the prediction accuracy of the target language model can be accurately determined. If the prediction accuracy of the target language model is high, the target language model can be used to better predict the semantic completeness of the search information to be identified; otherwise, the target language model is further trained to improve its prediction accuracy so as to better predict the semantic completeness of the information to be searched.

[0162] Based on the above embodiment, as a specific application of the above trained preset model, the embodiment of the present disclosure also provides a prediction method, such as Figure 6 As shown, the following steps may be specifically included:

[0163] S610, obtaining search information to be identified.

[0164] S620, input the search information to be identified into the target language model to obtain a target prediction score corresponding to the search information to be identified.

[0165] The target prediction score is used to characterize the semantic completeness of the search information to be identified.

[0166] Specifically, after the target language model is obtained through training in the above embodiment, the target language model can be used to predict the semantic completeness of the search information to be identified. The search information to be identified can be any search information. After the search information to be identified is input into the target language model, the target language model can accurately output the semantic completeness of the search information to be identified.

[0167] The technical solution provided by the disclosed embodiment is that when training the target language model, the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further predict the semantic completeness of the search information to be identified with higher accuracy.

[0168] According to a third aspect of the embodiments of the present disclosure, a language model training device is provided. Figure 7 As shown, including:

[0169] The training sample acquisition module 710 is configured to execute acquisition of training positive samples and training negative samples; the training positive samples include semantically complete preset search information, and the training positive samples are annotated with positive labels; the training negative samples are obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative samples are annotated with negative labels;

[0170] The language model training module 720 is configured to input the training positive samples and the training negative samples into the language model to be trained, so as to train the language model to be trained;

[0171] The language model determination module 730 is configured to determine the trained language model as the target language model when the loss function value obtained based on the output result of the trained language model is less than a preset threshold; the target language model is used to predict the semantic completeness of the search information to be identified.

[0172] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0173] Optionally, the training sample acquisition module is specifically configured to execute:

[0174] Obtaining the number of search terms in the preset search information;

[0175] At least one search term is deleted from the preset search information to obtain the deleted search information, and the deleted search information is determined as a training negative sample; the number of search terms deleted from the preset search information is less than the total number of search terms in the preset search information; the first search term after the deleted search term is marked with a negative label.

[0176] Optionally, the training sample acquisition module is specifically configured to execute:

[0177] Acquire a target search word in the preset search information; the target search word has the same pronunciation or a similar character shape as a target misspelled word in a pre-established misspelled word table;

[0178] The target search word in the preset search information is replaced with the target misidentified word to obtain the search information after the search word is replaced, and the search information after the search word is replaced is determined as a training negative sample; the target misidentified word is marked with a negative label.

[0179] Optionally, the device further comprises:

[0180] A first construction module is configured to execute construction of a first sub-loss function; the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive sample;

[0181] A second construction module is configured to execute construction of a second sub-loss function; the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample; the target negative label is a negative label obtained after deleting the at least one search term, and the target positive label is the deleted search term;

[0182] A third construction module is configured to execute construction of a third sub-loss function; the third sub-loss function is used to determine the loss value of the target search term caused by the target typo in the training negative sample;

[0183] The loss function determination module is configured to perform weighted summation of the first sub-loss function, the second sub-loss function, and the third sub-loss function to obtain the loss function of the language model to be trained.

[0184] Optionally, the device further comprises:

[0185] A test sample acquisition module is configured to acquire a test positive sample and a test negative sample, wherein the test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search word in the information to be searched in the test positive sample;

[0186] A prediction module is configured to execute inputting the test positive sample and the test negative sample into the target language model respectively, to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample; the first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample;

[0187] The prediction result determination module is configured to determine whether the target language model is accurate in prediction when the first prediction score is greater than the second prediction score.

[0188] Optionally, the device further comprises:

[0189] A prediction times acquisition module is configured to execute to acquire the accurate prediction times and the total prediction times of the target language model for the test positive sample and the test negative sample;

[0190] The prediction accuracy determination module is configured to determine the prediction accuracy of the target language model based on the number of accurate predictions and the total number of predictions.

[0191] According to a fourth aspect of the embodiments of the present disclosure, a prediction device is provided. Figure 8 As shown, including:

[0192] The search information acquisition module 810 is configured to acquire the search information to be identified;

[0193] The prediction score determination module 820 is configured to execute inputting the search information to be identified into the target language model described in the third aspect to obtain a target prediction score corresponding to the search information to be identified; wherein the target prediction score is used to characterize the semantic completeness of the search information to be identified.

[0194] The technical solution provided by the disclosed embodiment is that when training the target language model, the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further predict the semantic completeness of the search information to be identified with higher accuracy.

[0195] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0196] processor;

[0197] a memory for storing processor-executable instructions;

[0198] The processor is configured to execute the method described in any one of the first aspect or the second aspect of the claim.

[0199] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0200] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, which, when executed on a computer, enables the computer to execute the steps of the method described in the first aspect or the second aspect.

[0201] Fig. 9 1 is a block diagram of a model training device 900 according to an exemplary embodiment. For example, the device 900 is an electronic device, which may be a mobile phone, a computer, a digital broadcast terminal, a message transceiver, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0202] Reference Fig. 9 , the device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .

[0203] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0204] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0205] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.

[0206] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0207] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.

[0208] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0209] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0210] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0211] In an exemplary embodiment, the apparatus 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above-mentioned model training method or prediction method.

[0212] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0213] Fig.101 is a block diagram of an apparatus 1000 for training a language model or prediction according to an exemplary embodiment. For example, the apparatus 1000 may be provided as a server. Fig.10 , the apparatus 1000 includes a processing component 1022, which further includes one or more processors, and a memory resource represented by a memory 1032 for storing instructions, such as an application, that can be executed by the processing component 1022. The application stored in the memory 1032 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1022 is configured to execute the instructions to perform the above method.

[0214] The device 1000 may also include a power supply component 1026 configured to perform power management of the device 1000, a wired or wireless network interface 1050 configured to connect the device 1000 to a network, and an input / output (I / O) interface 1058. The device 1000 may operate based on an operating system stored in the memory 1032, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or the like.

[0215] According to the sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a method, which includes the steps of the method described in the first aspect or the second aspect.

[0216] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0217] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, which, when executed on a computer, enables the computer to execute the steps of the method described in the first aspect or the second aspect.

[0218] The technical solution provided by the embodiments of the present disclosure is that the training negative samples are obtained by deleting and / or replacing at least one search word in the preset search information, that is, the negative labels in the training negative samples are obtained by deleting or replacing the search words, which makes the negative labels more accurate and discriminative, so that the target language model can better distinguish between positive and negative labels, and further can more accurately predict the semantic completeness of the search information to be identified.

[0219] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, DSL (Digital Subscriber Line, digital subscriber line)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD (Digital Versatile Disc)), or a semiconductor medium (eg, an SSD (Solid State Disk)), etc.

[0220] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0221] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0222] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A language model training method, It is characterized in that include: Obtain training positive samples and training negative samples; The training positive samples include semantically complete preset search information, and the training positive samples are annotated with positive labels; The training negative sample is obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative sample is marked with a negative label; Inputting the training positive samples and the training negative samples into a language model to be trained, and training the language model to be trained; When a loss function value obtained based on an output result of the trained language model is less than a preset threshold, determining the trained language model as a target language model; The target language model is used to predict the semantic completeness of the search information to be identified; The obtaining of training negative samples comprises: Obtaining the number of search terms in the preset search information; Deleting at least one search word from the preset search information to obtain the deleted search information, and determining the deleted search information as a training negative sample; the number of search words deleted from the preset search information is less than the total number of search words in the preset search information; the first search word after the deleted search word is marked with a negative label; And / or, the obtaining of training negative samples includes: Acquire a target search word in the preset search information; the target search word has the same pronunciation or a similar character shape as a target misspelled word in a pre-established misspelled word table; The target search word in the preset search information is replaced with the target misidentified word to obtain the search information after the search word is replaced, and the search information after the search word is replaced is determined as a training negative sample; the target misidentified word is marked with a negative label.

2. The method according to claim 1, It is characterized in that The method further comprises: Constructing a first sub-loss function; the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive sample; Constructing a second sub-loss function; the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample; the target negative label is a negative label obtained after deleting the at least one search term, and the target positive label is the deleted search term; Constructing a third sub-loss function; the third sub-loss function is used to determine the loss value of the target search term caused by the target typo in the training negative sample; The first sub-loss function, the second sub-loss function, and the third sub-loss function are weightedly summed to obtain the loss function of the language model to be trained.

3. The method according to claim 1, It is characterized in that The method further comprises: Acquire a test positive sample and a test negative sample, wherein the test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search term in the information to be searched in the test positive sample; The test positive sample and the test negative sample are respectively input into the target language model to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample; the first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample; When the first prediction score is greater than the second prediction score, it is determined that the target language model is accurately predicted.

4. The method according to claim 3, It is characterized in that The method further comprises: Obtaining the number of accurate predictions and the total number of predictions of the target language model for the test positive sample and the test negative sample; Based on the number of accurate predictions and the total number of predictions, a prediction accuracy rate of the target language model is determined.

5. A prediction method, It is characterized in that include: Obtaining search information to be identified; Input the search information to be identified into the target language model described in any one of items 1 to 4 to obtain a target prediction score corresponding to the search information to be identified; wherein the target prediction score is used to characterize the semantic completeness of the search information to be identified.

6. A language model training device, It is characterized in that include: A training sample acquisition module is configured to acquire training positive samples and training negative samples; The training positive sample includes semantically complete preset search information, and the training positive sample is annotated with a positive label; the training negative sample is obtained by deleting and / or replacing at least one search term in the preset search information, and the training negative sample is annotated with a negative label; A language model training module is configured to input the training positive samples and the training negative samples into a language model to be trained, so as to train the language model to be trained; A language model determination module is configured to determine the trained language model as a target language model when a loss function value obtained based on an output result of the trained language model is less than a preset threshold; the target language model is used to predict the semantic completeness of the search information to be identified; The training sample acquisition module is specifically configured to execute: Obtaining the number of search terms in the preset search information; Deleting at least one search word from the preset search information to obtain deleted search information, and determining the deleted search information as a training negative sample; The number of search terms deleted from the preset search information is less than the total number of search terms in the preset search information; the first search term after the deleted search term is marked with a negative label; And / or, the training sample acquisition module is specifically configured to execute: Acquire a target search word in the preset search information; the target search word has the same pronunciation or a similar character shape as a target misspelled word in a pre-established misspelled word table; The target search word in the preset search information is replaced with the target misidentified word to obtain the search information after the search word is replaced, and the search information after the search word is replaced is determined as a training negative sample; the target misidentified word is marked with a negative label.

7. The device according to claim 6, It is characterized in that The device also includes: A first construction module is configured to execute construction of a first sub-loss function; the first sub-loss function is used to determine the loss value corresponding to the positive label in the training positive sample; A second construction module is configured to execute construction of a second sub-loss function; the second sub-loss function is used to determine the loss value of the target positive label caused by the target negative label in the training negative sample; the target negative label is a negative label obtained after deleting the at least one search term, and the target positive label is the deleted search term; A third construction module is configured to execute construction of a third sub-loss function; the third sub-loss function is used to determine the loss value of the target search term caused by the target typo in the training negative sample; The loss function determination module is configured to perform weighted summation of the first sub-loss function, the second sub-loss function, and the third sub-loss function to obtain the loss function of the language model to be trained.

8. The device according to claim 6, It is characterized in that The device also includes: A test sample acquisition module is configured to acquire a test positive sample and a test negative sample, wherein the test positive sample includes semantically complete information to be searched; and the test negative sample is obtained by deleting and / or replacing at least one search word in the information to be searched in the test positive sample; A prediction module is configured to execute inputting the test positive sample and the test negative sample into the target language model respectively, to obtain a first prediction score corresponding to the test positive sample and a second prediction score corresponding to the test negative sample; the first prediction score is used to characterize the semantic completeness of the test positive sample, and the second prediction score is used to characterize the semantic completeness of the test negative sample; The prediction result determination module is configured to determine whether the target language model is accurate in prediction when the first prediction score is greater than the second prediction score.

9. The device according to claim 8, It is characterized in that The device also includes: A prediction times acquisition module is configured to execute to acquire the accurate prediction times and the total prediction times of the target language model for the test positive sample and the test negative sample; The prediction accuracy determination module is configured to determine the prediction accuracy of the target language model based on the number of accurate predictions and the total number of predictions.

10. A prediction device, It is characterized in that include: A search information acquisition module, configured to acquire the search information to be identified; The prediction score determination module is configured to execute inputting the search information to be identified into the target language model described in any one of items 6 to 9 to obtain a target prediction score corresponding to the search information to be identified; wherein the target prediction score is used to characterize the semantic completeness of the search information to be identified.

11. An electronic device, It is characterized in that include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 5.

12. A computer-readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a method comprising the steps of any one of the methods of claims 1-5.

13. A computer program product, It is characterized in that When the method is executed on a computer, the computer is enabled to execute the steps of any one of the methods of claims 1 to 5.