Training method and device of cross-language alignment model, and electronic equipment
By evaluating the quality and difficulty of sentence pairs, and through hierarchical training and dynamic adjustment, the problem of sample imbalance in the training of multilingual large models is solved, and the accuracy and stability of cross-lingual alignment models are improved, especially the alignment effect in low-resource languages and mixed contexts.
Patent Information
- Application Number
- CN202611561528.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-10
- Publication Date
- 2026-11-10
AI Technical Summary
Existing multilingual large-scale model training suffers from imbalanced sample quality, a high proportion of noisy samples, and insufficient low-resource language samples. This causes the model to prematurely favor high-resource languages and simple samples, resulting in unstable cross-language alignment and making the model prone to convergence instability and overfitting.
By conducting quality and difficulty assessments on sentence pairs, the corpus is divided into multiple levels, and multiple training stages are set up. The proportion of high-quality samples is gradually reduced while the proportion of high-difficulty samples is increased. Reassessment and stratification are performed at each stage, and the sample level is adjusted using a weighted loss function and dynamic confidence to optimize the training process.
It improves the accuracy and stability of cross-language alignment models, reduces gradient fluctuations and noise pollution in the early stages of training, improves the dynamic balance of multilingual learning, and enhances the adaptability to low-resource languages and mixed contexts.
Smart Images

Figure CN123070097A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a training method and apparatus for a cross-language alignment model, an electronic device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] Cross-linguistic alignment is a fundamental capability in multilingual large-scale models, machine translation, cross-linguistic retrieval, cross-linguistic question answering, and multilingual knowledge transfer. Its core goal is not simply to translate one language into another, but to establish stable and reusable semantic correspondences between different languages, so that the same semantic content falls into a consistent or comparable representation space as much as possible under different linguistic representations.
[0003] The training of existing multilingual large-scale models typically relies on multiple data sources, including manually generated parallel corpora, machine-translated pseudo-parallel corpora, sentence pairs mined from web pages, and back-translated data from monolingual corpora. However, in practical industrial applications, the data scale, distribution, writing systems, syntactic structures, lexical variations, and cultural expressions of different languages vary significantly. These objective differences lead to a series of challenges, such as extremely imbalanced training sample quality, a high proportion of noisy samples, and a severe shortage of low-resource language samples. In this context, if all collected samples are directly mixed for model training, the model is very likely to prematurely favor high-resource languages and easy-to-align simple samples, resulting in highly unstable cross-language alignment performance.
[0004] To address the aforementioned issues with multilingual training data, the most readily available technologies in the industry currently employ the following strategies: Static threshold filtering: A common existing technique is to perform static threshold filtering on the collected parallel corpus, and then directly mix all sentence pairs that pass the fixed threshold for training language representation models or translation models.
[0005] Fixed sampling ratio method: Another existing technology is to construct a pseudo-parallel corpus through machine translation and then conduct multilingual mixed training according to a pre-set fixed sampling ratio.
[0006] Basic Curriculum Learning: Some methods adopt the general idea of curriculum learning. However, the arrangement of their courses is usually based solely on simple sentence length, word frequency, or manual rules, and is not linked to cross-linguistic sentence pair confidence, difficulty of complex samples, or real-time model feedback during training.
[0007] The aforementioned existing technologies have the following significant drawbacks when dealing with large-scale, high-noise multilingual corpora: 1. Early training space is easily contaminated: Since the existing technology only uses a single static threshold screening, semantic shifts, term mismatches, translation jargon, language recognition errors and web page noise hidden in the candidate sentence pairs are very easy to be mixed into the training set, and cause serious contamination to the model's representation space in the early stage of training.
[0008] 2. Long-tail and difficult samples are consistently underestimated: Due to the huge differences in data quality across different languages, domains and sources, the strategy of using a fixed sampling ratio leads to high-resource languages and high-confidence samples having a long-term dominant advantage; while the role of low-resource languages, cross-script samples, long sentence samples and code switching samples is consistently underestimated and marginalized.
[0009] 3. The model is prone to convergence instability and overfitting: Because the existing training sequence lacks a scientific progression mechanism from easy to difficult, the model is strongly disturbed by a large number of high-difficulty and noisy samples before it has formed stable cross-linguistic semantic anchors. This easily leads to serious problems such as convergence instability, gradient oscillation, or overfitting to the surface translation pattern.
[0010] 4. Lack of feedback and error correction mechanisms: Due to the severe lack of dynamic re-scoring mechanisms and hierarchical adjustment methods in the current technology during the training process, changes in sample quality, improvements in the model's cross-language capabilities, and objective differences in learning progress between different languages cannot be fed back into the subsequent training scheduling strategy in a timely and effective manner. Summary of the Invention
[0011] This application provides a training method, apparatus, and electronic device for a cross-language alignment model, which can improve the accuracy, stability, and robustness of the trained cross-language alignment model.
[0012] In a first aspect, embodiments of this application provide a method for training a cross-language alignment model, including: Obtain a corpus containing multiple sentence pairs; For each sentence pair, a quality assessment and a difficulty assessment are performed. Based on the assessment results, the corpus is divided into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer. Multiple training phases are set up, and each phase extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process. After each training phase, a subset of samples in the corpus is re-evaluated based on the current alignment model, and the sample hierarchy is updated according to the re-evaluation results for use in subsequent training phases, until the preset termination condition is met.
[0013] In one embodiment, the evaluation result includes a comprehensive confidence level, and the quality assessment includes: The basic confidence of the sentence pair is calculated based on at least one of the semantic similarity, source reliability, length matching degree, and terminology consistency. When the base confidence score is within the fuzzy boundary interval, calculate the structural consistency score and / or cyclic consistency score of the sentence pair; based on the base confidence score, structural consistency score and / or cyclic consistency score, determine the overall confidence score of the sentence pair; When the basic confidence level is not within the fuzzy boundary interval, the basic confidence level is used as the comprehensive confidence level.
[0014] In one embodiment, the evaluation result includes a static difficulty score, and the difficulty evaluation includes: calculating the static difficulty score of the sentence pair based on at least one of the sentence pair's length features, word form variation features, word order difference features, and code mixing features.
[0015] In one embodiment, the plurality of layers further includes a medium sample layer and a noise layer, wherein samples in the noise layer are not used for training.
[0016] In one embodiment, the step of extracting samples from the plurality of levels according to a preset strategy includes: Samples are taken from each level according to a preset mixing ratio, and the preset mixing ratio is adjusted as the stage progresses.
[0017] In one embodiment, the step of extracting samples from the plurality of levels according to a preset strategy includes: Within each level, the sampling probability of the language pair is determined based on the sample size of the language pair within that level.
[0018] In one embodiment, the training employs a weighted loss function, wherein the weight of a sample is associated with the confidence level of the sample and the current stage number.
[0019] In one embodiment, the re-evaluation of a subset of samples in the corpus based on the current alignment model includes: Using an exponential moving average copy of the current alignment model, the semantic consistency and alignment loss moving average of a subset of samples in the corpus are recalculated. Based on the recalculated semantic consistency and alignment loss moving average, the dynamic confidence and dynamic difficulty scores of some samples in the corpus are determined. The sample hierarchy is updated based on the dynamic confidence and dynamic difficulty scores of some samples in the corpus.
[0020] In one embodiment, updating the sample hierarchy based on the re-evaluation result includes: Based on the entry and exit thresholds, the level of a sample is adjusted after the sample meets the migration conditions for multiple consecutive evaluation cycles.
[0021] Secondly, embodiments of this application also provide a training apparatus for a cross-language alignment model, comprising: The corpus acquisition module is used to acquire a corpus set containing multiple sentence pairs; The hierarchical division module is used to perform quality and difficulty assessments on each sentence pair, and divide the corpus into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer, based on the assessment results. The model training phase is used to set up multiple training phases. Each phase extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process. The feedback update module is used to re-evaluate a portion of the samples in the corpus based on the current alignment model after each training stage, and update the sample hierarchy according to the re-evaluation results for use in subsequent training stages, until the preset termination condition is met.
[0022] Thirdly, embodiments of this application also provide an electronic device, including: Memory is used to store executable instructions for a computer; The processor, when executing computer-executable instructions stored in the memory, implements the training method for the cross-language alignment model described above.
[0023] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the training method for the cross-language alignment model described above.
[0024] Fifthly, embodiments of this application also provide a computer program product, which includes computer-executable instructions stored in a computer-readable storage medium; The training method for the cross-language alignment model described above is implemented when the processor of the electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions.
[0025] The technical solution provided in this application assesses the quality and difficulty of sentence pairs. Based on the assessment results, the corpus is stratified according to quality and difficulty. Multiple training stages are set up, during which the proportion of high-quality samples gradually decreases while the proportion of high-difficulty samples gradually increases. After each training stage, reassessment and stratification are performed for subsequent training stages until completion. Thus, in the early stages of model training, the introduction of low-quality samples can be reduced, improving the stability of the initial alignment process, reducing gradient fluctuations and representation degradation risks in the early stages of training, and reducing invalid computation of obviously noisy samples. After each training stage, reassessment and sample stratification can feed back changes in model capabilities and differences in language resources to subsequent training scheduling, thereby improving the accuracy of the model. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating a training method for a cross-language alignment model provided in an embodiment of this application; Figure 2 yes Figure 1 Detailed flowchart of step S140 in the corresponding embodiment; Figure 3 This is a block diagram of a training device for a cross-language alignment model provided in an embodiment of this application; Figure 4 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.
[0028] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0029] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0030] Figure 1 This is a flowchart illustrating a training method for a cross-language alignment model provided in an embodiment of this application. Figure 1 As shown, the method includes: Step S110: Obtain a corpus containing multiple sentence pairs.
[0031] Specifically, cross-linguistic sequences are extensively collected from human-translated corpora, machine-translated pseudo-parallel corpora, webpage-aligned sentence pairs, terminology database-expanded sentence pairs, and back-translated samples to form a massive candidate sentence pair pool. Lightweight cleaning operations are performed on the candidate sentence pair pool, including language recognition, script normalization, punctuation and number standardization, word segmentation, deduplication, entity anchor extraction, and hard verification of cross-linguistic length ratios. This process eliminates sentence pairs with empty sentences, language identification errors, complete repetitions, script anomalies, and significant length ratio distortions, resulting in standardized sentence pairs with a unified representation. A corpus containing multiple sentence pairs can be considered a preprocessed corpus containing multiple standardized sentence pairs.
[0032] Step S120: Perform quality and difficulty assessments on each sentence pair, and divide the corpus into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer, based on the assessment results.
[0033] In one embodiment, the evaluation result may include the overall confidence score C_i of the sentence pair. The overall confidence score can be obtained by calculating a basic confidence score for the sentence pair based on at least one of semantic similarity, source reliability, length matching, and terminology consistency. When the basic confidence score is within a fuzzy boundary interval, a structural similarity score and / or a cycle consistency score are calculated for the sentence pair; based on the basic confidence score, the structural consistency score, and / or the cycle consistency score, the overall confidence score of the sentence pair is determined. When the basic confidence score is not within a fuzzy boundary interval, the basic confidence score is used as the overall confidence score.
[0034] Among them, semantic similarity The source sentence vector output by the dual encoder can be calculated using a lightweight dual encoder model. With the target sentence vector The cosine similarity is obtained by truncation and normalization, i.e. .
[0035] Source reliability The accuracy of sentence pairs can be pre-calibrated and normalized to [0,1] based on their source type and historical sampling accuracy: for example, 0.95–1.00 can be used for manually reviewed professional parallel corpora, 0.85–0.95 for terminology database expanded sentence pairs, 0.60–0.85 for automatically aligned webpage sentence pairs, and 0.50–0.80 for machine translation or back-translation generated sentence pairs; or the source reliability can be updated according to the ratio of the number of semantically equivalent sentence pairs in the most recent sampling of the same source to the total number of sampled sentence pairs. Length matching degree S_len You can first calculate the symmetry length ratio ,in , These are the effective lexical units of the source and target sentences after word segmentation, respectively, and then calculated. , This represents the median of the symmetric length ratio of corresponding language pairs on reliable parallel corpora. This is the scale parameter.
[0036] Terminology Consistency Based on a pre-defined bilingual terminology list or entity mapping table, the weighted coverage rate of correctly mapped identifiable terms in the source sentence to the target sentence can be calculated. When a sentence pair does not contain identifiable terms, the item is marked as missing and the weights of the remaining available features are renormalized.
[0037] Baseline confidence level Calculated using a weighted fusion method: And each The sum is 1; when missing features exist, only the available items are considered. Renormalize. Weights representing semantic similarity Weights representing the reliability of the source. The weights representing the length matching degree The weight representing terminological consistency. As one example, , , , Take values of 0.55, 0.20, 0.10, and 0.15 respectively; for , , , The sentence is correct. The weights and length ratio parameters can be obtained through grid search or Bayesian optimization on a validation set with artificial quality labels, with the goal of maximizing the AUC or F1 value that distinguishes correctly aligned sentence pairs from incorrectly aligned sentence pairs.
[0038] The baseline confidence level is within the preset fuzzy boundary range. The sample triggers deep neural fine screening, calls the sequence alignment algorithm to calculate the structural consistency score S_struct, and selectively calls the lightweight translation model to calculate the cycle consistency (back-translation) score S_cycle.
[0039] The final overall confidence score C_i is a weighted fusion of the base confidence score, structural consistency score, and cycle consistency score. If the sample does not enter the fuzzy boundary interval, then C_i = C_base; if the sample enters the fuzzy boundary interval and obtains a structural consistency score S_struct and a cycle consistency score S_cycle, then C_i = β_base·C_base + β_struct·S_struct + β_cycle·S_cycle, where the sum of each β is 1. As an example, β_base, β_struct, and β_cycle are set to 0.50, 0.25, and 0.25, respectively; if a certain item is not calculated, the weights of the available items are renormalized. S_struct calculates the soft alignment result based on the word similarity matrix of the source and target sentences, and weights it by the average similarity of aligned words, bidirectional coverage, and path cost allowing limited word order jumps, thus avoiding imposing strict monotonic alignment constraints on languages with large word order differences. S_cycle is obtained by normalizing the cosine similarity of the sentence vectors of the back-translated sentence and the original source sentence after back-translating the target sentence into the source language. The β coefficient is determined based on the manually labeled validation set. In addition to linear weighting, the basic confidence and comprehensive confidence can also use logistic regression, gradient boosting trees, or lightweight multilayer perceptrons to map each scoring feature to the probability of correct sentence pair alignment. The training labels are obtained from manual sampling results.
[0040] In one embodiment, the evaluation result further includes a static difficulty score, wherein the difficulty evaluation includes calculating the static difficulty score of the sentence pair based on at least one of the sentence pair's length features, word form variation features, word order difference features, and code mixing features.
[0041] The length feature can be represented as: ; Word inflection features can be used The expression refers to the average proportion of non-dictionary basic word forms or words with inflection / derivation markers in the source and target sentences; word order differences can be... The terminology used to represent the word order dissimilarity is the normalized result of 5%–95% quantile truncation of the alignment cross-entropy on the validation set. Code hybrid features can be used... The term "non-subject language lexical units" refers to the proportion of non-subject language lexical units to the total number of lexical units.
[0042] The formula for calculating the static difficulty score can be expressed as follows: , and the sum of all λ is 1. As an embodiment, the values of each λ are 0.25, 0.20, 0.15, and 0.40 respectively; when the four features of a certain sentence pair are 0.40, 0.30, 0.10, and 0.60 respectively, D_i=0.415, which belongs to medium difficulty. L_0, L_1, quantiles and λ are configured separately for each language pair, where L_0 represents the lower limit threshold of length difficulty, and L_1 represents the upper limit threshold of length difficulty; for low-resource languages that lack a reliable morphological analyzer, the average token expansion rate after subword segmentation can be used to replace d_morph. It should be noted that when any one of the length feature, morphological variation feature, word order difference feature and code mixing feature is missing, the remaining several features can be used to participate in the calculation of the static difficulty score.
[0043] The comprehensive confidence is used to characterize the credibility / quality level of a sentence pair as a training sample, and a higher score indicates that the sentence pair is more likely to be a correct semantic alignment. The static difficulty score is used to characterize the complexity / learning difficulty of the sentence pair itself, and a higher score indicates that the sentence pair is more difficult for the model to learn.
[0044] In an embodiment, all sentence pairs can be divided into a plurality of sets based on the comprehensive confidence and static difficulty score of each sentence pair. The plurality of sets may be referred to as a plurality of tiers, and the plurality of tiers at least include a high-quality (low-difficulty) sample tier and a high-difficulty (low-quality) sample tier. A noise tier and a medium sample tier can also be included as needed. The medium sample tier refers to a sample tier with medium quality and difficulty.
[0045] Specifically, samples with C_i<0.30 can first be classified into the noise tier and eliminated; samples with C_i≥0.80 and D_i≤0.35 are classified into the high-quality (low-difficulty) sample tier; samples with 0.55≤C_i<0.80 and D_i≤0.70, or C_i≥0.80 and 0.35<D_i≤0.70 are classified into the medium sample tier; samples with 0.30≤C_i<0.55, or D_i>0.70 and C_i≥0.55 are classified into the low-quality (high-difficulty) sample tier. It should be noted that the high quality, low quality, high difficulty, and low difficulty described in the present application are all relative.
[0046] For example, if a sentence pair has C_i=0.87 and Di_i=0.28, it is classified into the high-quality (low-difficulty) sample layer; if C_i=0.68 and Di_i=0.52, it is classified into the medium-quality sample layer; if C_i=0.47 and Di_i=0.76, it is classified into the low-quality (high-difficulty) sample layer; and if C_i=0.22, it is classified into the noise layer regardless of the value of Di_i. These rules cover all samples with C_i ≥ 0.30, and the layers are mutually exclusive. The threshold can be jointly determined on the validation set based on the target size of each layer, the accuracy of manual sampling, and the training convergence metric, and can be set separately for different language pairs.
[0047] Step S130: Set up multiple training stages. Each stage extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process.
[0048] For example, K training phases can be set, such as a basic alignment phase, a capability ramp-up phase, and a long-tail generalization phase. For the k-th phase, a hierarchical mixing objective P_k = [p_easy^(k), p_mid^(k), p_hard^(k)] is set, where the sum of each component is 1. p_easy^(k) represents the sampling ratio of high-quality (low-difficulty) samples in the k-th phase, p_mid^(k) represents the sampling ratio of medium-quality samples in the k-th phase, and p_hard^(k) represents the sampling ratio of low-quality (high-difficulty) samples in the k-th phase. Samples are taken from each level according to the preset mixing ratio, and the preset mixing ratio is adjusted as the phase progresses. As k increases, the proportion of high-quality (easy) samples is gradually decreased while the proportion of high-difficulty samples is increased. The proportion of medium-quality samples can be increased first and then decreased, or it can be continuously increased. The datasets for each phase are not mutually exclusive; the same sample can appear repeatedly in multiple phases with different sampling probabilities. As an example, P_k for the three stages is set to [0.70, 0.25, 0.05], [0.40, 0.40, 0.20], and [0.20, 0.35, 0.45] respectively. To avoid high-resource languages continuously dominating training, temperature sampling probability q_ is set for each language pair within each level. l ∝N_ l ^a, where q_ l Indicates a certain language l The sampling probability (e.g., the probability of an English-Chinese sample being drawn), N_ l Let q_ be the available sample size for the language pair (e.g., 10 million sentence pairs for English-Chinese, but only 20,000 for English-Swahili), and 'a' be a hyperparameter controlling the "compensation strength," where 0 ≤ a < 1; the smaller 'a' is, the stronger the compensation for the low-resource language; l Proportional to N_l Finally, we need to normalize the numbers to make the sum of all probabilities equal to 1.
[0049] In one embodiment, the alignment model can employ either a dual-encoder structure or a shared backbone plus a language adapter structure. Training uses a weighted loss function, where the weight of a sample is associated with its confidence level and the current stage number. The loss function design uses a confidence-weighted approach that complements the stage sampling strategy. To avoid loss scale drift caused by changes in the average weights across different stages or batches, the overall loss uses intra-batch weight normalization.
[0050] The weighted loss function can be expressed as:
[0051] Where B is the batch size. It is an index of sentence pairs. To prevent positive numbers with a denominator of zero, For cross-language semantic alignment loss, The feature regularization term can be represented using Euclidean distance, cosine distance, two-way KL divergence, or covariance constraints. For balance coefficient, It refers to sentence pairs The weights, and the overall confidence level and the current stage number Related.
[0052] Specifically, the weights of samples (i.e., sentence pairs) can be calculated using the following formula: + , of which 0 And it increases with each stage. It is a small normal number. Early period Smaller, higher-confidence samples have significantly larger weights; later... As the confidence level increases, the weight difference between samples of different confidence levels is compressed. Therefore, the stage sampling probability is responsible for controlling the frequency of samples appearing in each layer. The two are responsible for controlling the gradient contribution of the collected samples. They have different roles but together constitute the course training.
[0053] Among them, cross-language semantic alignment loss In-batch contrastive learning loss can be used. For the i-th sentence pair within a batch, a normalized representation is obtained from an encoder with shared parameters or partially shared parameters. , The sentence pairs with the same sequence number are used as positive samples, and other target sentences within the batch are used as candidate negative samples.
[0054] The calculation formula can be expressed as:
[0055] in, , These are the normalized representations of the source sentence and the target sentence, respectively. To exclude the first Source sentences can be paired with sentences that share the same document identifier, the same combination of entity anchors, or have a similarity exceeding the threshold for false negative samples, in order to reduce the risk of semantically equivalent sentences being mistakenly identified as negative samples. The source and target languages can also be swapped to calculate the inverse loss, and the two directions can be averaged. This is the temperature coefficient.
[0056] This is used to limit the representation offset of the same semantic meaning across different languages and perturbation views. The source and target sentences are subjected to semantically unchanged lexical discarding, synonym substitution, or random masking to obtain the perturbation representation. , The formula for calculating the characteristic regularization term can be expressed as:
[0057] When using probability distribution output, the squared distance can also be replaced with two-way KL divergence. The squared distance for each sample can then be... and After summing, and applying the aforementioned normalization formula, the overall loss is obtained. γ, η (weighting coefficients), and... The target can be determined on the validation set by cross-language retrieval accuracy, translation quality, or alignment error.
[0058] Step S140: After the training of each stage is completed, a portion of the samples in the corpus is re-evaluated based on the current alignment model, and the sample level is updated according to the re-evaluation results for use in subsequent stage training, until the preset termination condition is met.
[0059] The training phase can be switched by a fixed number of rounds, or adaptively switched when the alignment loss on the validation set decreases below a threshold for several consecutive evaluation periods, or when the retrieval accuracy reaches the target value. After each training phase, an evaluation subset is extracted from each language pair and each level according to a preset proportion to re-evaluate the current alignment model. Depending on the needs, the re-evaluation can cover the entire sample set, or only cover fuzzy boundary samples, high-loss samples, and randomly sampled samples; when computational resources are limited, the re-evaluation frequency can be reduced, or only S_sem and model loss-related features can be updated.
[0060] Specifically, such as Figure 2 As shown, the above step S140 specifically includes: steps S141-S143.
[0061] Step S141: Recalculate the semantic consistency and alignment loss moving average of a subset of samples in the corpus using an exponential moving average copy of the current alignment model.
[0062] A subset of samples in the corpus can be called the evaluation subset, which can be sampled representatively. Samples are taken from each language pair and each level to ensure comprehensive coverage of the evaluation results.
[0063] It should be noted that newly trained models may overfit the current batch, resulting in unstable and highly volatile evaluation results. The exponential moving average copy of the current alignment model (hereinafter referred to as the EMA model) is a smoothed average of historical weights, making it more stable, robust, and providing more reliable evaluation results. Semantic consistency S_sem^(k) refers to the semantic similarity between the source and target sentences calculated using the EMA model. The moving average of the alignment loss E_i^(k) refers to the alignment loss of the samples on the EMA model.
[0064] Step S142: Determine the dynamic confidence and dynamic difficulty scores of some samples in the corpus based on the recalculated semantic consistency and alignment loss moving average.
[0065] Based on the recalculated semantic consistency, the overall confidence level can be recalculated, denoted as . This is the new score for this stage.
[0066] The formula for calculating dynamic confidence level can be expressed as: ;in, This represents the overall confidence level for the previous stage. This is a new score for this stage, with 0 ≤ δ < 1, used to smooth out fluctuations between stages.
[0067] The dynamic difficulty score can be calculated as D_i^(k) = ζ·D_i + (1-ζ)·Norm(E_i^(k)), thus simultaneously reflecting both the inherent difficulty of the sample and the learning difficulty of the EMA model for that sample. D_i represents the static difficulty score; E_i^(k) represents the learning difficulty of the EMA model on that sample. Alignment loss on the scale; Norm represents normalization, mapping the loss value to a uniform scale; ζ is the mixing coefficient, controlling the weights of "inherent difficulty" and "current learning difficulty".
[0068] Step S143: Update the sample level based on the dynamic confidence and dynamic difficulty scores of some samples in the corpus.
[0069] It should be noted that the initial sample stratification is based on the overall confidence level and static difficulty score. After the first stage, the evaluation subset can be re-stratified based on the dynamic confidence level and dynamic difficulty score, according to the stratification rules mentioned above, to obtain the updated sample stratification. Samples not selected for re-evaluation in this stage retain the scores and stratifications from the previous stage. To prevent samples from frequently migrating around the threshold, a hysteresis interval can be set between the entry and exit thresholds, and samples are required to meet the migration conditions for two consecutive evaluation cycles before their stratification is adjusted.
[0070] For example, a sample's confidence level fluctuates around 0.55; the first evaluation: 0.54, classifying it as "high difficulty"; the second evaluation: 0.56, returning it to "medium difficulty"; the third evaluation: 0.53, returning it to "high difficulty" again. This frequent transfer leads to unstable training, with the same sample being treated differently at different stages, wasting computational resources, and requiring a regeneration of the sampling list each time, leaving the model confused. By setting a hysteresis range between entry and exit thresholds, for example, an entry threshold of 0.55 and an exit threshold of 0.60, the sample moves from a lower to a higher level only if the dynamic confidence level is greater than 0.60 for two consecutive times. If the dynamic confidence level is less than 0.55 for two consecutive times, the sample moves from a higher to a lower level. Between 0.55 and 0.6, no transfer occurs, and the sample remains unchanged.
[0071] Samples with confidence levels below the noise threshold but persistently high loss are prioritized for manual review; difficult samples that are confirmed as correct are returned to the high-difficulty sample layer, while samples that are confirmed as incorrect are removed from the training pool. The updated hierarchical states and language pair statistics can be used to generate the sampling list for the next stage and conduct the next stage of training, thus forming a closed loop of "evaluation—stratification—training—feedback—re-stratification".
[0072] In one embodiment, the preset termination condition may be that the value of the loss function is less than a preset value or that the maximum number of training stages is reached, for example, all K stages are completed. After training, the parameters of the cross-language alignment model, the shared multilingual representation space, and the hierarchical alignment index of the parallel corpus can be obtained. The index records at least the sentence pair identifier, language pair, source type, latest confidence C_i, latest difficulty D_i, level, most recent re-scoring stage, and entity / term anchor point, enabling downstream machine translation, cross-language retrieval, or multilingual instruction fine-tuning to retrieve or sample by language, confidence, and difficulty.
[0073] The technical solutions provided in the above embodiments of this application have the following technical effects: Reduce early noise pollution: Since this application first performs multi-dimensional confidence screening on candidate parallel corpora and then organizes training in a course-like progressive order, it can reduce the interference of low-quality sentence pairs on the representation space in the early stage of training and improve the stability of the initial alignment process.
[0074] Mitigating gradient oscillations and representation collapse: Since high-confidence, easy samples are prioritized for training, the model first establishes basic semantic anchors and then gradually absorbs medium and high-difficulty samples, thus reducing the risk of gradient oscillations and representation degradation in the early stages of training.
[0075] Improve the dynamic balance of multilingual learning: Through dynamic rescoring, hierarchical transfer and low-resource language temperature sampling after the end of the stage, the changes in model capabilities and differences in language resources can be fed back into the subsequent training schedule.
[0076] Improve computational efficiency: By performing high-cost fine screening only on fuzzy boundary samples and prioritizing high-value samples using stratified sampling probability and confidence loss weights, invalid computations on obviously noisy samples and easily repeated samples can be reduced.
[0077] Enhance long-tail and mixed-context adaptation capabilities: The difficulty assessment explicitly considers features such as cross-script, long sentences, dense terminology, and code switching, and increases the proportion of high-difficulty samples in the later stage, which is beneficial to improve the alignment effect in low-resource languages, professional fields, and mixed-language scenarios.
[0078] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
[0079] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0080] Figure 3 This is a block diagram of a training device for a cross-language alignment model provided in an embodiment of this application. Figure 3 As shown, the device includes: a corpus acquisition module 310, a hierarchical division module 320, a model training phase 330, and a feedback update module 340.
[0081] The corpus acquisition module 310 is used to acquire a corpus set containing multiple sentence pairs.
[0082] The hierarchical division module 320 is used to perform quality and difficulty assessments on each sentence pair, and divide the corpus into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer, based on the assessment results.
[0083] The model training phase 330 is used to set up multiple training phases. Each phase extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process.
[0084] The feedback update module 340 is used to re-evaluate a portion of the samples in the corpus based on the current alignment model after each training stage, and update the sample hierarchy according to the re-evaluation results for use in subsequent training stages, until the preset termination condition is met.
[0085] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. Each method step is implemented by a corresponding module, which will not be described in detail here. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0086] Figure 4 This specification illustrates a hardware structure diagram of an electronic device housing a training apparatus for a cross-language alignment model, according to an exemplary embodiment. Figure 4 As shown, the device may include: a processor 301, a memory 302, an input / output interface 303, a communication interface 304, and a bus 305. The processor 301, memory 302, input / output interface 303, and communication interface 304 are interconnected within the device via the bus 305.
[0087] The processor 301 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the steps of the training method for the cross-language alignment model provided in the embodiments of this specification.
[0088] The memory 302 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 302 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 302 and is called and executed by the processor 301.
[0089] Input / output interface 303 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touch screens, microphones, various sensors, etc., and output devices may include displays, speakers, vibrators, indicator lights, etc.
[0090] Communication interface 304 is used to connect a communication module (not shown in the figure) to enable communication and interaction between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0091] Bus 305 includes a pathway for transmitting information between various components of the device (e.g., processor 301, memory 302, input / output interface 303, and communication interface 304).
[0092] It should be noted that although the above-described device only shows the processor 301, memory 302, input / output interface 303, communication interface 304, and bus 305, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0093] This specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of a training method for a cross-language alignment model as described in any of the embodiments of this specification.
[0094] This specification also provides a computer program product, which includes computer-executable instructions stored in a computer-readable storage medium; wherein, when the processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, it implements the steps of the training method for the cross-language alignment model described in the above embodiments of this application.
[0095] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0096] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0097] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
Claims
1. A training method for a cross-language alignment model, characterized in that, include: Obtain a corpus containing multiple sentence pairs; For each sentence pair, a quality assessment and a difficulty assessment are performed. Based on the assessment results, the corpus is divided into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer. Multiple training phases are set up, and each phase extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process. After each training phase, a subset of samples in the corpus is re-evaluated based on the current alignment model, and the sample hierarchy is updated according to the re-evaluation results for use in subsequent training phases, until the preset termination condition is met.
2. The method according to claim 1, characterized in that, The evaluation results include a comprehensive confidence level, and the quality assessment includes: The basic confidence of the sentence pair is calculated based on at least one of the semantic similarity, source reliability, length matching degree, and terminology consistency. When the base confidence score is within the fuzzy boundary interval, calculate the structural consistency score and / or cyclic consistency score of the sentence pair; based on the base confidence score, structural consistency score and / or cyclic consistency score, determine the overall confidence score of the sentence pair; When the basic confidence level is not within the fuzzy boundary interval, the basic confidence level is used as the comprehensive confidence level.
3. The method according to claim 1, characterized in that, The evaluation results include a static difficulty score, and the difficulty evaluation includes: calculating the static difficulty score of the sentence pair based on at least one of the sentence pair's length features, word form variation features, word order difference features, and code mixing features.
4. The method according to claim 1, characterized in that, The multiple layers also include a medium sample layer and a noise layer, wherein samples in the noise layer are not used for training.
5. The method according to claim 1, characterized in that, The step of extracting samples from the multiple levels according to a preset strategy includes: Samples are taken from each level according to a preset mixing ratio, and the preset mixing ratio is adjusted as the stage progresses.
6. The method according to claim 1, characterized in that, The step of extracting samples from the multiple levels according to a preset strategy includes: Within each level, the sampling probability of the language pair is determined based on the sample size of the language pair within that level.
7. The method according to claim 1, characterized in that, The training employs a weighted loss function, where the weight of a sample is associated with the sample's confidence level and the current stage number.
8. The method according to claim 1, characterized in that, The re-evaluation of a subset of samples in the corpus based on the current alignment model includes: Using an exponential moving average copy of the current alignment model, the semantic consistency and alignment loss moving average of a subset of samples in the corpus are recalculated. Based on the recalculated semantic consistency and alignment loss moving average, the dynamic confidence and dynamic difficulty scores of some samples in the corpus are determined. The sample hierarchy is updated based on the dynamic confidence and dynamic difficulty scores of some samples in the corpus.
9. The method according to claim 1, characterized in that, The step of updating the sample hierarchy based on the reassessment results includes: Based on the entry and exit thresholds, the level of a sample is adjusted after the sample meets the migration conditions for multiple consecutive evaluation cycles.
10. A training device for a cross-language alignment model, characterized in that, include: The corpus acquisition module is used to acquire a corpus set containing multiple sentence pairs; The hierarchical division module is used to perform quality and difficulty assessments on each sentence pair, and divide the corpus into multiple levels, including at least a high-quality sample layer and a high-difficulty sample layer, based on the assessment results. The model training phase is used to set up multiple training phases. Each phase extracts samples from the multiple levels according to a preset strategy to train the alignment model. The preset strategy makes the proportion of high-quality samples gradually decrease and the proportion of high-difficulty samples gradually increase during the training process. The feedback update module is used to re-evaluate a portion of the samples in the corpus based on the current alignment model after each training stage, and update the sample hierarchy according to the re-evaluation results for use in subsequent training stages, until the preset termination condition is met.
11. An electronic device, characterized in that, include: Memory is used to store executable instructions for a computer; A processor, when executing computer-executable instructions stored in the memory, implements the training method for the cross-language alignment model according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The system stores computer-executable instructions, which, when executed by a processor, implement the training method for the cross-language alignment model according to any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes computer-executable instructions stored in a computer-readable storage medium; When the processor of the electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, it implements the training method of the cross-language alignment model according to any one of claims 1 to 9.
