Language model training method and device, equipment and medium

By training a language model using global and local sample sets, and using object features to distinguish global sample texts of different objects, the problem of low recommendation accuracy in natural language applications is solved, while protecting object data security.

CN122064237APending Publication Date: 2026-05-19TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-11-19
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In natural language processing applications, the lack of personalized information leads to lower recommendation accuracy, while the security of object data needs to be protected.

Method used

By acquiring global and local sample sets of multiple objects, a language model is trained based on a preset probability distribution. The global sample text of different objects is distinguished by object features, and object features are introduced as input data into the initial language model to avoid the leakage of personalized information.

Benefits of technology

While protecting the security of object data, it improves the recommendation accuracy of natural language applications and achieves personalized recommendations without leaking personalized information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122064237A_ABST
    Figure CN122064237A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a language model training method and device, equipment and a medium, and is used for improving the recommendation accuracy of a natural language application for an output text on the basis of protecting the data security of an object. The method comprises the steps that a global sample set corresponding to a plurality of objects is obtained, each global sample comprises a global sample text historically input by the corresponding object, a corresponding global output text and object features, the object features are generated according to preset probability distribution set for the object, and the preset probability distribution is generated according to the global sample text, the corresponding global output text and the object features; the initial probability distribution is trained based on a local sample set of the object; and carrying out iterative training on the initial language model based on the global sample set, and each round of iteration comprises the following steps: inputting the selected global sample text and object features into the initial language model, and carrying out parameter adjustment on the initial language model based on the difference between the obtained global prediction text and the corresponding global output text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, and medium for training a language model. Background Technology

[0002] In recommendation scenarios, recommendation systems in some applications (such as shopping apps and browsers) typically need to recommend content that an object might be interested in based on the object's personalized information (including object identifiers) and the object's behavior (such as the products and articles browsed).

[0003] However, in some natural language applications with strict data security requirements (such as input method applications), recommendation systems avoid collecting and storing personalized information of objects (including object identifiers, etc.) to protect the data security of objects. As a result, the recommendation system is unable to output personalized content to different objects due to the lack of personalized information of objects, resulting in lower recommendation accuracy.

[0004] Therefore, how to improve the recommendation accuracy of natural language applications while protecting the data security of the target audience is a problem that needs to be solved. Summary of the Invention

[0005] This application provides a method, apparatus, device, and medium for training a language model, which improves the accuracy of natural language applications in recommending output text while protecting the data security of the object.

[0006] On the one hand, the language model training method provided in this application embodiment is applied to the server side, and the method includes:

[0007] A global sample set corresponding to multiple objects is obtained. Each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of the corresponding object feature points according to a preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training an initial probability distribution based on a local sample set. Each local sample includes: local sample text of the corresponding object's historical input and the corresponding local output text.

[0008] The initial language model is iteratively trained based on the global sample set, wherein each iteration includes:

[0009] The selected global sample text and object features are input into the initial language model to obtain the global predicted text. Based on the difference between the global predicted text and the corresponding global output text, the parameters of the initial language model are adjusted.

[0010] On the one hand, the probability distribution training method provided in this application embodiment is applied to a terminal device, the method comprising:

[0011] Obtain a local sample set. Each local sample includes: local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the corresponding sample feature point value range according to the initial probability distribution.

[0012] The initial probability distribution is iteratively trained based on the local sample set to obtain a preset probability distribution; wherein each iteration includes: inputting the selected local sample text and sample features into the acquired server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text.

[0013] A subset of global samples is sent to the server. Each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and the object features generated according to the preset probability distribution.

[0014] On one hand, an embodiment of this application provides a language model training device, which is set on a server, and the device includes:

[0015] The first acquisition module is used to acquire a global sample set corresponding to multiple objects. Each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of corresponding object feature points according to a preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training an initial probability distribution based on a local sample set. Each local sample includes: local sample text of the corresponding object's historical input and the corresponding local output text.

[0016] The first training module is used to iteratively train the initial language model based on the global sample set, wherein each iteration includes:

[0017] The selected global sample text and object features are input into the initial language model to obtain the global predicted text. Based on the difference between the global predicted text and the corresponding global output text, the parameters of the initial language model are adjusted.

[0018] In some embodiments, the preset probability distribution set for each object is obtained by the terminal device corresponding to each object in the following way:

[0019] The initial probability distribution is iteratively trained based on the local sample set, with each iteration including:

[0020] Select a local sample text, and according to the initial probability distribution, select multiple sample feature points from the corresponding sample feature point value range to obtain sample features;

[0021] The local sample text and the sample features are input into the initial language model to obtain local predicted text, and the parameters of the initial probability distribution are adjusted based on the difference between the local predicted text and the corresponding local output text.

[0022] In some embodiments, when selecting multiple sample feature points from the corresponding sample feature point value range according to the initial probability distribution to obtain sample features, the terminal device corresponding to each object is specifically used for:

[0023] A reference feature containing multiple reference feature points is generated according to a reference probability distribution. The reference feature is then input into a pre-trained feature encoding model to obtain the sample feature. The feature encoding model is used to: convert any feature that satisfies the reference probability distribution into another feature that satisfies the initial probability distribution.

[0024] The adjustment of the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text includes:

[0025] Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

[0026] In some embodiments, the terminal devices corresponding to the plurality of objects each have the same configuration training data set for their respective initial probability distributions, and the configuration training data includes one or more of the following:

[0027] The initial parameters of the initial probability distribution;

[0028] Learning rate size;

[0029] The critical value for gradient clipping;

[0030] The number of update steps for the initial probability distribution.

[0031] In some embodiments, the probability distribution function corresponding to the preset probability distribution set for each object resides in a linearly correlated space.

[0032] The probability distribution function represents the preset selection probability of each value interval within the range of the object feature points, and the linear correlation space represents the linear relationship between the probability distribution function corresponding to the preset probability distribution and the probability distribution functions corresponding to other probability distributions.

[0033] In some embodiments, the first acquisition module is specifically used for:

[0034] Each object receives a global sample subset sent by its respective terminal device. Each global sample subset includes multiple global samples corresponding to one object.

[0035] The global sample set is obtained based on multiple received global sample subsets.

[0036] In some embodiments, the apparatus further includes:

[0037] The prediction module is used to acquire real-time input text and sampling features sent by the target terminal device. The sampling features include multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution trained by the target terminal device. The real-time input text and the sampling features are then input into the trained target language model to predict the corresponding recommended text.

[0038] The push module is used to send the recommended text to the terminal device corresponding to the target object.

[0039] On one hand, an embodiment of this application provides a probability distribution training device, which is installed in a terminal device. The device includes:

[0040] The second acquisition module is used to acquire a local sample set. Each local sample includes: local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the corresponding sample feature point value range according to the initial probability distribution.

[0041] The second training module is used to iteratively train the initial probability distribution based on the local sample set to obtain a preset probability distribution. Each iteration includes: inputting the selected local sample text and sample features into the acquired server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text.

[0042] The sending module is used to send a subset of global samples to the server. Each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and the object features generated according to the preset probability distribution.

[0043] In some embodiments, when selecting multiple sample feature points from the corresponding sample feature point value range according to the initial probability distribution to obtain sample features, the second training module is specifically used for:

[0044] According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. The reference features are then converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model.

[0045] When adjusting the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text, the second training module is specifically used for:

[0046] Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

[0047] In some embodiments, the function space of the probability distribution function corresponding to the initial probability distribution is a linear correlation space;

[0048] The probability distribution function represents the initial selection probability of each value interval within the range of sample feature points of the initial probability distribution, and the linear correlation space represents the probability distribution function corresponding to the initial probability distribution, which has a linear relationship with other probability distribution functions.

[0049] In some embodiments, the apparatus further includes:

[0050] The sampling module is used to acquire the real-time input text and sampling features of the target object. The sampling features include multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution obtained through training.

[0051] The upload module is used to send the real-time input text and the sampled features to the server, so that the server can predict the corresponding recommended text based on the real-time input text and the sampled features using the trained target language model;

[0052] A receiving module is used to receive the recommended text returned by the server.

[0053] On one hand, an electronic device provided in this application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the above-mentioned language model training methods and probability distribution training methods.

[0054] On one hand, embodiments of this application provide a computer-readable storage medium including a computer program. When the computer program is run on an electronic device, the computer program is used to cause the electronic device to perform the steps of any of the above-described language model training methods and probability distribution training methods.

[0055] On one hand, embodiments of this application provide a computer program product, the computer program product including a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the above-described language model training methods and probability distribution training methods.

[0056] The solution proposed in this application has at least the following beneficial effects:

[0057] This application provides a language model training method, apparatus, device, and medium. An initial language model is trained based on a global sample set corresponding to multiple objects. Each global sample includes: global sample text of the corresponding object's historical input, corresponding global output text, and object features. These object features satisfy a preset probability distribution corresponding to the corresponding object. Since the preset probability distribution is obtained by training the initial probability distribution based on a local sample set corresponding to the corresponding object, each local sample includes: local sample text of the corresponding object's historical input, and corresponding local output text. Therefore, the preset probability distributions set for multiple objects are different. Thus, object features satisfying different preset probability distributions can represent different objects.

[0058] By introducing object features into each global sample and using them as input data for the initial language model along with the global sample text, the initial language model can distinguish different global sample texts through these object features. This allows it to learn to predict suitable recommended text for each object based on the real-time input text. Furthermore, since these object features do not contain personalized information such as object identifiers, unauthorized access to object data can be prevented, thus protecting object data security. Therefore, this embodiment can improve the accuracy of recommended text output by natural language applications while protecting object data security.

[0059] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0060] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0061] Figure 1This is a schematic diagram illustrating one application scenario in an embodiment of this application;

[0062] Figure 2 This is a flowchart illustrating a language model training method according to an embodiment of this application;

[0063] Figure 3 This is a schematic diagram illustrating the collection process of a global sample set in an embodiment of this application;

[0064] Figure 4 This is a schematic diagram illustrating the training process of an initial language model in an embodiment of this application;

[0065] Figure 5 This is a schematic diagram illustrating the training process of an initial probability distribution according to an embodiment of this application;

[0066] Figure 6 This is a schematic diagram illustrating the training process of another initial probability distribution according to an embodiment of this application;

[0067] Figure 7 This is a schematic diagram illustrating the application process of a target language model according to an embodiment of this application;

[0068] Figure 8 This is a schematic diagram of the interface of an input method application in an embodiment of this application;

[0069] Figure 9 This is a schematic diagram of the interface of a smart assistant according to an embodiment of this application;

[0070] Figure 10 This is a schematic diagram of the interface of a search application in an embodiment of this application;

[0071] Figure 11 This is a flowchart illustrating a probability distribution training method according to an embodiment of this application;

[0072] Figure 12 This is a schematic diagram of the composition structure of a language model training device according to an embodiment of this application;

[0073] Figure 13 This is a schematic diagram of the composition structure of a probability distribution training device according to an embodiment of this application;

[0074] Figure 14 This is a schematic diagram of the composition structure of an electronic device using an embodiment of this application;

[0075] Figure 15 This is a schematic diagram of the composition structure of another electronic device using an embodiment of this application. Detailed Implementation

[0076] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.

[0077] The following describes some of the concepts involved in the embodiments of this application.

[0078] Probability distribution is a fundamental concept in probability theory and statistics, describing the probability of all possible values ​​a random variable can take. Probability distributions can be divided into two main categories: discrete probability distributions and continuous probability distributions. Discrete probability distributions are applicable to discrete random variables, meaning the variable can only take a finite or countably infinite number of values. They are described by a probability mass function (PMF), which gives the probability of the random variable taking each possible value. Continuous probability distributions are applicable to continuous random variables, meaning the variable can take any real value within a certain interval. They are described by a probability density function (PDF), which does not directly give the probability but rather the probability density around a certain point. Optionally, the preset probability distribution in this embodiment can be a continuous probability distribution; in some cases, the preset probability distribution can also be a discrete probability distribution, and this is not limited.

[0079] Language models are used to understand and generate natural language. They can be trained on large-scale text datasets and perform various natural language processing tasks, such as text generation, question answering, and translation. Typically, language models employ Transformer-based neural network architectures, including but not limited to the GPT (Generative Pre-trained Transformer) series (such as GPT1, GPT2, etc.), BERT (Bidirectional Encoder Representations from Transformers) models, T5 (Text-to-Text Transfer Transformer) models, and BART (Bidirectional and Auto-Regressive Transformers) models.

[0080] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.

[0081] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0082] The design concept of the embodiments of this application will be introduced below.

[0083] In related technologies, recommendation systems in some applications (such as shopping apps and browsers) typically need to recommend potentially interesting content to users based on their personalized information (including object identifiers) and their behavior (such as browsed products and articles). In this case, the server can obtain each object's local data through its object identifier. However, in natural language applications with strict data security requirements (such as input method applications), local object data is highly sensitive. Therefore, recommendation systems avoid collecting and storing personalized information such as object identifiers, which are used to distinguish different objects and include, but are not limited to, object IDs and device IDs, thereby protecting object data security. Thus, due to the lack of personalized information, recommendation systems cannot output personalized content to different objects, resulting in lower recommendation accuracy.

[0084] In view of this, in order to improve the recommendation accuracy of natural language applications while protecting the data security of the objects, embodiments of this application provide a language model training method, apparatus, device, and medium. Different objects are represented by object features that satisfy different preset probability distributions. These object features are introduced into each global sample of the initial language model and used as input data along with the global sample text. This allows the initial language model to distinguish different global sample texts through object features, thereby learning to predict suitable recommendation text for each object based on the real-time input text. Furthermore, since the aforementioned object features do not contain personalized information such as object identifiers, the illegal acquisition of object data can be prevented, thus protecting the object's data security. Therefore, embodiments of this application can improve the accuracy of recommendation text output by natural language applications while protecting the data security of the objects.

[0085] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0086] like Figure 1 The diagram shown illustrates an application scenario of an embodiment of this application. This application scenario diagram includes multiple terminal devices 110 and a server 120. Each terminal device 110 and the server 120 can communicate via a communication network.

[0087] In one alternative implementation, the communication network can be a wired network or a wireless network.

[0088] In this embodiment, the terminal device 110 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, and in-vehicle terminals. The terminal device may have natural language applications installed, such as input method applications, smart assistants, dialogue systems, and search applications. The server 120 may be a backend server corresponding to the application, or a server specifically used for language model training; this application does not impose specific limitations. The server 120 may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0089] The language model training method of this application embodiment can be executed by server 120, and the probability distribution training method of this application embodiment can be executed by terminal device 110.

[0090] In some embodiments, each terminal device 110 has an input method application installed, which can obtain the input texts historically entered by the corresponding object in the input method application, and the output text corresponding to each input text. For example, each input text is Pinyin, and the corresponding output text is the word corresponding to the Pinyin. The terminal device 110 uses each input text as a local sample text and the corresponding output text as a local output text to obtain each local sample. The terminal device 110 obtains an initial language model from the server, and trains an initial probability distribution based on the local sample set and the initial language model to obtain a preset probability distribution. The server 120 can obtain a global sample set corresponding to multiple objects. Each global sample includes the global sample texts historically entered by the corresponding object in the input method application, the corresponding global output text, and object features generated according to the preset probability distribution. The server trains the initial language model based on the global sample set.

[0091] In other embodiments, each terminal device 110 is equipped with a smart assistant (or dialogue system). In some scenarios, when a user inputs a question text into the smart assistant, the smart assistant can output multiple answer texts and instruct the user to select one from them. Specifically, the user can directly input the question text or input it via voice. The smart assistant can directly output multiple answer texts or output multiple answer texts via voice. The terminal device 110 can obtain the question texts historically input by the user in the smart assistant, and the answer text corresponding to each question text. The answer text can be one or more answer texts selected by the user from the multiple answer texts output by the smart assistant. The terminal device 110 uses each question text as a local sample text and the answer text or multiple answer texts selected by the user as local output texts to obtain each local sample. The terminal device 110 obtains an initial language model from the server, and trains an initial probability distribution based on the local sample set and the initial language model to obtain a preset probability distribution. Server 120 can obtain global sample sets corresponding to multiple objects. Each global sample includes the global sample text of the corresponding object in the smart assistant in the past, the corresponding global output text, and the object features generated according to the preset probability distribution. The initial language model is trained based on the global sample set.

[0092] In some embodiments, each terminal device 110 is equipped with a search application. When a user inputs search text into the search application, the application can output multiple search result texts, allowing the user to select one or more. For example, the user can click and browse a search result text to select that text. Specifically, the user can directly input the search text or input it via voice. The terminal device 110 can obtain the historical search texts input by the user in the search application and the corresponding search result texts for each text. These search result texts can be one or more selected search result texts from the multiple search result texts output by the search application. The terminal device 110 uses each search text as a local sample text and selects one or more search result texts as local output texts to obtain each local sample. The terminal device 110 obtains an initial language model from the server, trains an initial probability distribution based on the local sample set and the initial language model, and obtains a preset probability distribution. Server 120 can obtain global sample sets corresponding to multiple objects. Each global sample includes the global sample text of the corresponding object in the smart assistant in the past, the corresponding global output text, and the object features generated according to the preset probability distribution. The initial language model is trained based on the global sample set.

[0093] It should be noted that natural language applications are not limited to the aforementioned input method applications, intelligent assistants, dialogue systems, search applications, etc. They can also be any application that can perform text input and text output. Furthermore, the input text can be text directly entered by the user or text input via voice, and the output text can be text directly output by the application or text corresponding to the output voice. Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.

[0094] The following describes the language model training method provided by the exemplary embodiments of this application in conjunction with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.

[0095] See Figure 2 The diagram shown is a flowchart of a language model training method provided in this application embodiment, with the server as the execution entity. The specific implementation process of this method includes the following S21-S22:

[0096] S21. Obtain a global sample set corresponding to multiple objects. Each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of the corresponding object feature points according to the preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training the initial probability distribution based on the local sample set. Each local sample includes: the local sample text of the corresponding object's historical input and the corresponding local output text.

[0097] Each object's terminal device can collect the input texts that the object has historically entered in the target application, as well as the output texts returned by the server corresponding to the target application for each input text. The target application can be a natural language application as mentioned in the above embodiments. Then, the terminal device uses each input text as a global sample text and the corresponding output text as a global output text. For each global sample text, it generates object features according to a preset probability distribution. Each global sample text, the corresponding global output text, and the object features are uploaded to the server as a global sample.

[0098] Specifically, when the terminal device generates object features according to a preset probability distribution, it can select multiple object feature points from each value interval within the range of object feature point values ​​corresponding to the preset probability distribution, forming the aforementioned object features. The number of multiple object feature points can be set as needed, for example, 768, and is not limited thereto. It should be noted that when the preset probability distribution is a continuous probability distribution, each feature point value interval includes multiple continuous values; when the preset probability distribution is a discrete probability distribution, each feature point value interval includes one value.

[0099] In some embodiments, such as Figure 3 As shown, the server can receive global sample subsets sent by the respective terminal devices of multiple objects. Each global sample subset includes multiple global samples corresponding to one object. Based on the received global sample subsets, the global sample set is obtained. In this way, the server cannot distinguish the individual global samples corresponding to each object, ensuring the anonymity of the object data and thus protecting the security of the object data.

[0100] Optionally, the preset probability distribution can be a continuous probability distribution. A continuous probability distribution is described by a probability density function (PDF), which can be used to calculate the preset selection probability of each feature point within the range of values ​​for the object's feature points. Several types of continuous probability distributions are introduced below.

[0101] The beta distribution is used to describe the probability distribution within the value range [0, 1] of the object feature points, and the PDF is expressed as the following formula (1):

[0102]

[0103] where f(x) represents the PDF, 0 ≤ x ≤ 1, α and β are the parameters of the beta distribution, representing different shape parameters respectively, and B(α, β) represents the beta function, which is used to ensure that the integral of the PDF over [0, 1] is 1.

[0104] The normal distribution, also known as the Gaussian distribution, is used to describe the probability distribution within the value range (-∞, +∞) of the object feature points, and the PDF is expressed as the following formula (2):

[0105]

[0106] where f(x) represents the PDF, 0 ≤ x ≤ 1, μ and σ are the parameters of the normal distribution, representing the mean and standard deviation respectively.

[0107] Pearson Type VI distribution, also known as Beta Prime distribution or inverse gamma distribution, is used to describe the probability distribution within the value range (0, +∞) of the object feature points, and the PDF is expressed as the following formula (3):

[0108]

[0109] where f(x) represents the PDF, 0 < x < +∞, α, β, γ, δ are the parameters of the beta distribution. Specifically, α and β represent different shape parameters respectively, and γ, δ represent different scale parameters, Γ represents the gamma function, which is used to ensure that the integral of the PDF over (0, +∞) is 1.

[0110] In the embodiments of the present application, the preset probability distribution can adopt one of the above several continuous probability distributions, or other continuous probability distributions, which are not limited herein.

[0111] In addition, the preset probability distribution can also adopt discrete probability distributions, such as Poisson distribution, binomial distribution, geometric distribution, etc., which are not limited herein.

[0112] The preset probability distribution set for each object is obtained by training the initial probability distribution based on the local sample set of the corresponding object by the terminal device of each object. On the one hand, the probability distribution types of the initial probability distributions corresponding to different objects can be the same, but the probability distribution parameters are different; on the other hand, the probability distribution types of the initial probability distributions corresponding to different objects can also be different, which are not limited herein. The following embodiments of the present application will detail the training process of the initial probability distribution.

[0113] S22. Iteratively train the initial language model based on the global sample set. Each iteration includes: inputting the selected global sample text and object features into the initial language model to obtain the global predicted text, and adjusting the parameters of the initial language model based on the difference between the global predicted text and the corresponding global output text.

[0114] The global output text can include one or more output texts, and correspondingly, the global predicted text can also include one or more predicted texts. For example, the global sample text is the pinyin entered by the object in an input method application, and the corresponding global output text includes one or more words; the global sample text is the search text entered by the object in a search application, and the corresponding global output text includes one or more search result texts; the global sample text is the question text entered by the object in a smart assistant, and the corresponding global output text includes one or more answer texts.

[0115] like Figure 4 As shown, after obtaining the global sample set, the server can concatenate the selected global sample text and object features in each round of training iteration to obtain personalized global input data. This global input data is then input into the initial language model, which outputs the global predicted text corresponding to the global sample text. Then, a preset loss function is used to determine the global loss value based on the difference between the global predicted text and the corresponding global output text (i.e., sample labels). For example, the preset loss function includes, but is not limited to, the cross-entropy loss function. Finally, the parameters of the initial language model are adjusted based on the global loss value.

[0116] It should be noted that in each round of training iteration, the parameters of the initial language model can be adjusted based on the global loss value corresponding to a global sample, or the total global loss value can be obtained based on the global loss values ​​corresponding to multiple global samples. For example, the total global loss value can be obtained by averaging multiple global loss values, and the parameters of the initial language model can be adjusted based on the total global loss value.

[0117] Specifically, the global loss value (or total global loss value) can be backpropagated, that is, starting from the output layer of the initial language model, the gradient of the global loss value (or total global loss value) with respect to the parameters of each network layer is calculated backward. Then, gradient descent can be used to update the parameters of each network layer of the initial language model. For example, the parameters of each network layer can include weights, biases, and activation function parameters. Optionally, the parameters of the initial language model can be updated based on an optimizer, which includes, but is not limited to, Adam (Adaptive Moment Estimation), RMSprop (Root Mean Square propagation), and Adagrad (Adaptive gradient algorithm).

[0118] In this embodiment of the application, the iteration stopping condition for the initial language model includes at least one of the following conditions:

[0119] (1) The number of iterations reaches the set threshold.

[0120] (2) The global loss value is less than the set loss threshold.

[0121] In this embodiment, when the number of iterations does not exceed a preset threshold and the global loss value is not less than a preset loss threshold, the current initial language model is considered not to have met the iteration termination condition, and the model parameters need to be adjusted to continue training. After parameter adjustment, the next iteration training process begins. When the number of iterations has exceeded the preset threshold, or the global loss value is less than the preset loss threshold, the current initial language model is considered to have met the convergence condition, the model training ends, and the current initial language model is used as the target language model.

[0122] In this embodiment, different objects are represented by object features that satisfy different preset probability distributions. These object features are introduced into each global sample of the initial language model and used as input data for the initial language model along with the global sample text. This allows the initial language model to distinguish different global sample texts based on the object features, thereby learning to predict suitable recommended text for each object based on the real-time input text. Furthermore, since the aforementioned object features do not contain personalized information such as object identifiers, the illegal acquisition of object data can be prevented, thus protecting object data security. Therefore, this embodiment can improve the accuracy of recommended text output by natural language applications while protecting object data security.

[0123] The training process for the initial probability distribution of each object is described below.

[0124] In some embodiments, the preset probability distribution set for each object is obtained by the terminal device corresponding to each object through iterative training of the initial probability distribution based on a local sample set. Specifically, when collecting the local sample set, the terminal device for each object can obtain the historical input texts of the object in the target application, as well as the output text returned by the server corresponding to the target application for each input text; then, the terminal device uses each input text as a local sample text and the corresponding output text as a local output text.

[0125] It should be noted that the local sample texts collected by the terminal device of each object, and the global sample texts uploaded by the terminal device to the server, are all input texts that the corresponding object has historically entered in the target application. It is understood that there may be the same input texts between the local sample texts and the global sample texts, or there may be different input texts. This is not limited.

[0126] The training of the initial probability distribution for each object's corresponding terminal device in each iteration includes the following steps A1-A2:

[0127] A1. Select local sample text and corresponding sample features. The sample features include multiple sample feature points selected from the value range of the corresponding sample feature points according to the initial probability distribution.

[0128] For each selected local sample text, a sample feature is generated. The range of sample feature point values ​​in the initial probability distribution set for each object is the same as the range of object feature point values ​​in the preset probability distribution after training. However, because the parameters of the initial probability distribution and the preset probability distribution are different, the initial selection probability of each value interval within the range of sample feature point values ​​is different from the preset selection probability of each value interval within the range of object feature point values.

[0129] Specifically, when generating sample features, the terminal device selects multiple sample feature points from each value interval within the corresponding sample feature point value range according to the initial probability distribution and their respective initial selection probabilities, thereby obtaining sample features. The number of multiple sample feature points can be set as needed and can be consistent with the number of multiple object feature points in the above embodiment, for example, 768, without limitation.

[0130] A2. Input the local sample text and sample features into the initial language model to obtain the local predicted text, and adjust the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text.

[0131] Each object's terminal device can obtain the server's initial language model, which can be either actively sent to the terminal device by the server or actively obtained by the terminal device from the server.

[0132] like Figure 5 As shown, after each object's terminal device samples a sample feature based on the initial probability distribution, it can concatenate the selected local sample text with the sample feature to obtain personalized enhanced local input data. This local input data is then input into the initial language model, which outputs the local predicted text corresponding to the local sample text. Next, a preset loss function is used to determine the local loss value based on the difference between the local predicted text and the corresponding local output text (i.e., the sample label). For example, the preset loss function includes, but is not limited to, the cross-entropy loss function. Finally, the parameters of the initial probability distribution are adjusted based on the local loss value. For example, when the initial probability distribution is a beta distribution, the parameters include shape parameter α and shape parameter β; when the initial probability distribution is a normal distribution, the parameters include the mean μ and standard deviation σ.

[0133] It should be noted that in each round of training iteration, the parameters of the initial probability distribution can be adjusted based on the local loss value corresponding to a local sample, or the total local loss value can be obtained based on the multiple local loss values ​​after obtaining the local loss values ​​corresponding to multiple local samples. For example, the total local loss value can be obtained by averaging the multiple local loss values, and the parameters of the initial probability distribution can be adjusted based on the total local loss value.

[0134] Specifically, after obtaining the initial language model from the server, the terminal device of each object fixes the parameters of the initial language model and trains the initial probability distribution based on the local sample set to minimize the local loss value on the local sample set, as shown in the following equation (4):

[0135]

[0136] Among them, D n Denotes a local sample set, |D n | represents the number of local samples, E represents the expectation, U n Let u represent the initial probability distribution. n Indicates from U n Sample features from the sample, l(h([u n ;x]),y) represent local loss values, x represents local sample text, y represents local output text, h represents the initial language model, h([u n ;x]) represents local predicted text.

[0137] In this embodiment, the preset probability distribution set for each object is obtained by the terminal device corresponding to each object through iterative training of the initial probability distribution based on a local sample set and combined with the initial language model. This makes the preset probability distribution for each object optimal, and at the same time, makes the preset probability distributions for different objects different, so that the target language model can output personalized recommendation text that matches each object based on the features of each object that meet different preset probability distributions and the real-time input text of different objects.

[0138] On the one hand, the gradient of the parameters of the initial probability distribution can be directly estimated based on the local loss value (or the total local loss value). Specifically, stochastic gradient estimation methods can be used, such as the score function estimation method, to calculate the gradient. The training gradient can be expressed as the following equation (5):

[0139]

[0140] Where E represents the expectation, U n Let u represent the initial probability distribution. n Indicates from U n Sample features from the sample, l(h([u n ;x]),y) represent local loss values, x represents local sample text, y represents local output text, h represents the initial language model, h([u n ;x]) represents the locally predicted text,

[0141] On the other hand, considering that the sample features are directly randomly sampled from the initial probability distribution, there may be a relatively large range of variation. If the sample features change a lot, the local loss value (or the total local loss value) will also change a lot, which will lead to an increase in the variance of the gradient estimation, making the gradient estimation unstable and slowing down the optimization process of the initial probability distribution. Based on this, the embodiments of this application can also use the reparameterization method to train the initial probability distribution. The training process of the reparameterization method is described below.

[0142] In some embodiments, such as Figure 6 As shown, in step A1 above, multiple sample feature points are selected from the corresponding range of sample feature points according to the initial probability distribution to obtain sample features, including:

[0143] According to the reference probability distribution, multiple reference feature points are selected from the corresponding range of reference feature points to obtain reference features. Through a pre-trained feature encoding model, the reference features are converted into sample features that satisfy the initial probability distribution. The type of the reference probability distribution is different from the type of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution.

[0144] Specifically, the reference probability distribution can be set as needed. For example, when the initial probability distribution is a beta distribution, the reference probability distribution can be a continuous probability distribution other than the beta distribution, such as the standard normal distribution (a normal distribution with a mean of 0 and a standard deviation of 1); when the initial probability distribution is a normal distribution, the reference probability distribution can be a continuous probability distribution other than the normal distribution, such as the beta distribution, etc.

[0145] When generating reference features according to the reference probability distribution, the terminal device can select multiple reference feature points from each value interval according to the reference selection probability of each value interval within the range of reference feature point values ​​corresponding to the reference probability distribution, and form the above reference features. The number of multiple reference feature points can be set as needed, and can be consistent with the number of multiple object feature points in the object features in the above embodiment, for example, 768, and is not limited thereto.

[0146] The pre-trained feature encoding model can be a neural network model or a linear mapping function, used to transform any feature that satisfies the parameter probability distribution into another feature that satisfies the initial probability distribution. In this case, the parameters of the feature encoding model include the parameters of the initial probability distribution.

[0147] Furthermore, in step A2 above, the parameters of the initial probability distribution are adjusted based on the difference between the local predicted text and the corresponding local output text, including:

[0148] Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

[0149] Specifically, a preset loss function is used to determine the local loss value based on the difference between the local predicted text and the corresponding local output text (i.e., sample label). For example, the preset loss function includes, but is not limited to, the cross-entropy loss function. Finally, the parameters of the feature encoding model are adjusted based on the local loss value, and the parameters in the adjusted feature encoding model that correspond to the initial probability distribution are used as the new parameters of the initial probability distribution.

[0150] For example, the initial probability distribution is a beta distribution, and the corresponding parameters include shape parameter α and shape parameter β. The feature encoding model parameters also include α and β. Thus, after adjusting α and β of the feature encoding model, the adjusted α and β are used as the new parameters of the initial probability distribution.

[0151] It should be noted that in each round of training iteration, the parameters of the feature encoding model can be adjusted based on the local loss value corresponding to a local sample, or the total local loss value can be obtained based on the local loss values ​​corresponding to multiple local samples. For example, the total local loss value can be obtained by averaging the multiple local loss values, and the parameters of the feature encoding model can be adjusted based on the total local loss value.

[0152] For example, during the training process of the initial probability distribution, a reference feature ξ (i.e., an auxiliary random variable) is introduced, ξ ~ p(ξ), where p(ξ) represents another probability distribution, such as the standard normal distribution N(0, 1), i.e., the mean μ is 0 and the standard deviation σ is 1. ξ is sampled from the standard normal distribution, and a feature encoding model g (i.e., a deterministic mapping function) is introduced, satisfying g(ξ) ~ U. n The mapping relationship, U n Let g(ξ) represent the initial probability distribution, and ξ ~ U. n This indicates that the mapping function g can transform ξ into a function that satisfies U. n The sample features. Assuming the initial probability distribution is a beta distribution (α, β), the sample features z can be expressed as follows (6):

[0153] z=g(ξ;α,β)=α+βξ (6)

[0154] By reparameterizing, the gradient can be estimated by directly calculating the changes in the loss value with respect to α and β. For example, the loss function L is expressed as follows (7):

[0155] L=l(h([u n ;x]), y) (7)

[0156] The gradient of L with respect to α and β is calculated by backpropagation, and then α and β are updated using the gradient descent method. It can be understood that α and β are both parameters of the feature encoding model g and parameters of the initial probability distribution.

[0157] In this embodiment, the initial probability distribution is trained using a reparameterization method, which makes the gradient estimation based on the feature encoding model rather than on changes in sample features, thus making the gradient estimation more stable and the optimization process of the initial probability distribution more reliable.

[0158] In this embodiment, considering that the server can obtain the object features corresponding to multiple objects, and each object feature satisfies a corresponding preset probability distribution, it can be assumed that the server possesses a mixture of preset probability distributions corresponding to multiple objects, i.e., a global distribution. If the server attempts to identify each object based on the collected object features, it needs to reconstruct the preset probability distribution corresponding to each object from the global distribution and further confirm which preset probability distribution each object feature comes from. Therefore, to ensure the anonymity of object features, this can be achieved in the following two ways: First, the preset probability distribution of each object cannot be identified from the global distribution; second, even if the preset probability distribution corresponding to each object is reconstructed from the global distribution, it is impossible to accurately attribute each object feature to its respective preset probability distribution.

[0159] Regarding the first aspect mentioned above, when the function space containing the preset probability distribution corresponding to each object is a linearly correlated space, it can be guaranteed that the preset probability distribution of each object cannot be identified from the aforementioned global distribution, thereby protecting the anonymity of object features. For example, the preset probability distribution can adopt a beta distribution, a Pearson Type VI distribution, etc., to ensure the linear correlation of the function space containing the preset probability distribution.

[0160] Regarding the second aspect mentioned above, when the distance between the preset probability distributions of multiple objects is small, it can be ensured that the server cannot accurately attribute the collected object features to their respective preset probability distributions. One feasible method is to initialize the parameters characterizing the initial probability distributions with the same values, controlling the learning rate, the gradient clipping threshold, and the total number of update steps. For a normal distribution, the probability of misattribution (misattributing object features to their respective preset probability distributions) is negatively correlated with the learning rate, update steps, and gradient clipping threshold, and positively correlated with the standard deviation (a parameter of the normal distribution).

[0161] It is understandable that the anonymity of object characteristics can be guaranteed when either the first or second aspect is satisfied. The implementation methods of the first and second aspects are explained below.

[0162] In some embodiments, to ensure that the server cannot identify the preset probability distribution of each object from the characteristics of each object, the following settings can be made: the terminal devices corresponding to multiple objects each have the same configuration training data set for their respective initial probability distributions. The configuration training data includes one or more of the following:

[0163] Initial parameters of the initial probability distribution;

[0164] Learning rate size;

[0165] The critical value for gradient clipping;

[0166] The number of steps to update the initial probability distribution.

[0167] When the initial parameters of the initial probability distributions set for multiple objects are the same, the types of the initial probability distributions corresponding to the multiple objects are the same. For example, the initial probability distributions corresponding to the multiple objects are all beta distributions or all Gaussian distributions.

[0168] The learning rate is a crucial hyperparameter in machine learning. It determines the step size and magnitude of parameter updates in each iteration of the initial probability distribution. Specifically, the learning rate controls how quickly the optimization algorithm moves along the gradient direction during gradient descent. A larger learning rate results in a larger step size for parameter updates, potentially leading to faster convergence of the initial probability distribution, but it can also cause training instability or even divergence. Conversely, a smaller learning rate results in a smaller step size for parameter updates, leading to slower convergence of the initial probability distribution, but it is more likely to converge and the training process is more stable. Therefore, the magnitude of the learning rate significantly impacts the convergence speed and performance of the initial probability distribution. By choosing an appropriate learning rate, the initial probability distribution can converge within a reasonable timeframe while avoiding overfitting or underfitting.

[0169] Gradient clipping is used during training of an initial probability distribution to prevent gradient explosion. Gradient explosion refers to the phenomenon where, during training, the gradient value becomes extremely large, causing the parameters of the initial probability distribution to vary excessively, leading to parameter divergence and preventing convergence. Here, the gradient represents the steepest ascent direction of the loss function at a given point, and the gradient value is the norm of the gradient, used to quantify its magnitude. To address this parameter divergence and convergence failure, gradient clipping limits the gradient's magnitude by setting a critical value, known as the gradient clipping threshold, which is the set maximum gradient value. If the calculated gradient value exceeds this threshold, it is scaled to ensure that the gradient value does not exceed the threshold.

[0170] The number of update steps for the initial probability distribution can be understood as the number of times the parameters are updated.

[0171] In this embodiment of the application, considering that if the server can accurately infer the preset probability distribution to which each object feature belongs based on the object features, it can distinguish different object features and thus different objects. In this case, the server can collect various data generated by each object in the target application, which poses a data security risk. Therefore, in order to prevent the server from accurately inferring the preset probability distribution to which each object feature belongs and to ensure the security of object data, the distance between the preset probability distributions corresponding to different objects can be set to be small (i.e., the similarity is large). When the configuration training data of the preset probability distributions corresponding to different objects are the same, the distance between the preset probability distributions corresponding to different objects can be made small.

[0172] In some embodiments, in order to minimize the distance between the preset probability distributions of multiple objects, the following settings can be made: the probability distribution function corresponding to the preset probability distribution set for each object resides in a linearly correlated space.

[0173] The probability distribution function is used to represent the preset selection probability of each value interval within the range of values ​​of the object's feature points. The linear correlation space represents the probability distribution function corresponding to the preset probability distribution, which has a linear relationship with the probability distribution functions corresponding to other probability distributions. In other words, the probability distribution function corresponding to the preset probability distribution can be represented by one or more probability distribution functions corresponding to other probability distributions.

[0174] For example, suppose the probability distribution function corresponding to the preset probability distribution is f1(x), which has a linear relationship with the probability distribution function f2(x) corresponding to another probability distribution and the probability distribution function f3(x) corresponding to another probability distribution, as can be expressed as the following equation (8):

[0175] f1(x)=c1 f2(x)+c2 f2(x) (8)

[0176] Where c1 and c2 are non-negative numbers, and c1 + c2 = 1.

[0177] In this embodiment, the probability distribution function corresponding to the preset probability distribution set for each object is located in a linearly correlated space. This ensures that the preset probability distribution of each object cannot be identified based on the characteristics of each object that satisfy different preset probability distributions, thus protecting the anonymity of object characteristics and ensuring the data security of the object.

[0178] In some embodiments, after the server completes the training of the initial language model, it obtains the target language model. During the application of the target language model, such as... Figure 7As shown, the server can obtain the real-time input text and sampling features sent by the target terminal device. The sampling features include: multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution trained by the target terminal device; inputting the real-time input text and sampling features into the trained target language model, predicting the corresponding recommended text, and sending the recommended text to the terminal device corresponding to the target object.

[0179] In this process, after the target terminal device obtains the real-time input text entered by the corresponding object in the target application, it generates sampling features according to a preset probability distribution obtained through training. Specifically, according to the preset selection probability of each value interval within the range of object feature points in the preset probability distribution, multiple sampling feature points are selected from each value interval. The number of multiple sampling feature points can be set as needed, and can be consistent with the number of multiple object feature points in the object features in the above embodiment, without limitation. The real-time input text and sampling features are then uploaded to the server, and the server predicts the corresponding recommended text based on the target language model.

[0180] For example, when the real-time input text is the pinyin input by the target object in the input method application, the recommended text is one or more words corresponding to the pinyin returned by the server. Figure 8 As shown, the target user inputs the pinyin "zi'ran'yu'yan" through an input method application. The input method application uploads the pinyin and the corresponding sampled features to the server. Based on the pinyin and the corresponding sampled features, the server predicts multiple words, including "natural language still needs natural still one...", through the target language model.

[0181] For example, when the real-time input text is the question text entered by the target user in the intelligent assistant, the recommended text can be one or more answer texts returned by the server. Figure 9 As shown, the target user inputs the question text "Please recommend some good comedy movies" through the intelligent assistant. The intelligent assistant uploads the question text and corresponding sampled features to the server. Based on the question text and corresponding sampled features, the server predicts the answer text using the target language model: "Of course! Here are some highly-rated comedy movies that are not only funny but also bring you joy and relaxation. Hope you like them! 1. The movie 'XXXX' tells the story of... 2. The movie 'XXXX' tells the story of...."

[0182] For example, when the real-time input text is the search text entered by the target object in a search application, the recommended text can be one or more search result texts returned by the server. For example... Figure 10As shown, the target user inputs the search text "What is a probability distribution?" in real time in the search application. The search application uploads the search text and the corresponding sampling features to the server. Based on the search text and the corresponding sampling features, the server predicts multiple search result texts through the target language model, including "What is the meaning of probability distribution?", "Probability distribution (mathematical term) - encyclopedia", "Probability distribution function - encyclopedia", and "What is probability distribution - some common...".

[0183] It should be noted that the language model training method of this application embodiment can be applied to various natural language applications, not limited to the above-mentioned input method applications, intelligent assistants (or dialogue systems), search applications, etc.

[0184] In this embodiment, the server can obtain the real-time input text and sampling features sent by the target terminal device, input the real-time input text and sampling features into the trained target language model, and output personalized recommendation text that matches the target object.

[0185] Based on the same inventive concept, this application also provides a probability distribution training method. The principle of this device in solving the problem is similar to that of the language model training method in the above embodiments. Therefore, the implementation of this probability distribution training method can refer to the implementation of the language model training method described above, and the repeated parts will not be described again.

[0186] like Figure 11 The diagram shown is a flowchart of a probability distribution training method provided in an embodiment of this application. This method is applied to a terminal device and may include the following steps S111-S113:

[0187] S111. Obtain a local sample set. Each local sample includes: the local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the value range of the corresponding sample feature points according to the initial probability distribution.

[0188] The process of obtaining the local sample set is described in the training process of the initial probability distribution of each object in the above embodiments of this application, and will not be repeated here.

[0189] S112. Iteratively train the initial probability distribution based on the local sample set to obtain the preset probability distribution. Each iteration includes: inputting the selected local sample text and sample features into the obtained server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text.

[0190] The specific implementation process of S112 is similar to that of steps A1-A2 in the above embodiments of this application, and will not be repeated here.

[0191] S113. Send a subset of global samples to the server. Each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and the object features generated according to a preset probability distribution.

[0192] The process of obtaining each global sample in the global sample subset is described in the specific implementation process of S21 in the above embodiments of this application, and will not be repeated here.

[0193] In some embodiments, multiple sample feature points are selected from the corresponding range of sample feature points according to an initial probability distribution to obtain sample features, including:

[0194] According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. The reference features are then converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model. The type of the reference probability distribution is different from that of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution.

[0195] Furthermore, based on the difference between the local predicted text and the corresponding local output text, the parameters of the initial probability distribution are adjusted, including: adjusting the parameters of the feature encoding model based on the difference between the local predicted text and the corresponding local output text, and obtaining new parameters of the initial probability distribution based on the adjusted parameters.

[0196] It should be noted that the specific implementation process of this embodiment is described in the relevant content of the foregoing embodiments of this application, and will not be repeated here.

[0197] In some embodiments, the function space of the probability distribution function corresponding to the initial probability distribution is a linearly dependent space;

[0198] The probability distribution function represents the initial selection probability of each interval within the range of sample feature points of the initial probability distribution. The linear correlation space represents the probability distribution function corresponding to the initial probability distribution, which has a linear relationship with other probability distribution functions.

[0199] It should be noted that the specific implementation process of this embodiment is described in the relevant content of the foregoing embodiments of this application, and will not be repeated here.

[0200] In some embodiments, the terminal device can also acquire real-time input text and sampling features of the target object. The sampling features include: multiple sampling feature points selected from the corresponding object feature point value range according to a preset probability distribution obtained through training; sending the real-time input text and sampling features to the server so that the server can predict the corresponding recommended text based on the real-time input text and sampling features through the trained target language model; and receiving the recommended text returned by the server.

[0201] It should be noted that the specific implementation process of this embodiment is described in the relevant content of the foregoing embodiments of this application, and will not be repeated here.

[0202] The following pseudocode illustrates the overall implementation flow of an embodiment of this application.

[0203] Input: Number of users N; existing initial language model h on the server; initial probability distribution U n , n=1,2,3...N.

[0204] Server-side and terminal device collaborative training phase

[0205] / * Processes for each mobile device * /

[0206] 1: For n, complete do in parallel from 1 to N.

[0207] 2: Download the initial language model h from the server;

[0208] 3: Fix the parameters of h, based on the initial probability distribution U n Training the optimal preset probability distribution U n ′, where U n It needs to be obtained from a linearly dependent space;

[0209] 4: for each global sample (x, y) do

[0210] 5: From U n Features of the sampled object u n ;

[0211] 6: Anonymous upload of global samples ([u n (x], y) to the server;

[0212] 7: end for

[0213] 8: end for

[0214] / * Server process * /

[0215] 9: Receives a global sample set of all objects;

[0216] 10: Train h based on the global sample set to obtain the target language model h′;

[0217] Server-side real-time inference stage

[0218] / * Processes for each mobile device * /

[0219] 11: For each object's real-time input text x′, based on U n Generate sampling features u n ′, will [u n Upload [x', x'] to the server;

[0220] / * Server process * /

[0221] 12: Through h′, based on [u n [x', x'], predict recommended text;

[0222] 13: Return the recommended text to the terminal device.

[0223] This application embodiment conducted experiments on three public datasets and two industrial datasets; the public datasets include Sentiment140, Amazon eBooks, and the Reddit dataset. The industrial datasets were collected from microblog data from multiple entities and preprocessed to construct a Pinyin input method dataset and an intelligent association dataset. The target language model can be GPT2. The accuracy rates of the training method of this application embodiment and the traditional training method are shown in Table 1 below:

[0224] Table 1

[0225]

[0226] Based on the same inventive concept, this application also provides a language model training device. The principle of this device in solving the problem is similar to the language model training method in the above embodiments. Therefore, the implementation of this device can refer to the implementation of the above method, and the repeated parts will not be described again.

[0227] like Figure 12 The diagram shown is a structural schematic of a language model training device 1200, which is located on the server side and may specifically include:

[0228] The first acquisition module 1201 is used to acquire a global sample set corresponding to multiple objects. Each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of the corresponding object feature points according to a preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training an initial probability distribution based on a local sample set. Each local sample includes: local sample text of the corresponding object's historical input and the corresponding local output text.

[0229] The first training module 1202 is used to iteratively train the initial language model based on the global sample set, wherein each iteration includes:

[0230] The selected global sample text and object features are input into the initial language model to obtain the global predicted text. Based on the difference between the global predicted text and the corresponding global output text, the parameters of the initial language model are adjusted.

[0231] In some embodiments, the preset probability distribution set for each object is obtained by the terminal device corresponding to each object in the following way:

[0232] The initial probability distribution is iteratively trained based on a local sample set. Each iteration includes:

[0233] Select local sample text and corresponding sample features. The sample features include multiple sample feature points selected from the value range of the corresponding sample feature points according to the initial probability distribution.

[0234] The local sample text and sample features are input into the initial language model to obtain the local predicted text. Based on the difference between the local predicted text and the corresponding local output text, the parameters of the initial probability distribution are adjusted.

[0235] In some embodiments, multiple sample feature points are selected from the corresponding sample feature point value range according to the initial probability distribution. When obtaining sample features, the terminal device corresponding to each object is specifically used for:

[0236] According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. The reference features are then converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model. The type of the reference probability distribution is different from that of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution.

[0237] When adjusting the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text, the terminal device corresponding to each object is specifically used for:

[0238] Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

[0239] In some embodiments, the terminal devices corresponding to multiple objects each have the same configuration training data set for their respective initial probability distributions. The configuration training data includes one or more of the following:

[0240] Initial parameters of the initial probability distribution;

[0241] Learning rate size;

[0242] The critical value for gradient clipping;

[0243] The number of steps to update the initial probability distribution.

[0244] In some embodiments, the function space of the probability distribution function corresponding to the preset probability distribution set for each object is a linear correlation space.

[0245] The probability distribution function represents the preset selection probability of each value interval within the range of values ​​of the object's feature points. The linear correlation space represents the probability distribution function corresponding to the preset probability distribution, which has a linear relationship with the probability distribution functions corresponding to other probability distributions.

[0246] In some embodiments, the first acquisition module 1201 is specifically used for:

[0247] Each object receives a global sample subset sent by its respective terminal device. Each global sample subset includes multiple global samples corresponding to one object.

[0248] The global sample set is obtained based on multiple received global sample subsets.

[0249] In some embodiments, the apparatus further includes:

[0250] The prediction module is used to acquire real-time input text and sampling features sent by the target terminal device. The sampling features include multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution corresponding to the target object. The real-time input text and sampling features are then input into the trained target language model to predict the corresponding recommendation text.

[0251] The push module is used to send recommended text to the terminal devices corresponding to the target audience.

[0252] Based on the same inventive concept, this application also provides a probability distribution training device. The principle of this device in solving the problem is similar to the probability distribution training method in the above embodiments. Therefore, the implementation of this device can refer to the implementation of the above method, and the repeated parts will not be described again.

[0253] like Figure 13 The diagram shown is a schematic of the probability distribution training device 1300, which is installed in a terminal device and specifically includes:

[0254] The second acquisition module 1301 is used to acquire a local sample set. Each local sample includes: local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the value range of the corresponding sample feature points according to the initial probability distribution.

[0255] The second training module 1302 is used to iteratively train the initial probability distribution based on the local sample set to obtain the preset probability distribution. Each iteration includes: inputting the selected local sample text and sample features into the obtained server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text.

[0256] The sending module 1303 is used to send a global sample subset to the server so that the server can train the initial language model based on the global sample subset; each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and the object features generated according to a preset probability distribution.

[0257] In some embodiments, when selecting multiple sample feature points from the corresponding sample feature point value ranges according to the initial probability distribution to obtain sample features, the second training module 1302 is specifically used for:

[0258] According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. Then, the reference features are converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model. The type of the reference probability distribution is different from the type of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution.

[0259] When adjusting the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text, the second training module 1302 is specifically used for:

[0260] Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

[0261] In some embodiments, the function space of the probability distribution function corresponding to the initial probability distribution is a linearly dependent space;

[0262] The probability distribution function represents the initial selection probability of each interval within the range of sample feature points of the initial probability distribution. The linear correlation space represents the probability distribution function corresponding to the initial probability distribution, which has a linear relationship with other probability distribution functions.

[0263] In some embodiments, the apparatus further includes:

[0264] The sampling module is used to acquire the real-time input text and sampling features of the target object. The sampling features include: multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution obtained through training.

[0265] The upload module is used to send real-time input text and sampled features to the server, so that the server can predict the corresponding recommended text based on the real-time input text and sampled features using the trained target language model;

[0266] The receiving module is used to receive the recommendation text returned by the server.

[0267] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0268] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0269] Having introduced the language model training method, apparatus, and probability distribution training method and apparatus according to exemplary embodiments of this application, the electronic device according to another exemplary embodiment of this application will now be described.

[0270] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. In one embodiment, the electronic device may be a server, such as... Figure 1 The server 120 is shown. In this embodiment, the electronic device can be structured as follows: Figure 14As shown, it includes a memory 1401, a communication module 1403, and one or more processors 1402.

[0271] The memory 1401 is used to store computer programs executed by the processor 1402. The memory 1401 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0272] Memory 1401 may be volatile memory, such as random-access memory (RAM); memory 1401 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1401 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1401 may be a combination of the above-described memories.

[0273] Processor 1402 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 1402 is used to implement the above-mentioned language model training method when calling the computer program stored in memory 1401.

[0274] The communication module 1403 is used to communicate with terminal devices and other servers.

[0275] This application embodiment does not limit the specific connection medium between the memory 1401, communication module 1403, and processor 1402. This application embodiment... Figure 14 The memory 1401 and the processor 1402 are connected via a bus 1404, and the bus 1404 is in Figure 14 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1404 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 14 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0276] The memory 1401 stores a computer storage medium, which stores computer-executable instructions for implementing the language model training method of this application embodiment. The processor 1402 is used to execute the above-described language model training method, such as... Figure 2 As shown.

[0277] In another embodiment, the electronic device can also be other electronic devices, such as... Figure 1 The terminal device 110 is shown. In this embodiment, the electronic device can be structured as follows: Figure 15 As shown, it includes components such as: communication component 1510, memory 1520, display unit 1530, camera 1540, sensor 1550, audio circuit 1560, Bluetooth module 1570, processor 1580, etc.

[0278] The communication component 1510 is used to communicate with the server. In some embodiments, it may include a Circuit-Based Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology. Electronic devices can use the WiFi module to help users send and receive information.

[0279] The memory 1520 can be used to store software programs and data. The processor 1580 executes various functions of the terminal device 110 and performs data processing by running the software programs or data stored in the memory 1520. The memory 1520 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1520 stores an operating system that enables the terminal device 110 to run. In this application, the memory 1520 may store the operating system and various application programs, and may also store a computer program that executes the probability distribution training method of the embodiments of this application.

[0280] The display unit 1530 can also be used to display information input by the user or information provided to the user, as well as various menus of the terminal device 110, in a graphical user interface (GUI). Specifically, the display unit 1530 may include a display screen 1532 disposed on the front of the terminal device 110. The display screen 1532 may be configured as a liquid crystal display, a light-emitting diode, or the like. The display unit 1530 can be used to display natural language application interfaces, etc., as described in the embodiments of this application.

[0281] The display unit 1530 can also be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device 110. Specifically, the display unit 1530 may include a touch screen 1531 disposed on the front of the terminal device 110, which can collect touch operations of the user on or near it, such as clicking buttons, dragging scroll boxes, etc.

[0282] The touchscreen 1531 can be placed on top of the display screen 1532, or the touchscreen 1531 and the display screen 1532 can be integrated to realize the input and output functions of the terminal device 110. After integration, it can be referred to as a touch display screen. In this application, the display unit 1530 can display the application and the corresponding operation steps.

[0283] Camera 1540 can be used to capture still images, which users can then share via an application. There can be one or multiple cameras 1540. An object is projected onto a photosensitive element through a lens, generating an optical image. This photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to the processor 1580 for conversion into a digital image signal.

[0284] The terminal device may also include at least one sensor 1550, such as an accelerometer 1551, a proximity sensor 1552, a fingerprint sensor 1553, and a temperature sensor 1554. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.

[0285] Audio circuitry 1560, speaker 1561, and microphone 1562 provide an audio interface between the user and terminal device 110. Audio circuitry 1560 converts received audio data into electrical signals, which are then transmitted to speaker 1561, where they are converted into sound signals for output. Terminal device 110 may also be equipped with volume buttons for adjusting the volume of the sound signal. On the other hand, microphone 1562 converts collected sound signals into electrical signals, which are received by audio circuitry 1560, converted into audio data, and then output to communication component 1510 for transmission to, for example, another terminal device 110, or to memory 1520 for further processing.

[0286] The Bluetooth module 1570 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1570, thereby exchanging data.

[0287] The processor 1580 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 1520 and calling data stored in the memory 1520. In some embodiments, the processor 1580 may include one or more processing units; the processor 1580 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1580. In this application, the processor 1580 can run the operating system, applications, user interface display and touch response, and the probability distribution training method of the embodiments of this application. Furthermore, the processor 1580 is coupled to the display unit 1530.

[0288] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when run on an electronic device, causes the electronic device to execute the steps of the language model training method or probability distribution training method of embodiments of this application.

[0289] In some possible implementations, various aspects of the language model training method and probability distribution training method provided in this application can also be implemented in the form of a computer program product, which includes a computer program. When the computer program product is run on an electronic device, the computer program is used to cause the electronic device to perform the steps in the language model training method or probability distribution training method according to the various exemplary embodiments of this application described above. For example, the electronic device can perform, for example, Figure 2 The steps are shown in the figure.

[0290] Computer program products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0291] The computer program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0292] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.

[0293] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0294] Computer programs for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The computer program can execute entirely on the user's electronic device, partially on the user's electronic device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).

[0295] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0296] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0297] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.

[0298] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0299] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for training a language model, characterized in that, Applied to the server side, the method includes: A global sample set corresponding to multiple objects is obtained. Each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of the corresponding object feature points according to a preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training an initial probability distribution based on a local sample set. Each local sample includes: local sample text of the corresponding object's historical input and the corresponding local output text. The initial language model is iteratively trained based on the global sample set, wherein each iteration includes: The selected global sample text and object features are input into the initial language model to obtain the global predicted text. Based on the difference between the global predicted text and the corresponding global output text, the parameters of the initial language model are adjusted.

2. The method according to claim 1, characterized in that, The preset probability distribution set for each object is obtained by the terminal device corresponding to each object in the following way: The initial probability distribution is iteratively trained based on the local sample set to obtain the preset probability distribution; wherein each iteration includes: Select local sample text and corresponding sample features, wherein the sample features include: multiple sample feature points selected from the value range of the corresponding sample feature points according to the initial probability distribution; The local sample text and the sample features are input into the initial language model to obtain local predicted text, and the parameters of the initial probability distribution are adjusted based on the difference between the local predicted text and the corresponding local output text.

3. The method according to claim 2, characterized in that, The step of selecting multiple sample feature points from the corresponding sample feature point value range according to the initial probability distribution to obtain sample features includes: According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. Then, the reference features are converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model. The type of the reference probability distribution is different from the type of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution. The adjustment of the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text includes: Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

4. The method according to claim 2, characterized in that, The terminal devices corresponding to the plurality of objects each have the same configuration training data set for their respective initial probability distributions, and the configuration training data includes one or more of the following: The initial parameters of the initial probability distribution; Learning rate size; The critical value for gradient clipping; The number of update steps for the initial probability distribution.

5. The method according to any one of claims 1 to 4, characterized in that, The probability distribution function corresponding to the preset probability distribution set for each object resides in a linearly correlated space. The probability distribution function represents the preset selection probability of each value interval within the range of the object feature points, and the linear correlation space represents the linear relationship between the probability distribution function corresponding to the preset probability distribution and the probability distribution functions corresponding to other probability distributions.

6. The method according to any one of claims 1 to 4, characterized in that, The step of obtaining the global sample set corresponding to multiple objects includes: Each object receives a global sample subset sent by its respective terminal device. Each global sample subset includes multiple global samples corresponding to one object. The global sample set is obtained based on multiple received global sample subsets.

7. The method according to any one of claims 1 to 4, characterized in that, The method further includes: The real-time input text and sampling features sent by the target terminal device are obtained. The sampling features include multiple sampling feature points selected from the corresponding object feature point value range according to the preset probability distribution trained by the target terminal device. The real-time input text and the sampled features are input into the trained target language model to predict the corresponding recommended text, and the recommended text is sent to the terminal device corresponding to the target object.

8. A method for training a probability distribution, characterized in that, Applied to a terminal device, the method includes: Obtain a local sample set. Each local sample includes: local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the corresponding sample feature point value range according to the initial probability distribution. The initial probability distribution is iteratively trained based on the local sample set to obtain a preset probability distribution; wherein each iteration includes: inputting the selected local sample text and sample features into the acquired server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text. A subset of global samples is sent to the server, enabling the server to train the initial language model based on the subset of global samples; each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features generated according to the preset probability distribution.

9. The method according to claim 8, characterized in that, The step of selecting multiple sample feature points from the corresponding sample feature point value range according to the initial probability distribution to obtain sample features includes: According to the reference probability distribution, multiple reference feature points are selected from the corresponding reference feature point value range to obtain reference features. The reference features are then converted into sample features that satisfy the initial probability distribution through a pre-trained feature encoding model. The type of the reference probability distribution is different from the type of the initial probability distribution, and the parameters of the feature encoding model include the parameters of the initial probability distribution. The adjustment of the parameters of the initial probability distribution based on the difference between the local predicted text and the corresponding local output text includes: Based on the difference between the local predicted text and the corresponding local output text, the parameters of the feature encoding model are adjusted, and new parameters of the initial probability distribution are obtained based on the adjusted parameters.

10. The method according to claim 8 or 9, characterized in that, The function space containing the probability distribution function corresponding to the initial probability distribution is a linearly dependent space. The probability distribution function represents the initial selection probability of each value interval within the range of sample feature points of the initial probability distribution, and the linear correlation space represents the probability distribution function corresponding to the initial probability distribution, which has a linear relationship with other probability distribution functions.

11. The method according to claim 8 or 9, characterized in that, The method further includes: The real-time input text and sampling features of the target object are obtained. The sampling features include multiple sampling feature points selected from the corresponding object feature point value range according to a preset probability distribution obtained through training. The real-time input text and the sampled features are sent to the server so that the server can predict the corresponding recommended text based on the real-time input text and the sampled features using the trained target language model. Receive the recommended text returned by the server.

12. A training device for a language model, characterized in that, Located on the server side, the device includes: The first acquisition module is used to acquire a global sample set corresponding to multiple objects. Each global sample includes: global sample text of the corresponding object's historical input, the corresponding global output text, and object features. The object features include: multiple object feature points selected from the value range of corresponding object feature points according to a preset probability distribution set for the corresponding object. The preset probability distribution is obtained by training an initial probability distribution based on a local sample set. Each local sample includes: local sample text of the corresponding object's historical input and the corresponding local output text. The first training module is used to iteratively train the initial language model based on the global sample set, wherein each iteration includes: The selected global sample text and object features are input into the initial language model to obtain the global predicted text. Based on the difference between the global predicted text and the corresponding global output text, the parameters of the initial language model are adjusted.

13. A probability distribution training device, characterized in that, The device, configured in a terminal device, includes: The second acquisition module is used to acquire a local sample set. Each local sample includes: local sample text of the corresponding object's historical input, the corresponding local output text, and sample features. The sample features include: multiple sample feature points selected from the corresponding sample feature point value range according to the initial probability distribution. The second training module is used to iteratively train the initial probability distribution based on the local sample set to obtain a preset probability distribution. Each iteration includes: inputting the selected local sample text and sample features into the acquired server-side initial language model, and adjusting the parameters of the initial probability distribution based on the difference between the output local predicted text and the corresponding local output text. The sending module is used to send a subset of global samples to the server. Each global sample includes: the global sample text of the corresponding object's historical input, the corresponding global output text, and the object features generated according to the preset probability distribution.

14. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1 to 7 or any of the methods described in claims 8 to 11.

15. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1 to 7 or any of the methods described in claims 8 to 11.

16. A computer program product, characterized in that, The method includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the methods of claims 1 to 7 or any of the methods of claims 8 to 11.