Model training method and device, reasoning method and device, electronic equipment and storage medium

By introducing feature regularization and cross-entropy loss function into large model training, and combining positive and negative sample feature sets to optimize model parameters, the problem of insufficient feature regularization in existing technologies is solved, improving model training efficiency and downstream task performance, enhancing semantic consistency and feature separability, and improving user experience.

CN121638465APending Publication Date: 2026-03-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing large models suffer from limitations in capturing word-level differences during training due to the difficulty of feature regularization techniques. They neglect fine-grained semantic modeling, and the coupling between regularization signals and the main task objective is insufficient. Cross-feature dimension correlations are not effectively modeled, resulting in limited ability of the model to capture multi-dimensional feature interaction relationships in complex scenarios, which affects generalization performance and adaptability to downstream tasks.

Method used

By introducing feature regularization techniques during training, including cross-domain feature alignment, content feature alignment, sentence feature alignment, context alignment, and attribute feature alignment, and combining them with the cross-entropy loss function, the positive and negative sample feature sets of the target sample are determined. The model parameters are adjusted to enhance semantic consistency and feature separability, and the model is optimized using feature similarity loss information.

Benefits of technology

It improves model training efficiency and performance, enhances the model's representation consistency and robustness in tasks such as classification and retrieval, improves user experience, and achieves stronger feature representation capabilities and generalization capabilities for downstream tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121638465A_ABST
    Figure CN121638465A_ABST
Patent Text Reader

Abstract

The invention provides a model training method, and relates to the technical field of artificial intelligence, in particular to the technical fields of large models, deep learning, natural language processing, pre-training, fine tuning and the like. According to the specific implementation scheme, a sample data sequence is input into a to-be-trained model, a target sample feature sequence is obtained, the sample data sequence comprises multiple pieces of sample data, and the target sample feature sequence comprises respective target sample features of the multiple pieces of sample data; determining at least one piece of first loss information for the at least one piece of target sample data according to the at least one positive sample feature set for the at least one piece of target sample data, the positive sample feature set for the target sample data comprises first target sample features of a plurality of previous sample data of the target sample data in the plurality of target sample features; and training the to-be-trained model according to the at least one piece of first loss information. The invention further provides a reasoning method and device, electronic equipment and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of artificial intelligence, and in particular, to the technical field of large models, deep learning, natural language processing (NLP), pre-training, fine-tuning, and the like. More specifically, the present disclosure provides a model training method, an inference method, an apparatus, an electronic device, and a storage medium. BACKGROUND

[0002] With the development of artificial intelligence technology, the application of large models is increasing. A large model can generate a response result according to single-modal or multi-modal input data. In the training process of the large model, the parameters of the large model can be adjusted based on loss information determined by a cross entropy loss function. SUMMARY

[0003] The present disclosure provides a model training method, an inference method, an apparatus, a device, and a storage medium.

[0004] According to an aspect of the present disclosure, a model training method is provided. The method includes inputting a sample data sequence into a to-be-trained model to obtain a target sample feature sequence, the sample data sequence including a plurality of sample data, and the target sample feature sequence including target sample features of the plurality of sample data; determining at least one first loss information for at least one target sample data according to at least one positive sample feature set for the at least one target sample data, the target sample data being determined according to a plurality of sample data with a data similarity greater than or equal to a preset data similarity threshold, and the positive sample feature set for the target sample data including first target sample features of a plurality of preceding sample data of the target sample data in the plurality of target sample features; training the to-be-trained model according to the at least one first loss information, and the sample data sequence being obtained according to at least one of a sample text, a sample image, a sample audio, and a sample video.

[0005] According to another aspect of the present disclosure, an inference method is provided. The method includes inputting a to-be-processed data sequence into a target model to obtain a response result, wherein the target model is trained according to the model training method provided by the present disclosure, and the to-be-processed data sequence is obtained according to at least one of a to-be-processed text, a to-be-processed image, a to-be-processed audio, and a to-be-processed video.

[0006] According to another aspect of the present disclosure, a model training apparatus is provided, which comprises: a first obtaining module configured to input a sample data sequence into a model to be trained to obtain a target sample feature sequence, the sample data sequence comprising a plurality of sample data, and the target sample feature sequence comprising target sample features of the plurality of sample data respectively; a first determining module configured to determine at least one first loss information for at least one target sample data according to at least one positive sample feature set for the at least one target sample data, the target sample data being determined according to a plurality of sample data whose data similarity is greater than or equal to a preset data similarity threshold, and the positive sample feature set for the target sample data comprising first target sample features of a plurality of preceding sample data of the target sample data in the plurality of target sample features; and a training module configured to train the model to be trained according to the at least one first loss information, the sample data sequence being obtained according to at least one of a sample text, a sample image, a sample audio and a sample video.

[0007] According to another aspect of the present disclosure, an inference apparatus is provided, which comprises: a second obtaining module configured to input a data sequence to be processed into a target model to obtain a response result, wherein the target model is trained by the model training apparatus provided by the present disclosure, and the data sequence to be processed is obtained according to at least one of a text to be processed, an image to be processed, an audio to be processed and a video to be processed.

[0008] According to another aspect of the present disclosure, an electronic device is provided, which comprises: at least one processor; and a memory connected to the at least one processor in communication, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by the present disclosure.

[0009] According to another aspect of the present disclosure, a non-transitory computer readable storage medium storing computer instructions is provided, the computer instructions being used to enable a computer to perform the method provided by the present disclosure.

[0010] According to another aspect of the present disclosure, a computer program product is provided, which comprises a computer program, the computer program being used to implement the method provided by the present disclosure when executed by a processor.

[0011] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS

[0012] The accompanying drawings are used to better understand the present scheme, and do not constitute a limitation on the present disclosure. Among them:

[0013] Figure 1 is a flowchart of a model training method according to an embodiment of the disclosure;

[0014] Figure 2 is a structural diagram of a model to be trained according to an embodiment of the disclosure;

[0015] Figure 3 is an effect diagram of feature alignment loss information according to an embodiment of the disclosure;

[0016] Figure 4 is a diagram of a plurality of processing layers and an output layer according to an embodiment of the disclosure;

[0017] Figure 5 is a principle diagram of model training according to an embodiment of the disclosure;

[0018] Figure 6 is a schematic flowchart of an inference method according to an embodiment of the disclosure;

[0019] Figure 7 is a block diagram of a model training apparatus according to an embodiment of the disclosure;

[0020] Figure 8 is a block diagram of an inference apparatus according to another embodiment of the disclosure; and

[0021] Figure 9 is a block diagram of an electronic device to which at least one of a model training method and an inference method can be applied according to an embodiment of the disclosure. DETAILED DESCRIPTION

[0022] Exemplary embodiments of the disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the disclosure to help understanding, and should be considered as merely exemplary. Thus, those of ordinary skill in the art will recognize various changes and modifications of the embodiments described herein, which do not depart from the scope and spirit of the disclosure. Also, for the sake of clarity and conciseness, the description below omits the description of well-known functions and structures.

[0023] Large model training can refer to pre-training of a large model and supervised fine-tuning of the large model, etc. The large model can be a large language model (LLM), a large vision model (LVM), or a multimodal large language model (MLLM). The large model can process data of one or more modalities. The data of one or more modalities can include at least one of text, image, audio, and video.

[0024] Taking the data of processing text modal as an example, the strategy of large model training can be an extension based on the traditional autoregressive language model on the classification task. However, unlike general classification tasks, language data has the following two special properties: 1, the data source has a strong long-tail distribution; 2, the feature space corresponding to each predicted word is quite different. This difference leads to the feature space for classification corresponding to the predicted word not being close enough, which further leads to insufficient feature separation distance in the feature extraction stage, further slowing down the pre-training speed and performance.

[0025] In order to improve the training efficiency of the large model and the performance of the large model after training, a feature regularization technique can be introduced in the training process to enhance the generalization ability and semantic consistency of the model through external features, auxiliary signals or structural constraints. The feature regularization technique includes cross-domain feature alignment, content feature alignment, sentence feature alignment, context alignment, attribute feature alignment, etc.

[0026] Cross-domain feature alignment can include: aligning features of different modalities or different domains to achieve a unified semantic space. For example, the contrastive language-image pre-training (CLIP) extracts features from images and text respectively and introduces a contrastive loss, so that related image-text pairs are close in the embedding space, thereby achieving cross-modal semantic consistency. Cross-domain feature alignment takes domain or modality difference as a constraint carrier to achieve cross-domain knowledge sharing and migration.

[0027] Content feature alignment focuses on the consistency of the same semantic content in different contexts. By extracting keywords or semantic summaries from different text segments and projecting them into a unified semantic vector space, the model generates consistent representations when facing similar semantic content. Content feature alignment is commonly used in document-level understanding, retrieval-enhanced pre-training, semantic clustering and other tasks.

[0028] Sentence feature alignment can include: using syntactic structure or salient semantic units in a sentence as auxiliary features for training by parsing the syntactic structure or salient semantic units in the sentence. For example, aligning the syntactic structure by using a syntactic tree or dependency relationship, so that the model has stronger modeling capability for context dependency relationship at the syntactic level.

[0029] Context alignment can include: in the pre-training process, the feature consistency of adjacent segments, different sampling perspectives or multi-round context is constrained. In this way, the robustness of the model in context reasoning and long-range dependency modeling can be improved to learn stable and semantically transferable representations.

[0030] The attribute feature alignment can include: by explicitly separating or constraining the feature dimension corresponding to a specific attribute, the controllability and interpretability of the model to a specific feature factor are strengthened. For example, feature decoupling is achieved by orthogonal constraint or mutual information minimization, so that the model learns a more discriminative internal representation.

[0031] The feature constraint granularity of the above feature regularization technology is coarse, and it is difficult to capture word-level differences. The above feature regularization technology usually takes sentence-level, paragraph-level or modal-level features as the basic unit, ignoring the semantic dynamics at the word or sub-word level. This leads to bias in the model's fine-grained semantic modeling, especially in tasks involving polysemous words and strong context dependence.

[0032] In addition, the regularization signal of the above feature regularization technology is insufficiently coupled with the main task target. These feature-based regularization techniques are mostly applied independently in a contrast learning or feature alignment manner, without fully combining the loss structure of classification, generation and other main tasks, so that the regularization term is difficult to directly promote the main task performance in the optimization process, and even introduces optimization conflicts in some scenarios.

[0033] The above feature regularization technology does not effectively model the correlation across feature dimensions. The above feature regularization technology mostly considers feature regularization as an independent constraint, lacking a modeling mechanism for the inherent relationship between different feature dimensions (such as semantics, syntax, context, position, etc.). This independent modeling approach limits the model's ability to capture multi-dimensional feature interaction relationships in complex scenarios.

[0034] The above feature regularization technology has limited adaptability to downstream task migration. Some regularization schemes introduce fixed feature constraints in the pre-training phase, but it is difficult to adapt to the task feature space flexibly in the downstream fine-tuning phase, resulting in a bias between the pre-training representation and the downstream target, affecting the generalization performance.

[0035] In order to fully improve the model training efficiency and the performance of the trained model, the present disclosure provides a model training method, which will be described below.

[0036] Figure 1 is a flowchart of a model training method according to an embodiment of the present disclosure.

[0037] As shown in Figure 1 , the method 100 can include operations S110 to S130.

[0038] In operation S110, a sample data sequence is input into a model to be trained to obtain a target sample feature sequence.

[0039] According to an embodiment of the present disclosure, the sample data sequence can include a plurality of sample data. The sample data sequence is obtained according to at least one of sample text, sample image, sample audio, and sample video. For example, the sample text can include a plurality of sample characters, and can be taken as the sample data sequence. The sample characters can be taken as the sample data. The sample text can be “Here is a PDF file on how they are used and what they look like”. It can be understood that the sample text including English words is only an example. The present disclosure does not limit this, and the sample text can be text in various languages, and can include one or more languages.

[0040] The to-be-trained model can be the large model described above. The to-be-trained model can extract features at different levels to obtain a plurality of feature sequences, and one of the plurality of feature sequences can be taken as the target sample feature sequence.

[0041] In the model training stage, the expected output of the to-be-trained model can be consistent with the input. The plurality of sample data in the sample data sequence is sequentially provided to the to-be-trained model. The to-be-trained model determines subsequent data based on the preceding sample data. For example, the to-be-trained model receives the sample character “PDF”, and can determine the subsequent character. The subsequent character can be “file”, which is consistent with the character expected to be output by the model. It can be understood that in the early stage of training, the subsequent character can not be consistent with the character expected to be output by the model. With the model being iteratively trained, the consistency between the subsequent character determined by the model and the character expected to be output by the model is continuously improved.

[0042] The target sample feature sequence can include target sample features of the plurality of sample data respectively. For example, the target sample feature sequence can include a target sample feature of the sample character “here”, and can also include a target sample feature of the sample character “is”.

[0043] In operation S120, at least one first loss information for the at least one target sample data is determined according to the at least one positive sample feature set for the at least one target sample data

[0044] According to an embodiment of the present disclosure, the target sample data is determined according to a plurality of sample data in which the data similarity is greater than or equal to a preset data similarity threshold. For example, taking the sample data sequence as sample text as an example, the sample text includes two identical sample characters “they”. The sample character “they” can be taken as the target sample data. In the case where the sample data sequence is sample text, the preset text similarity threshold can be 1, for example.

[0045] The positive sample feature set for the target sample data includes a plurality of first target sample features of a plurality of preceding sample data of the target sample data. The plurality of preceding sample data can be adjacent to the target sample data respectively. For example, in the sample text, the two preceding sample characters adjacent to the sample character "they" are the sample character "how" and the sample character "what" respectively. The target sample feature of the sample character "how" and the target sample feature of the sample character "what" can be used as two first target sample features for the sample character "they". The sample feature set including the two first target sample features can be used as the positive sample feature set for the sample character "they".

[0046] The similarity between the plurality of first target sample features in the positive sample feature set for the target sample data can be determined to determine the first loss information. For example, after determining the similarity between the plurality of first target sample features, the similarity can be multiplied by a preset negative value to obtain the first loss information. It can be understood that the first loss information being a negative number is only an example, and the present disclosure is not limited in this regard.

[0047] In operation S130, the to-be-trained model is trained according to the at least one first loss information.

[0048] According to the embodiments of the present disclosure, the parameters of the to-be-trained model can be adjusted to reduce the first loss information to obtain the trained model. As described above, the first loss information can be a negative number, and reducing the first loss information can increase the similarity between the first target sample features in the positive sample feature set and narrow the distance between the target sample feature of the sample character "how" and the target sample feature of the sample character "what". Thus, the subsequent character determined by the model according to the feature of the sample character "how" is more likely to be consistent with the subsequent character determined by the model according to the feature of the sample character "what".

[0049] In this embodiment, the preceding sample data of the target sample data can be different. A large model can determine the subsequent data based on the preceding sample data in the input sequence. By determining the characteristics of the different preceding data of the target sample data that appears multiple times in the sample data sequence, first loss information is determined, and the model is trained based on this first loss information. This allows similar semantic content to be more concentrated in the feature space and fully utilizes the contextual information of the input model's data sequence (such as sentences). Determining the loss based on the features of the data in the sequence achieves finer-grained semantic constraints, reducing model overfitting and gradient oscillations, improving training efficiency and model stability, and realizing controllable regularization and efficient training optimization at the feature level. This significantly improves the model's feature representation ability and downstream task performance. At the product level, the above method can be integrated into the pre-training or fine-tuning process, significantly improving the model's generalization ability and task transfer performance. It can significantly improve the model's representation consistency and robustness in tasks such as classification and retrieval without increasing additional inference costs.

[0050] Furthermore, through the embodiments of this disclosure, the corresponding first loss information is determined based on the positive sample feature set for the target sample data. From the perspective of separability of the feature space, the convergence of similar features is increased, enhancing feature separability and thus accelerating the pre-training process and generalization performance on downstream tasks. Therefore, taking the sample data sequence obtained from sample text as an example, it can improve the ability of the trained model to generate content required by the user based on the text, thereby improving the user experience.

[0051] As can be understood, the method of this disclosure has been explained above, and the training model of this disclosure will be further explained below.

[0052] Figure 2 This is a schematic diagram of the structure of a training model according to an embodiment of the present disclosure.

[0053] like Figure 2 As shown, the model to be trained may include multiple cascaded processing layers. These multiple processing layers may include n processing layers, where n is an integer greater than 1. The n processing layers may include an embedding layer 201, one or more decoder layers 210, and a final layer normalization layer 202. That is, the nth processing layer is the final layer normalization layer 202.

[0054] In some embodiments, the plurality of processing layers in the cascade can determine a plurality of candidate sample feature sequences of the sample data sequence in turn. The candidate sample feature sequence can include respective candidate sample features of the plurality of sample data. For example, the embedding layer 201 can determine a candidate sample feature sequence. The one or more decoding layers 210 can determine one or more candidate sample feature sequences. The layer normalization layer 202 can determine a candidate sample feature sequence.

[0055] The target sample feature sequence can be one of the plurality of candidate sample feature sequences. For example, the target sample feature sequence can be the candidate sample feature sequence determined by the last layer normalization layer. As shown in Figure 2 The candidate sample feature sequence determined by the layer normalization layer 202 can be the target sample feature sequence. By the embodiments of the present disclosure, the feature sequence determined by the last layer normalization layer is taken as the target sample feature sequence, which can improve the efficiency of model training, improve the content generation capability of large models, and improve user experience.

[0056] In some embodiments, in some embodiments of the above operation S110, the sample data sequence can be input into the model to be trained. As shown in Figure 2 The sample text t200 can be input into the model to be trained. The sample text t200 can include a plurality of sample characters. The plurality of sample characters can include sample character T1, sample character T2, …, sample character T16. The sample text t200 can be “Here is a PDF file on how they are used and what they look like.” The sample character T1 can be “Here”. The sample character T2 can be “is”. … The sample character T16 can be “.”.

[0057] As shown in Figure 2 The plurality of processing layers of the model to be trained can determine the target sample feature sequence e200. The target sample feature sequence e200 can include target sample feature e1, target sample feature e2, …, target sample feature e16. The target sample feature e1 can be a feature of the sample character T1. The target sample feature e2 can be a feature of the sample character T2. … The target sample feature e16 can be a feature of the sample character T16.

[0058] As shown in Figure 2 The model to be trained can further include an output layer 203. The candidate sample feature sequence determined by the nth processing layer can be input into the output layer 203 to obtain an output result.

[0059] It can be understood that the above describes the model to be trained of the present disclosure, and the loss of the feature layer of the present disclosure will be further described below.

[0060] In some embodiments, after obtaining the target sample feature sequence, the operation S120 described above can be performed to determine one or more first loss information for the one or more target sample data.

[0061] The first similarity between any two first target sample features in the positive sample feature set for the target sample data can be determined to obtain at least one first similarity. For example, the cosine similarity or inner product between the sample character “what” and the sample character “how” can be determined as the first similarity.

[0062] According to the at least one first similarity, the first loss information for the target sample data can be determined. For example, one first similarity can be taken as the first loss information. The sum of a plurality of first similarities can also be taken as the first loss information. For another example, the sum of a plurality of first similarities can also be processed by a logarithmic function to obtain the first loss information. According to the similarity between different features in the positive sample set to determine the loss information, the model can effectively reduce the distance between similar features and reduce the distance between the features of the positive sample. The class separability and the distance between classes of the model in the classification task (such as word segmentation) can be enhanced, and stronger feature separability can be achieved.

[0063] It can be understood that the above describes some ways of determining the first loss information according to the positive sample feature set, but the present disclosure is not limited thereto, and another loss information for the target sample data can also be determined according to the negative sample feature set for the target sample data.

[0064] In some embodiments, the method 100 described above can further include: determining at least one second loss information for the at least one target sample data according to at least one negative sample feature set for the at least one target sample data.

[0065] The negative sample feature set for the target sample data includes a plurality of second target sample features in addition to the plurality of first target sample features in the plurality of target sample features. As described above, the sample character "they" can be the target sample data. The sample character "how" and the sample character "what" are adjacent to the sample character "they" and are the preceding characters of the sample character "they". In addition to the target sample features of the sample character "how" and the sample character "what", the target sample features of other characters in the sample text t200 can be the second target sample features. For example, the target sample features of the sample character "Here", the sample character "is", the sample character "a", the sample character "PDF", the sample character "file", the sample character "on", the sample character "are", the sample character "used", the sample character "and", the sample character "look", the sample character "like", and the sample character "." can be the second target sample features, respectively. The set including these second target sample features can be the negative sample feature set for the sample character "they". It can be understood that the target sample feature of the sample character "they" itself can also be added to the negative sample feature set. According to the embodiments of the present disclosure, the other target sample features in addition to the positive sample feature set are used as the negative sample feature set, which can provide rich and effective constraints on the feature granularity for model training, and help to fully improve the performance of the model.

[0066] The second similarity between any two second target sample features in the negative sample feature set for the target sample data can be determined to obtain at least one second similarity. For example, the cosine similarity or the inner product between the sample character "here" and the sample character "is" can be determined as the second similarity.

[0067] According to the at least one second similarity, the second loss information for the target sample data can be determined. For example, one second similarity can be used as the second loss information. A plurality of second similarities can also be added to obtain an addition operation result as the second loss information. For another example, the sum of a plurality of second similarities can also be processed by using a logarithmic function to obtain the second loss information. According to the embodiments of the present disclosure, the loss information is determined according to the similarity between different features in the negative sample set, which can make the model effectively increase the distance between different class features and increase the distance between the features of the negative sample. The class separability and the inter-class distance of the model in the classification task are further enhanced, and stronger feature separability can be achieved.

[0068] Next, the operation S130 can be performed. In some embodiments of the operation S130, according to the at least one first loss information and the at least one second loss information, at least one feature similarity loss information can be determined. According to the at least one feature similarity loss information, a target loss can be determined. According to the target loss information, the to-be-trained model can be trained.

[0069] The feature similarity loss information for the target sample data can be obtained by subtracting the first loss information for the target sample data from the second loss information for the target sample data. According to one or more feature similarity loss information, a feature alignment loss information can be determined. For example, the feature alignment loss information can be determined by the following formula:

[0070] (Formula One)

[0071] is the feature alignment loss information. The negative sample feature set for the ith target sample data can be The positive sample feature set for the ith target sample data can be. For example, there are N second target sample features in the negative sample feature set. For example, there are P first target sample features in the positive sample feature set. N is an integer greater than 1. P is an integer greater than 1. is an integer greater than or equal to 1 and less than or equal to N. is an integer greater than or equal to 1 and less than or equal to N. is an integer greater than or equal to 1 and less than or equal to P. is an integer greater than or equal to 1 and less than or equal to P.

[0072] Log is a logarithmic function, for example, a logarithmic function with base 2. represents the sum of one or more second similarities in the negative sample feature set . represents the sum of one or more first similarities in the positive sample feature set . is the first loss information. is the second loss information. The feature similarity loss information can be for the target sample data. Average[] is an average function, and in Formula One, an average value between the plurality of feature similarity loss information of the plurality of target sample data in each round of training is determined as the feature alignment loss information. It can be understood that when the model is trained according to the first loss information and the second loss information, the first similarity can be taken as the first loss information without being multiplied by the preset negative value. It can also be understood that the way of determining the feature alignment loss information by using the average is only an example, and according to one or more feature similarity loss information, other ways (such as weighted average, median, etc.) can also be used to determine the feature alignment loss information.

[0073] According to the feature alignment loss information, the target loss information can be determined. For example, according to the output result and the label of the sample data sequence, the cross-entropy loss information can be determined. According to the cross-entropy loss information and the feature alignment loss information, the target loss information can be determined. Through the embodiments of the present disclosure, the feature alignment loss information is established according to the first loss information and the second loss information, and the first loss information and the second loss information can be jointly optimized to maximize the negative sample distance and minimize the positive sample distance, fully enhance the class separability of the corresponding word segmentation in the classification task and the distance between classes, and finally realize stronger feature separability.

[0074] The following will be combined Figure 3 The effect of training the model based on the feature alignment loss information. Figure 3 is a schematic diagram of the effect of the feature alignment loss information according to an embodiment of the present disclosure.

[0075] As Figure 3 indicated, the model to be trained can be trained by using the cross-entropy loss information until the cross-entropy loss information converges. The sample text t300 is input into the model trained by using the cross-entropy loss information, and a similarity matrix SM30 for the sample text t300 can be obtained. The sample text t300 can be the sample text t200 described above. The similarity in the similarity matrix SM30 can be the cosine similarity between the first sample features of two sample characters in the sample text t300. For example, the similarity sim301 can be the similarity between the first sample feature of the sample character "what" and the first sample feature of the sample character "how".

[0076] As Figure 3As shown, the model can also be trained using cross-entropy loss and feature alignment loss information until they converge. Inputting the sample text t300 into the model trained using cross-entropy loss and feature alignment loss information yields a similarity matrix SM31 for the sample text t300. The similarity in the similarity matrix SM31 can be the cosine similarity between the second sample features of two sample characters in the sample text t300. For example, the similarity sim311 can be the similarity between the second sample features of the sample character "what" and the second sample features of the sample character "how".

[0077] Understandable, such as Figure 3 In the two similarity matrices shown, the row and column labels are obtained by shifting the sample characters in the sample text t300 one position forward (towards the beginning of the sentence). For example, the row labels of similarity matrix SM30 are "is", "a", "PDF", "file", "on", "how", "they", "are", "used", "and", "what", "they", "look", "like", and ".". Therefore, the matrix elements indicated by the row and column labels "they" together represent the similarity between the features of the different preceding characters ("how" and "what") of the sample character "they".

[0078] In the similarity matrix SM30, the distinguishing effect between features of different semantics is poor. For example, similarity sim302 can be the similarity between the first sample feature of the sample character "what" and the first sample feature of the sample character "on". Both similarity sim302 and similarity sim301 are greater than 0.5, indicating that the distinguishing effect between the features of the sample characters "what", "how", and "on" is poor.

[0079] After introducing feature similarity alignment loss information, the discriminative power between features with different semantics is significantly improved, and features with the same semantics become more concentrated. For example, the similarity sim312 can be considered as the similarity between the second sample feature of the sample character "what" and the second sample feature of the sample character "on". A similarity sim312 is a value less than 0.5, while a similarity sim301 is a value greater than 0.5, indicating that the distance between the features of the sample character "what" and the features of the sample character "on" increases, and also indicating that the features of the sample character "what" and the features of the sample character "how" are more concentrated.

[0080] It is understood that the target loss information was determined based on the loss information determined from one of the feature sequences of multiple candidate samples. However, this disclosure is not limited to this; the target loss information can also be determined based on the feature sequences of multiple candidate samples, as will be explained below.

[0081] In some embodiments, the method 100 described above may further include: determining multiple third loss information for each of the multiple sample data based on multiple candidate sample features of each of the multiple sample data. The third loss information for the sample data is determined based on the similarity between the multiple candidate sample features of the sample data. The following will combine... Figure 4 Please provide an explanation.

[0082] Figure 4 This is a schematic diagram of multiple processing layers and output layers according to an embodiment of the present disclosure.

[0083] like Figure 4 As shown, the multiple processing layers include processing layers 1 to n. Processing layer 401 can be the embedding layer 201 mentioned above, processing layer 411 can be one or more decoding layers 210 mentioned above, and processing layer 402 can be the last normalization layer 202. Output layer 403 can be the output layer 203 mentioned above. Processing layer 401 can determine the candidate sample feature sequence e401 based on the sample text t400. Processing layer 411 can determine the candidate sample feature sequence e411 based on the candidate sample feature sequence e401. Processing layer 402 can determine the candidate sample feature sequence e402. That is, any processing layer from the second to the nth processing layer can determine the candidate sample feature sequence of that processing layer based on the candidate sample feature sequence determined in the previous processing layer. It can be understood that sample text t400 can be the sample text t200 mentioned above.

[0084] Candidate sample feature sequence e401 may include candidate sample features for each of the multiple sample characters in the sample text t200 determined by the first processing layer. Candidate sample feature sequence e411 may include candidate sample features for each of the multiple sample characters determined by the second processing layer. Candidate sample feature sequence e402 may include candidate sample features for each of the multiple sample characters determined by the nth processing layer.

[0085] In some embodiments, the third loss information for the sample data is determined by the following operations based on the similarity between multiple candidate sample features of the sample data: determining the m-th intermediate loss information based on the third similarity between the candidate sample features determined by the m-th processing layer in n processing layers and the nm-th subsequent sample features, where m is an integer greater than or equal to 1 and less than n, and the nm-th subsequent sample features are the nm-th candidate sample features determined by the nm-th processing layers after the m-th processing layer; and determining the third loss information for the sample data based on the first to the (n-1)-th intermediate loss information.

[0086] For example, for the sample character "Here", taking m=1 as an example, the candidate sample feature sequence e401 may include the candidate sample features of the sample character "Here" determined by the first processing layer. When m=1, the candidate sample features of the sample character "Here" in the candidate sample feature sequence e411, ... and the candidate sample features of the sample character "Here" in the candidate sample feature sequence e402 can be used as subsequent sample features of the candidate sample features of the sample character "Here" determined by the first processing layer.

[0087] The m-th processing layer determines the candidate sample features and the nm third similarities between the subsequent sample features. For each candidate sample feature determined by the m-th processing layer, subtracting the nm third similarities from a preset value yields nm intermediate sub-loss information. The sum of these nm intermediate sub-loss information can be used as the m-th intermediate loss information. Adding the n-1 intermediate loss information results in the third loss information specific to the sample data. The preset value can be 1.

[0088] Inter-layer similarity loss information can be determined by using multiple third loss parameters, each applied to multiple sample data. For example, the expected value of each third loss parameter can be determined. The inter-layer similarity loss information can be determined using the following formula. :

[0089] (Formula 2)

[0090] This represents the features of the candidate samples determined by the m-th processing layer. Features of candidate samples determined by the k-th processing layer The feature similarity between them. k can be an integer greater than or equal to m+1 and less than or equal to n. This represents the intermediate loss information. This represents the m-th intermediate loss information. This represents the third loss information for the sample data. E[] is the expectation function, which in Formula 2 represents the expected value of determining one or more third loss information, as the inter-layer similarity loss information. It can be understood that determining the expected value of one or more third loss information is only an example; it is also possible to determine the average value of one or more third loss information, as the inter-layer similarity loss information.

[0091] In this embodiment, the large model is a deep language model where the feature representations of each layer do not exist in isolation, but rather evolve gradually from shallow local patterns to deep semantic features. Each token, during the forward propagation of the entire model, should exhibit a continuous, stable, and semantically consistent structure across different levels of features, gradually converging towards its final label semantics. Each token can be associated with a corresponding label from the input stage; therefore, the token should maintain semantically relevant feature directions and intra-class consistency across shallow, mid, and deep layers. If cross-layer features shift or become inconsistent between layers during evolution, it will make it difficult for deep features to converge effectively, disrupting the continuity of feature expression. By determining inter-layer similarity loss information, features of the same token in different network layers are aligned, allowing them to exhibit a progressive evolutionary trajectory in the feature space without losing semantic attributes. By imposing consistency constraints on cross-layer features, the stability of the network's internal representation can be effectively enhanced, thereby accelerating model training and significantly improving the reliability of feature expression. This makes the model more relevant to the user input and the generated content, effectively improving the user experience.

[0092] As we have explained above, the method for determining inter-layer similarity loss information will now be explained below.

[0093] Figure 5 This is a schematic diagram illustrating the principle of model training according to an embodiment of the present disclosure.

[0094] like Figure 5 As shown, sample data sequence 500 can be input into the model to be trained, and processed by multiple processing layers P50 of the model to obtain multiple candidate sample feature sequences determined sequentially by the multiple processing layers. The multiple processing layers P50 may include the aforementioned embedding layer, decoding layer, and a final normalization layer. The candidate sample feature sequence determined by the last normalization layer among the multiple candidate sample feature sequences can be used as the target sample feature sequence e502. Sample data sequence 500 can be the aforementioned sample text 200, and may include the sample character "they" as the target sample data.

[0095] Based on at least one set of positive sample features for at least one target sample data, at least one first loss information can be determined for at least one target sample data. Based on at least one set of negative sample features for at least one target sample data, at least one second loss information can be determined for at least one target sample data. Based on at least one first loss information and at least one second loss information, at least one feature similarity loss information L51 is determined for at least one target sample data. Based on at least one feature similarity loss information, feature alignment loss information can be determined. It is understood that the method for determining feature alignment loss information can be referred to the explanation of Formula 1, which will not be repeated here. Next, based on the feature alignment loss information, target loss information can be determined, which will be explained in detail below.

[0096] The candidate sample feature sequence includes the candidate sample features of multiple sample data points in the sample data sequence. Based on the multiple candidate sample features of each sample data point, the inter-layer similarity loss information L52 can be determined. It can be understood that the method for determining the inter-layer similarity loss information can be referred to the explanation of Formula 2 above, and will not be repeated here.

[0097] In some embodiments, the output of the model to be trained is determined based on the feature sequence of the target sample. Cross-entropy loss information is determined based on the labels of the sample data sequence and the output of the model to be trained. The cross-entropy loss information, multiple third-party loss information, and at least one feature similarity loss information are weighted and fused. During the training phase, the label of the sample data sequence can be the sample data sequence itself.

[0098] like Figure 5 As shown, by processing the target sample feature sequence e502 using the output layer 503 of the model to be trained, the output result o500 can be obtained. Based on the output result o500 and the sample data sequence 500, the cross-entropy loss information L53 can be determined. By weighted and fused the cross-entropy loss information, the inter-layer loss information determined by multiple third loss information, and the feature alignment loss information determined by at least one feature similarity loss information, the target loss information can be obtained. For example, the target loss information can be determined using the following formula. :

[0099] (Formula 3)

[0100] Information can be lost due to cross-entropy. Loss information can be used for feature alignment. It can provide information about interlayer loss. It can be the weight of the feature alignment information, and can be a value that is not less than 0 and not greater than 1. These can be weights for inter-layer loss information, and can be values ​​that are neither less than 0 nor greater than 1. In one example, .

[0101] The parameters of multiple processing layers can be adjusted based on the target loss information. The parameters of the output layer can be adjusted based on the cross-entropy loss information. Through the embodiments of this disclosure, the cross-entropy loss information can improve the basic accuracy of the language model in the word prediction task and serves as an important supervisory signal throughout the training process. The feature alignment loss information term enhances intra-class compactness and inter-class separability by imposing aggregation constraints on features of similar word segments, thereby strengthening the semantic expressive power at the token level. The inter-layer similarity loss information can constrain the features of the same token in different processing layers to maintain semantic consistency, making the representation more stable, continuous, and structured during inter-layer evolution and preventing deep features from deviating from their label semantics.

[0102] It is understood that the above description uses examples of training a model to be trained based on first loss information and second loss information, and training a model to be trained based on first loss information, second loss information, and third loss information, to illustrate this disclosure. However, this disclosure is not limited thereto. In some embodiments, training a model to be trained based on at least one first loss information may include: determining target loss information based on at least one second loss information and at least one of multiple third loss information and at least one first loss information; and training the model to be trained based on the target loss information. That is, the model to be trained may also be trained based on first loss information and third loss information. For example, when training a model to be trained based on first loss information and third loss information, the first loss information may be a negative number. The inter-layer loss information determined by multiple third loss information and the first loss information may be weighted and fused to obtain the target loss information for training the model to be trained.

[0103] It is understood that the above description uses sample text as an example to illustrate this disclosure. However, this disclosure is not limited thereto, and the sample data sequence may be obtained from at least one of sample text, sample image, sample audio, and sample video.

[0104] In some embodiments, the sample image can be segmented to obtain multiple sample image patches. Based on these multiple patch images, a sample image patch sequence can be obtained, serving as the sample data sequence. For example, the sample image can be segmented into a 4×4 sample image patch array. Each row of this array contains four sample image patches. The four rows of patches are then concatenated sequentially to obtain a 1×16 sample image patch sequence, which serves as the sample data sequence. Except for the first sample image patch, the image similarity between any two sample image patches can be determined. If the image similarity between two image patches is greater than a preset image similarity threshold, one of these two image patches can be designated as the target image patch. In the sample image patch sequence, two adjacent preceding image patches can be identified. The target image features of these two preceding image patches can be added to the positive sample feature set for the target image patch as the first target image feature. Other image features besides the target image features of these two preceding image patches can be added to the negative sample feature set for the target image patch as the second target image feature. The preset image similarity threshold can be a value greater than 0.9 and less than or equal to 1.

[0105] In some embodiments, the sample audio can be transformed to obtain a sample audio sequence comprising multiple discrete sample audio segments, which serves as the sample data sequence. The audio segment similarity (e.g., cosine similarity) between any two sample audio segments is determined. If the similarity between two sample audio segments is greater than or equal to a preset audio segment similarity threshold, one of these two sample audio segments can be designated as the target audio segment. Within the sample audio segment sequence, two adjacent preceding audio segments can be identified. The target audio features of these two preceding audio segments can be added to the positive sample feature set for the target audio segment as the first target audio feature. Other audio features besides the target image features of each of the two preceding audio segments can be added to the negative sample feature set for the target audio segment as the second target audio feature.

[0106] In some embodiments, the sample video can be frame-segmented to obtain multiple video frames. Video frames are image data, and the processing method for sample images described above can be used to process the video frames, resulting in an image block sequence for each video frame. Multiple image block sequences are then concatenated to obtain a video image block sequence, which serves as the sample data sequence. It is understood that the method for determining the target sample data, positive sample feature set, and negative sample feature set in the video image block sequence is the same as or similar to the method for determining the target sample data, positive sample feature set, and negative sample feature set in the sample image block sequence, and will not be elaborated upon here.

[0107] As you can understand, the training method of this disclosure has been explained above, and the inference method of the model will be explained below.

[0108] Figure 6 This is a schematic flowchart of a reasoning method according to an embodiment of the present disclosure.

[0109] like Figure 6 As shown, method 600 may include operation S610.

[0110] In operation S610, the data sequence to be processed is input into the target model to obtain the response result.

[0111] The target model can be trained according to the methods provided in this disclosure. For example, the target model can be trained according to method 100.

[0112] The data sequence to be processed is obtained from at least one of the following: text to be processed, image to be processed, audio to be processed, and video to be processed.

[0113] It is understood that the method of this disclosure has been described above, and the apparatus of this disclosure will be described below.

[0114] Figure 7 This is a block diagram of a model training apparatus according to an embodiment of the present disclosure.

[0115] like Figure 7 As shown, the device 700 may include a first acquisition module 710, a first determination module 720, and a training module 730.

[0116] The first acquisition module 710 is used to input the sample data sequence into the model to be trained to obtain the target sample feature sequence. The sample data sequence includes multiple sample data, and the target sample feature sequence includes the target sample features of each of the multiple sample data.

[0117] The first determining module 720 is used to determine at least one first loss information for at least one target sample data based on at least one positive sample feature set for at least one target sample data. The target sample data is determined based on multiple sample data whose data similarity is greater than or equal to a preset data similarity threshold. The positive sample feature set for the target sample data includes the first target sample features of each of the preceding sample data of the target sample data.

[0118] Training module 730 is used to train the model to be trained based on at least one first loss information. The sample data sequence is obtained from at least one of sample text, sample images, sample audio, and sample video.

[0119] In some embodiments, the model to be trained includes multiple cascaded processing layers, and the target sample feature sequence is one of multiple candidate sample feature sequences determined sequentially by the multiple processing layers. The candidate sample feature sequence includes candidate sample features of each of the multiple sample data. The apparatus further includes at least one of the following: a second determining module, configured to determine at least one second loss information for at least one target sample data based on at least one negative sample feature set for at least one target sample data, wherein the negative sample feature set for the target sample data includes multiple second target sample features other than multiple first target sample features among the multiple target sample features; and a third determining module, configured to determine multiple third loss information for each of the multiple sample data based on the multiple candidate sample features of each of the multiple sample data.

[0120] In some embodiments, the training module includes: a first determining submodule, configured to determine target loss information based on at least one of at least one second loss information and a plurality of third loss information and at least one first loss information; and a training submodule, configured to train a model to be trained based on the target loss information, wherein the third loss information for the sample data is determined based on the similarity between features of a plurality of candidate samples of the sample data.

[0121] In some embodiments, the first determining module includes: a second determining submodule, configured to determine a first similarity between any two first target sample features in the positive sample feature set of the target sample data, to obtain at least one first similarity; and a third determining submodule, configured to determine first loss information for the target sample data based on at least one first similarity.

[0122] In some embodiments, the second determining module includes: a fourth determining submodule, configured to determine a second similarity between any two second target sample features in the negative sample feature set for the target sample data, to obtain at least one second similarity; and a fifth determining submodule, configured to determine second loss information for the target sample data based on at least one second similarity.

[0123] In some embodiments, the multiple processing layers are n processing layers, where n is an integer greater than 1. The third loss information for the sample data is determined by performing related operations based on the similarity between multiple candidate sample features of the sample data through the following sub-modules: a sixth determining sub-module, used to determine the m-th intermediate loss information based on the candidate sample features determined by the m-th processing layer in the n processing layers and the nm third similarities between the nm subsequent sample features, where m is an integer greater than or equal to 1 and less than n, and the nm subsequent sample features are the nm candidate sample features determined by the nm processing layers after the m-th processing layer; a seventh determining sub-module, used to determine the third loss information for the sample data based on the first to the (n-1)-th intermediate loss information.

[0124] In some embodiments, the first determining submodule includes: a first determining unit, configured to determine at least one feature similarity loss information for at least one target sample data based on at least one first loss information and at least one second loss information; and a second determining unit, configured to determine target loss information based on at least one feature similarity loss information.

[0125] In some embodiments, the first determining unit includes a subtraction operation subunit, used to subtract the first loss information of the target sample data from the second loss information of the target sample data to obtain feature similarity loss information of the target sample data.

[0126] In some embodiments, the second determining unit includes: a first determining subunit, configured to determine the output result of the model to be trained based on the target sample feature sequence; a second determining subunit, configured to determine cross-entropy loss information based on the label of the sample data sequence and the output result of the model to be trained; and a fusion subunit, configured to weightedly fuse the cross-entropy loss information, multiple third loss information and at least one feature similarity loss information to obtain target loss information.

[0127] In some embodiments, the nth processing layer is the last normalization layer of the model to be trained, and the target sample feature sequence is the candidate sample feature sequence determined by the nth processing layer.

[0128] Figure 8 This is a block diagram of a reasoning apparatus according to another embodiment of the present disclosure.

[0129] like Figure 8 As shown, the device 800 may include a second acquisition module 810.

[0130] The second acquisition module is used to input the data sequence to be processed into the target model and obtain the response result.

[0131] The target model is trained using the model training device provided in this disclosure.

[0132] The data sequence to be processed is obtained from at least one of the following: text to be processed, image to be processed, audio to be processed, and video to be processed.

[0133] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0134] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0135] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0136] like Figure 9 As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 902 or a computer program loaded from storage unit 908 into random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.

[0137] Multiple components in device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of monitors, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0138] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as at least one of the model training methods and inference methods. For example, in some embodiments, at least one of the model training methods and inference methods can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of at least one of the model training methods and inference methods described above can be performed. Alternatively, in other embodiments, the computing unit 901 may be configured by any other suitable means (e.g., by means of firmware) to perform at least one of the model training method and the inference method.

[0139] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard parts (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0140] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0141] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory (EPROM) or flash memory, optical fiber, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0142] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a cathode ray tube (CRT) monitor or a liquid crystal display (LCD)); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0143] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0144] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.

[0145] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0146] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A model training method, comprising: inputting a sample data sequence into a to-be-trained model to obtain a target sample feature sequence, the sample data sequence comprising a plurality of sample data, and the target sample feature sequence comprising a plurality of target sample features of the sample data respectively; determining at least one first loss information for at least one target sample data according to at least one positive sample feature set for the target sample data, the target sample data being determined according to a plurality of sample data in which data similarity is greater than or equal to a preset data similarity threshold, and the positive sample feature set for the target sample data comprising a plurality of first target sample features of a plurality of preceding sample data of the target sample data in the target sample features; training the to-be-trained model according to at least one first loss information, the sample data sequence being obtained according to at least one of sample text, sample image, sample audio and sample video.

2. The method of claim 1, wherein, the to-be-trained model comprising a plurality of processing layers in cascade, and the target sample feature sequence being one of a plurality of candidate sample feature sequences determined by the processing layers in sequence, and each candidate sample feature sequence comprising a plurality of candidate sample features of the sample data respectively, the method further comprising at least one of: determining at least one second loss information for at least one target sample data according to at least one negative sample feature set for the target sample data, the negative sample feature set for the target sample data comprising a plurality of second target sample features other than the first target sample features in the target sample features; determining a plurality of third loss information for a plurality of sample data respectively according to a plurality of candidate sample features of the sample data.

3. The method of claim 2, wherein, the training the to-be-trained model according to at least one first loss information comprises: determining target loss information according to at least one of at least one second loss information and a plurality of third loss information and at least one first loss information; training the to-be-trained model according to the target loss information, the third loss information for the sample data being determined according to similarity between a plurality of candidate sample features of the sample data.

4. The method of claim 1, wherein, the determining at least one first loss information for at least one target sample data according to at least one positive sample feature set for the target sample data comprises: determining a first similarity between any two first target sample features in the positive sample feature set for the target sample data to obtain at least one first similarity; determining the first loss information for the target sample data according to at least one first similarity.

5. The method of claim 2, wherein, the determining at least one second loss information for at least one target sample data according to at least one negative sample feature set for the target sample data comprises: determining a second similarity between any two second target sample features in the negative sample feature set for the target sample data to obtain at least one second similarity; According to at least one of the second similarities, second loss information for the target sample data is determined.

6. The method of claim 3, wherein, The plurality of processing layers are n processing layers, n being an integer greater than 1, Third loss information for the sample data is determined according to similarities between a plurality of candidate sample features of the sample data by: According to n-m third similarities between a candidate sample feature determined by an mth processing layer in the n processing layers and n-m subsequent sample features, mth intermediate loss information is determined, m being an integer greater than or equal to 1 and less than n, the n-m subsequent sample features being n-m candidate sample features determined by n-m processing layers after the mth processing layer; According to the first intermediate loss information to the n-1th intermediate loss information, third loss information for the sample data is determined.

7. The method of claim 5, wherein, According to at least one of the second loss information and the third loss information, and at least one of the first loss information, target loss information is determined. According to at least one of the first loss information and at least one of the second loss information, at least one feature similarity loss information for at least one target sample data is determined. According to at least one of the feature similarity loss information, the target loss information is determined.

8. The method of claim 7, wherein, According to at least one of the first loss information and at least one of the second loss information, at least one feature similarity loss information for at least one target sample data is determined. Using the second loss information for the target sample data, the first loss information for the target sample data is subtracted to obtain the feature similarity loss information for the target sample data.

9. The method of claim 7, wherein, According to at least one of the feature similarity loss information, the target loss information is determined. According to the target sample feature sequence, an output result of the to-be-trained model is determined. According to the label of the sample data sequence and the output result of the to-be-trained model, cross-entropy loss information is determined. The cross-entropy loss information, the third loss information and the at least one feature similarity loss information are weighted and fused to obtain the target loss information.

10. The method of claim 6, wherein, The nth processing layer is the last layer normalization layer of the to-be-trained model, and the target sample feature sequence is a candidate sample feature sequence determined by the nth processing layer.

11. An inference method, comprising: inputting a to-be-processed data sequence into a target model to obtain a response result, wherein the target model is trained according to the method of any one of claims 1 to 10, the to-be-processed data sequence is obtained according to at least one of to-be-processed text, to-be-processed image, to-be-processed audio and to-be-processed video.

12. A model training apparatus, comprising: a first obtaining module configured to input a sample data sequence into a to-be-trained model to obtain a target sample feature sequence, the sample data sequence comprising a plurality of sample data, and the target sample feature sequence comprising target sample features of the plurality of sample data respectively; a second obtaining module configured to determine a first loss information for the sample data according to a similarity between a first sample feature of the sample data and a second sample feature of the sample data, the first sample feature being determined by a first processing layer of the to-be-trained model, and the second sample feature being determined by a second processing layer of the to-be-trained model, the first processing layer being different from the second processing layer; The first determining module is configured to determine at least one first loss information for at least one target sample data according to at least one positive sample feature set of the at least one target sample data, the target sample data being determined according to a plurality of sample data whose data similarity is greater than or equal to a preset data similarity threshold, and the positive sample feature set of the target sample data including a plurality of preceding sample data of the target sample data in the plurality of target sample features. The training module is configured to train the to-be-trained model according to the at least one first loss information. The sample data sequence is obtained according to at least one of sample text, sample image, sample audio and sample video.

13. An inference device, comprising: The second obtaining module is configured to input a to-be-processed data sequence into a target model to obtain a response result. The target model is trained by the device of claim 12. The to-be-processed data sequence is obtained according to at least one of to-be-processed text, to-be-processed image, to-be-processed audio and to-be-processed video.

14. An electronic device, comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 11.

15. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1 to 11.

16. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1 to 11.