Vector model fine tuning method and device, equipment, storage medium and program product

By constructing positive and negative sample pairs, nonlinear transformation, and scene weighting mechanisms, combined with an adaptive learning rate algorithm, the parameter training of the vector model is optimized, solving the problem of insufficient accuracy of the vector model in specific domains and achieving efficient and accurate model training results.

CN121502271APending Publication Date: 2026-02-10CHINA MOBILE M2M +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511745501.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing vector models struggle to accurately capture the meaning of specific terminology in particular domains, and existing methods such as expanding training datasets and hybrid models are costly or complex, making it difficult to simultaneously meet the requirements of accuracy and efficiency.

Method used

By constructing positive and negative sample pairs, employing nonlinear transformation and scene weighting mechanisms, and combining them with an adaptive learning rate algorithm, the parameter training process of the vector model is optimized. By utilizing a contrastive loss-driven strategy and gradient update mechanism, the model's recognition ability and robustness in specific scenarios are improved.

Benefits of technology

It improves the accuracy and robustness of vector models in specific domains, reduces the dependence on a large number of samples, and enhances model training efficiency and generalization ability, making it suitable for small sample sets and complex semantic scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121502271A_ABST
    Figure CN121502271A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a vector model fine adjustment method and device, equipment, a storage medium and a program product. The vector model fine tuning method comprises the following steps: acquiring a problem statement sample, and constructing a positive sample pair and a negative sample pair of the problem statement sample; after nonlinear transformation is carried out on the positive sample pair and the negative sample pair, the similarity between the positive sample pair and the negative sample pair is calculated; calculating comparison loss based on the importance and similarity of the question statement sample to the target scene; and finely tuning model parameters of the vector model based on the contrast loss. According to the embodiment of the invention, association characteristics between samples can be fully utilized, requirements on a large number of samples in a training process are reduced, and model training efficiency is improved; according to the method, the sample is mapped to the new semantic space, and the similarity is calculated according to the importance of the question statement sample and the target scene, so that the effect of comparative learning is effectively improved in a simple process, and meanwhile, the accuracy and robustness of the vector model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure belongs to the field of model fine-tuning technology, and particularly relates to a vector model fine-tuning method, apparatus, device, storage medium and program product. Background Technology

[0002] Vector models, through pre-training on large corpora, capture contextual information of words, learn semantic relationships between words, and quantify their similarity through mathematical operations. However, they still have significant limitations in word recognition in certain specific domains. For example, in the scenario of smart parks, when dealing with technical terms such as "land area" and "building area," it is often difficult to accurately capture their meaning in a specific context, easily leading to inaccurate search results.

[0003] To address these issues, one common strategy is to expand the training dataset by adding more domain-specific data to enhance the model's recognition capabilities. However, this method requires a large amount of labeled data, and the acquisition and processing of such data are costly. Another strategy is to use a hybrid model, combining traditional statistical models with vector models to achieve a trade-off in different scenarios. However, this often results in high complexity, slow inference speed, and an exceptionally complex tuning process, making it difficult to meet the requirements of real-time performance and stability. Therefore, while existing methods offer varying degrees of improvement, they struggle to simultaneously satisfy the requirements of accuracy and efficiency. Summary of the Invention

[0004] This disclosure provides a vector model fine-tuning method, apparatus, device, storage medium, and program product that can efficiently obtain an accurate output vector model.

[0005] In a first aspect, embodiments of this disclosure provide a vector model fine-tuning method, the method comprising: Obtain a sample of the question statement; Construct positive and negative sample pairs for the problem statement samples; After performing a nonlinear transformation on the positive and negative sample pairs, the similarity between the positive and negative sample pairs is calculated. Based on the importance and similarity of the question statement samples to the target scenario, the contrastive loss is calculated; Model parameters are fine-tuned based on contrastive loss vector model.

[0006] In one feasible implementation, the method further includes: calculating a contrastive loss based on the importance and similarity of the question statement samples to the target scene, including: Determine the target scenario to which the vector model is adapted; The importance of the question statement samples is determined based on their relevance to the target scenario, and sample weights are set according to their importance. Adjust the similarity of question statement samples using sample weights; Based on the adjusted similarity, the contrast loss is calculated.

[0007] In one feasible implementation, the method further includes: before obtaining the sample of the problematic statement, including: Set hyperparameters, including the adaptive learning rate; The model parameters for the contrastive loss-based fine-tuning vector model include: Extract the biased directional input of the contrastive loss with respect to the model parameters to obtain the gradient; Gradient updates are performed based on gradient time series and / or gradient direction changes; The adaptive learning rate is adjusted based on the updated gradient, and the model parameters of the vector model are fine-tuned using the adjusted adaptive learning rate.

[0008] In one feasible implementation, the method further includes: adjusting the adaptive learning rate based on the updated gradient, including: Calculate the first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient. The first-order momentum is used to characterize the direction of vector model training, and the second-order momentum is used to characterize the magnitude of vector model training. The adaptive learning rate is adjusted based on the first-order momentum and / or second-order momentum.

[0009] In one feasible implementation, the method further includes: calculating first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient, including: The sparsity index is determined based on the output value of the output layer and / or the activation value of the intermediate hidden layer of the vector model. The attenuation coefficient is then adjusted based on the sparsity index to obtain the adaptive attenuation coefficient. Calculate the first-order momentum and / or second-order momentum based on the updated gradient and the adaptive decay coefficient.

[0010] In one feasible implementation, the method further includes: adjusting the adaptive learning rate based on the updated gradient, including: The time series of the gradient is input into the long short-term memory network model to obtain the first gradient. The first decay coefficient is optimized with the sparsity index to obtain the first adaptive decay coefficient. The first momentum is obtained from the first gradient and the first adaptive decay coefficient. The second gradient is obtained by adjusting the angle between the gradient and the historical gradient using the interference intensity coefficient. The second attenuation coefficient is obtained by optimizing the second attenuation coefficient using the sparsity index. The second momentum is obtained from the second gradient and the second adaptive attenuation coefficient. The adaptive learning rate is updated based on the first-order momentum and the second-order momentum.

[0011] In one feasible implementation, the method further includes: fine-tuning the model parameters of the vector model using the following formula: in, These are the model parameters at time t+1; Here are the model parameters at time t; The original adaptive learning rate; It is second momentum; To prevent smooth terms with a denominator of zero; This is the adaptive decay coefficient used to calculate the first-order momentum; Let be the momentum at time t-1; For gradient time series Perform calculations on the Long Short-Term Memory (LSTM) network model; Let be the gradient at time t; Historical gradient; The interference intensity coefficient; This is the angle between the current gradient and the historical gradient.

[0012] In one feasible implementation, the method further includes: after fine-tuning the model parameters of the vector model based on the contrastive loss, including: The question statement is input into the fine-tuned vector model, which then outputs the answer to the question statement based on the target scenario.

[0013] Secondly, embodiments of this disclosure provide a vector model fine-tuning apparatus, the apparatus comprising: The sample acquisition module is used to obtain samples of the question statements; The sample pair construction module is used to construct positive and negative sample pairs of question statement samples; The similarity calculation module is used to calculate the similarity between positive and negative sample pairs after performing nonlinear transformations on them. The contrast loss calculation module is used to calculate the contrast loss based on the importance and similarity of the question statement samples to the target scene; The model parameter fine-tuning module is used to fine-tune the model parameters of the vector model based on contrastive loss.

[0014] Thirdly, this disclosure provides a vector model fine-tuning device, which includes a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the above-described vector model fine-tuning method.

[0015] Fourthly, this disclosure provides a computer storage medium storing computer program instructions, which, when executed by a processor, implement the aforementioned vector model fine-tuning method.

[0016] Fifthly, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements any of the vector model fine-tuning methods described in the above embodiments.

[0017] The vector model fine-tuning method, apparatus, device, storage medium, and program product disclosed herein take a question statement sample as input and process it into positive sample pairs containing the question statement sample and negative sample pairs containing the question statement sample. This fully utilizes the correlation characteristics between samples in the form of positive and negative sample pairs for vector model training, reducing the requirement for a large number of samples during training and improving model training efficiency. In addition, a linear transformation is performed on the positive and negative sample pairs to map them into a new semantic space. Then, the similarity is calculated based on the importance of the question statement sample and the target scene, enabling the model to make accurate similarity judgments with strong correlation to the target scene in a wider semantic space. This simple process effectively improves the effect of contrastive learning and enhances the accuracy and robustness of the vector model. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments of this disclosure will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating a vector model fine-tuning method provided in an embodiment of this disclosure; Figure 2 This is a flowchart illustrating a model parameter fine-tuning method provided in an embodiment of this disclosure; Figure 3 This is a flowchart illustrating a method for fine-tuning the bge-m3 vector model based on the method of this disclosure, provided in an embodiment of this disclosure. Figure 4 This is a schematic diagram of the comparative loss curve of a bge-m3 vector model implemented based on a traditional manual parameter tuning method, provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the comparative loss curve of the vector model after fine-tuning by the bge-m3 vector model fine-tuning method implemented based on the method of this disclosure, provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of the structure of a vector model fine-tuning device provided in an embodiment of this disclosure; Figure 7 This is a schematic diagram of the structure of a vector model fine-tuning device provided in an embodiment of this disclosure. Detailed Implementation

[0020] The features and exemplary embodiments of various aspects of this disclosure will now be described in detail. To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description, in conjunction with the accompanying drawings and specific embodiments, will provide a further detailed description. It should be understood that the specific embodiments described herein are intended only to explain this disclosure and not to limit it. For those skilled in the art, this disclosure can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this disclosure by illustrating examples.

[0021] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0022] Retrieval-Augmented Generation (RAG) architecture combines the advantages of information retrieval and generative models. It retrieves relevant documents or information fragments and uses them as context input to a generative model to improve the accuracy and relevance of responses. Due to its advantages, RAG architecture is widely used in current knowledge base retrieval and question-answering systems. In RAG architecture, vector models are crucial; they are used to transform text or words into high-dimensional vectors for efficient similarity calculation in the semantic space, helping the system quickly find documents relevant to the query. To improve the accuracy of vector models, various methods have been proposed by academia and industry. Common strategies include expanding the training dataset by adding more domain-specific data to enhance the model's recognition ability. While this can improve the model's understanding of domain-specific vocabulary to some extent, it requires a large amount of labeled data, and the acquisition and processing of such data is costly. Another approach is to use hybrid models, combining traditional statistical models with vector models to switch or trade off in different scenarios. While hybrid models can compensate for the shortcomings of single models to some extent, they are often complex, have slow inference speeds, and are difficult to meet real-time requirements. Furthermore, the tuning process for hybrid models is exceptionally complex, especially when dealing with multimodal information, where instability is prone to occur. Therefore, existing methods struggle to simultaneously meet the requirements of accuracy and efficiency in practical applications.

[0023] To address the problems in existing technologies, this disclosure provides a method, apparatus, device, storage medium, and program product for fine-tuning a vector model. Given that expanding the training dataset requires a large number of samples, and sample collection and processing is a complex process, and using a large amount of computation is unnecessary compared to model training and optimization, this disclosure constructs positive and negative sample pairs for the training samples. This allows the vector model to shift from passive classification to active comparison during training, learning deeper relative relationships between data with fewer training samples. Fully utilizing the correlation and dissimilarity between training samples facilitates the concentration of computational resources on the vector model training process, achieving rational resource allocation and thus solving the efficiency problem of model training. Specifically, this is achieved through a contrastive learning-driven strategy. Meanwhile, given the insufficient stability and accuracy of the hybrid model optimization process in the aforementioned cases... This disclosure trains on only one vector model, avoiding the problem of insufficient model stability. Furthermore, considering that the learning rate of a typical model is fixed within a training batch (multiple training iterations), which is not conducive to the model learning the essential features of the samples, this disclosure adaptively adjusts the learning rate based on the results of each training iteration. A dynamic learning rate is more conducive to the vector model obtaining a more accurate mapping function between input and output. This is specifically implemented through an adaptive learning rate algorithm.

[0024] The vector model fine-tuning method provided in the embodiments of this disclosure will be introduced first below.

[0025] Figure 1 A flowchart illustrating a vector model method provided in one embodiment of this disclosure is shown. Figure 1 As shown, the method may include the following steps: S10. Obtain a sample of the problem statement.

[0026] Question statement samples refer to text data that serves as model input in natural language-based tasks, existing in the form of questions or instructions, and aimed at obtaining certain information or triggering a certain response. Understanding question statement samples is key to understanding their context, and they typically appear in scenarios such as text-based question-answering, information retrieval, or dialogue systems. Specifically, question statement samples can be knowledge-based question-answering statements, such as questions in question-answering systems; or retrieval-based question statements, such as queries in contrastive learning or retrieval tasks. Furthermore, question statement samples and vector models are not limited to a single text format; they can explore the integration of multimodal information, such as images, videos, and sensor data. By combining text with other data sources, the model's ability to understand the scene can be further enriched, especially when dealing with IoT, video surveillance, and 3D building models, significantly improving the system's robustness and accuracy. Considering future globalization and multilingual users, fine-tuning schemes for cross-language vector models can also be explored, combining adaptive learning rates and contrastive learning strategies to further improve the model's generalization ability and accuracy in multilingual environments.

[0027] It should be noted that, for the vector model training process disclosed herein, the question statement samples can come from datasets related to the target scene. Furthermore, based on a contrastive learning-driven strategy, the question statement samples can come from pre-processed datasets in the form of positive and negative sample pairs, where it is necessary to ensure that the positive and negative sample pairs accurately reflect semantic similarities and differences. Of course, in practice, the question statement samples need to be processed by the vector model into question statement vectors to facilitate subsequent computation and learning.

[0028] Having a variety of question statement samples helps the model learn multiple ways of expression and obtain more accurate essential features of the samples, which helps improve the accuracy of the output.

[0029] S20. Construct positive and negative sample pairs of problem statement samples.

[0030] In one feasible implementation, when constructing a positive sample pair, text that is semantically similar to or the same as the question statement sample is generated, and together with the question statement sample, they form a positive sample pair for that question statement sample; similarly, when constructing a negative sample pair, text that is semantically dissimilar to or different from the question statement sample is generated, and together with the question statement sample, they form a negative sample pair for that question statement sample.

[0031] In the model training process, this disclosure adopts a contrastive learning-driven strategy, which is implemented on sample data in the form of positive and negative sample pairs. By defining and constructing positive and negative sample pairs of question statement samples, the vector model can not only focus on the loss function of the target task during training, but also improve the model's understanding of semantic similarity and difference through contrastive learning between samples, thereby reducing the dependence on a large number of samples.

[0032] S30. After performing a nonlinear transformation on the positive and negative sample pairs, calculate the similarity between the positive and negative sample pairs.

[0033] In other words, step S30 is the nonlinear similarity calculation mechanism. Before calculating the similarity of samples, a nonlinear transformation is performed on the samples. The contrastive learning-driven strategy proposed in this disclosure includes two core mechanisms, and the nonlinear similarity calculation in step S30 is one of the core mechanisms. In some embodiments, step S30 can be performed by mapping the sample vectors of positive and negative sample pairs to a new semantic space through a nonlinear transformation, and then calculating the similarity between positive and negative sample pairs to guide model learning.

[0034] The specific implementation process can be as follows: A nonlinear similarity measurement function is designed by introducing nonlinear transformation and temperature regulation. This function is used to implement the aforementioned nonlinear similarity calculation mechanism. In the specific calculation, firstly, the non-question statement samples in the positive sample pair are taken as positive samples, and the non-question statement samples in the negative sample pair are taken as negative samples. The calculation is then performed based on the question statement samples, positive samples, and negative samples. The nonlinear similarity measurement function can be expressed as Equation 1: Formula 1 in, Indicates sample and samples The similarity score between them, i.e., similarity; This represents the sample vector after nonlinear transformation; It is a temperature parameter used to adjust the smoothness of the distribution; To represent exponentiation; with When representing problem statement samples, with Characterizing positive samples, in Characterize negative samples.

[0035] Compared to traditional contrastive learning, which relies on simple Euclidean distance or cosine similarity to measure the similarity between samples, this disclosure introduces nonlinear transformation and temperature adjustment to improve the model's ability and accuracy in handling complex semantic relationships. It performs better in handling complex semantic relationships in high-dimensional space, enabling the model to make accurate similarity judgments on samples in a wider semantic space, thus effectively improving the effect of contrastive learning.

[0036] S40. Calculate the contrast loss based on the importance and similarity of the question statement samples to the target scene.

[0037] When processing complex data, step S30 effectively improves the model's semantic understanding and discrimination capabilities. However, when dealing with highly similar data samples, such as specialized terms like "area," "building area," "floor height," and "building height" in a park scene, the model struggles to correctly distinguish subtle differences, thus affecting overall performance. Therefore, in addition to the previously mentioned core mechanism, the contrastive learning-driven strategy proposes another core mechanism to improve the model's learning effect. Step S40 introduces a scene-weighted mechanism based on the traditional contrastive loss function. The basic process of the scene-weighted mechanism is as follows: when calculating the contrastive loss based on similarity, a weight is assigned to the corresponding similarity based on the importance of each question statement sample to the target scene. This weight is then used to adjust the similarity calculated in step S30, and the adjusted similarities are summed to obtain the contrastive loss.

[0038] Specifically, the scenario weighting mechanism can be implemented through the following process. First, determine the target scenario to which the vector model is adapted. The target scenario refers to the specific business problem, application environment, or task type that the vector model is designed to solve. Taking the application environment as an example, the target scenario could be a smart park. Taking the task type as an example, the target scenario could be a description that makes the output of the vector model more biased towards a key area within the smart park. Next, determine the importance of the question statement samples based on their relevance to the target scenario, and set sample weights according to their importance. The weights can be set as needed. For example, greater importance and weight can be given to sample pairs within the smart park that are more closely related to a specific key area. Finally, adjust the similarity of the question statement samples using the sample weights, and calculate the contrastive loss based on the adjusted similarity. When calculating the contrastive loss, a contrastive loss function is used. The purpose of the contrastive loss function is to maximize the similarity between semantically similar sample pairs while minimizing the similarity between semantically dissimilar sample pairs.

[0039] In one implementation, the contrast loss can be calculated using Equation 2: Formula 2 in, It is a contrastive loss function; It is the first The weights of each sample pair are assigned based on the importance of the scenario; It is the total number of sample pairs.

[0040] Through the above process, the samples are associated with the target scene, and this association is used to determine the contrastive loss process for the next model training. This improves the model's sensitivity to subtle semantic differences (such as key domain-specific words), thereby enhancing the model's generalization ability and robustness. At the same time, it enables the model to more effectively focus on key regions in a specific scene, further improving the model's generalization ability.

[0041] Furthermore, the aforementioned nonlinear similarity metric function and scene-weighted contrast loss function jointly enhance the model's ability and accuracy in handling complex semantic relationships. Combining these two functions can significantly improve the performance of the vector model in specialized scenarios such as smart parks, enabling it to maintain efficient training while possessing higher accuracy and robustness, thus better adapting to the complex needs of real-world applications.

[0042] S50, Model parameters based on the contrastive loss fine-tuning vector model.

[0043] The basic process described above is as follows: The biased induction of the contrastive loss with respect to the model parameters is extracted to obtain the gradient. This gradient is then decomposed and propagated to each layer of the encoder in the vector model via backpropagation to fine-tune the model parameters. The gradient descent optimization algorithm is used to update the model parameters along the reverse direction of the gradient. After step S50, iterative optimization can be performed, repeating steps S10 to S50 to bring the vector model to convergence. This process drives the encoder to adjust its parameters (i.e., model parameters), thereby systematically bringing the embeddings of positive sample pairs closer together and pushing the embeddings of negative sample pairs further apart, ultimately forming a well-structured embedding space based on semantic similarity.

[0044] To facilitate the description of the specific implementation process S51~S55 above, it is necessary to first introduce the concepts of hyperparameters and model parameters. Hyperparameters are parameters that are manually set or configured before the vector model begins training. For example, the learning rate represents the step size by which the model updates model parameters based on gradients; the training epochs represent the number of times the entire training dataset is fully traversed by the model. These parameters are not learned from the sample data by the vector model, but are used to control the vector model's learning process itself, and are generally set by developers based on experience, rules, or experiments. Model parameters, on the other hand, are learned from the sample data by the vector model during training. For example, the weights and biases in a neural network. Therefore, in the process of fine-tuning the vector model, it is crucial to reasonably select and adjust hyperparameters. In the traditional process of fine-tuning the vector model, it is necessary to manually set hyperparameters and then verify the effect of fine-tuning based on the calculation results of the loss function. If the effect is not good, it is necessary to reset the hyperparameters and fine-tune the vector model again. This process is very time-consuming and computationally expensive.

[0045] To address the above issues, this disclosure improves upon the traditional Adaptive Moment Estimation (Adam) algorithm, proposing a novel adaptive learning rate algorithm. To clearly explain the adaptive learning rate algorithm of this disclosure, the Adam algorithm needs to be introduced first.

[0046] The Adam algorithm is an optimization algorithm whose core lies in estimating the first and second momentum, and adjusting the learning rate during the fine-tuning of the vector model's parameters. The first momentum, representing momentum, is used to smooth gradient estimation and avoid getting trapped in local optima due to excessive gradient fluctuations during training. The first momentum is calculated using the following formula: Formula 3 in, This represents the momentum at the current time t. It is the momentum decay coefficient, which is usually set to 0.9; It is the gradient at the current time t.

[0047] Second-order momentum is used to characterize momentum acceleration and is used to adjust the learning rate to ensure the stability of parameter updates, especially under conditions of rapid gradient changes. The formula for second-order momentum is obtained from Equation 4: Formula 4 in, This represents the weighted average of the squared gradients; It is the acceleration attenuation coefficient, which is usually set to 0.999.

[0048] The fine-tuning process of the Adam algorithm model parameters combines the estimation of first-order and second-order momentum, ensuring that the model parameter update direction takes into account both past gradient information and the learning rate adjustment based on the magnitude of change in each parameter. The parameters of the vector model are fine-tuned using Equation 5: Formula 5 in, These are the model parameters at the current time t; It is the global learning rate; It is a smoothing term to prevent the denominator from being zero.

[0049] While the Adam algorithm offers a learning rate adjustment approach, accelerating initial convergence, this also causes it to linger near sharp, poorly generalized minima in the later stages of optimization, failing to find flatter, more generalized minima. For high-precision, specialized tasks, the Adam algorithm may converge to a local optimum worse than traditional momentum SGD. Furthermore, the Adam algorithm's adaptability to some extent overfits the initial iterations of the training data, limiting its ability to explore the solution space and resulting in low generalization. For example, in specific scenarios such as residential areas, the multi-tenant design leads to a smaller sample dataset, falling short of the optimal training dataset size. In such complex scenarios, the Adam algorithm struggles to effectively handle the complexities, limiting the model's generalization ability.

[0050] To address this issue, this disclosure proposes a novel adaptive learning rate algorithm in step S50, based on the Adam algorithm, to better resolve the overfitting and underfitting problems. As described above, prior to step S10, the process also includes setting hyperparameters, including the adaptive learning rate. Figure 2 Please refer to the flowchart of a model parameter fine-tuning method provided in this embodiment of the disclosure. Figure 2 The model parameters for the contrastive loss-based fine-tuning vector model include steps S51 to S55.

[0051] S51. Extract the biased directional input of the contrastive loss to the model parameters to obtain the gradient.

[0052] This is a systematic, hierarchical backpropagation process. First, the contrastive loss layer is differentiated, calculating the partial derivative of the contrastive loss with respect to each similarity score to obtain the signal strength that brings the signals closer / farther. Then, differentiation is performed at the similarity layer, mapping the gradient of the similarity score onto its input vector to obtain the adjustment direction of each output vector. Next, model backpropagation is performed, backpropagating the gradient of the output vector through each layer of the encoder, using the chain rule to calculate the local gradient of the parameters at each layer. Finally, the local gradients calculated for all samples in a batch are averaged to obtain the final gradient vector for this training step.

[0053] The gradient precisely indicates which direction is the steepest ascent in the multidimensional parameter space. Optimizers such as Stochastic Gradient Descent (SGD) or Adam then update the model parameters in the opposite direction, gradually reducing the contrastive loss and enabling the model to learn to generate high-quality vector representations.

[0054] S53. Gradient updates are performed based on the time series of gradients and / or changes in the direction of gradients.

[0055] This disclosure effectively processes and utilizes historical sequence information, considering the time series and direction change factors of the gradient, treating the gradient as a dynamic process rather than a static snapshot, and enabling an understanding of its "behavior" rather than just its "state". After processing the gradient in step S53, it participates in the process of updating model parameters through adaptive learning rate adjustment.

[0056] To achieve the above process, this disclosure proposes two methods for gradient updating. The first method involves obtaining a time series of gradients over a period of time and inputting it into a Long Short-Term Memory (LSTM) network model to obtain the updated gradient. Based on this, a momentum memory mechanism is proposed, the details of which will be explained later. The second method involves adjusting the angle between the gradient and the historical gradient directions using an interference intensity coefficient to update the gradient. Based on this, an directional gradient interference mechanism is proposed, the details of which will also be explained later.

[0057] By memorizing gradient information from the past period and adjusting the gradient direction, subsequent model parameter updates are based not only on the current gradient information but also on the historical direction and numerical changes of the gradient, enhancing the model's ability to escape local optima. This shift in perspective from static to dynamic regarding gradients further improves model performance, robustness, and intelligence.

[0058] S55. Adjust the adaptive learning rate based on the updated gradient, and use the adjusted adaptive learning rate to fine-tune the model parameters of the vector model.

[0059] Specifically, adjusting the adaptive learning rate based on the updated gradient includes: First, calculating the first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient. The first-order momentum characterizes the direction of vector model training, and the second-order momentum characterizes the magnitude of vector model training. Then, adjusting the adaptive learning rate based on the first-order momentum and / or second-order momentum.

[0060] Compared to the Adam algorithm, this disclosure dynamically updates the gradient, adjusts the adaptive learning rate with the dynamically updated gradient, and uses the adjusted adaptive learning rate in the process of updating the model parameters of the vector model, which can better optimize the convergence speed and output accuracy during the training process.

[0061] More specifically, for the data sparsity characteristics of a certain scenario, an adaptive momentum adjustment mechanism for data sparsity was designed. This mechanism dynamically adjusts the momentum decay coefficient based on the data sparsity, as follows: A sparsity index is determined based on the output values ​​of the output layer of the vector model and / or the activation values ​​of the intermediate hidden layers. The decay coefficient is then adjusted based on the sparsity index to obtain an adaptive decay coefficient. First-order momentum and / or second-order momentum are calculated based on the updated gradient and the adaptive decay coefficient.

[0062] The data sparsity adaptive momentum adjustment mechanism can dynamically adjust the momentum parameter according to the data sparsity, enabling the model to maintain good training performance on sparse datasets and avoiding gradient vanishing or exploding problems. Compared to the Adam algorithm, this disclosure dynamically updates the decay coefficient, adjusts the adaptive learning rate with the dynamically updated decay coefficient, and uses the adjusted adaptive learning rate in the model parameter update process of the vector model, which can enhance the model's performance on sparse datasets.

[0063] One implementation of the aforementioned new adaptive learning rate algorithm is to combine momentum memory mechanism, directional gradient interference mechanism and data sparsity adaptive momentum adjustment mechanism.

[0064] Data sparsity can lead to inaccurate momentum estimation, thus affecting the training performance of the model. To address this, a momentum memory mechanism is designed to improve momentum estimation by capturing long-term gradient changes. Specifically, when calculating the first-order momentum, the time series of gradients is input into the Long Short-Term Memory (LSTM) network model to obtain the first gradient. The first decay coefficient is then optimized using a sparsity metric to obtain the first adaptive decay coefficient. The first-order momentum is then obtained from the first gradient and the first adaptive decay coefficient. By memorizing gradient information from the past period, the momentum is made less sensitive to data sparsity, making training under sparse data more robust. The improved first-order momentum is calculated using Equation 6, and the first adaptive decay coefficient is calculated using Equation 7. Formula 6 Formula 7 LSTM stands for Long Short-Term Memory network, which is used to process gradient sequences over a period of time. Indicates the first adaptive attenuation coefficient; Indicates the first gradient; It is the adjustment coefficient; It is an indicator of data sparsity.

[0065] Traditional gradient descent methods are prone to getting trapped in local optima, especially in scenarios with sparse and complex data. To prevent this, an oriented gradient interference mechanism is designed, incorporating interference in both direction and magnitude during gradient updates to increase gradient diversity. When calculating second-order momentum, the angle between the gradient and historical gradient directions is adjusted using an interference intensity coefficient to obtain the second gradient. A second adaptive decay coefficient is obtained by optimizing the second decay coefficient using a sparsity index. The second momentum is then derived from the second gradient and the second adaptive decay coefficient. By adjusting the gradient direction, parameter updates are based not only on current gradient information but also on historical gradient directions, enhancing the model's ability to escape local optima. The second gradient is calculated using Equation 8, and the second adaptive decay coefficient is calculated using Equation 9. Formula 8 Formula 9 in, It is the interference intensity coefficient. It is the angle between the current gradient and the historical gradient; It is the adjustment coefficient; This represents the second adaptive attenuation coefficient.

[0066] Combining the above three mechanisms, the adaptive learning rate is updated based on the improved first-order and second-order momentum, and the model parameters of the vector model are updated based on the updated adaptive learning rate. The updated model parameters are calculated using the following formula (Equation 10): Formula 10 in, These are the model parameters at time t+1; Here are the model parameters at time t; The original adaptive learning rate; It is second momentum; To prevent smooth terms with a denominator of zero; This is the adaptive decay coefficient used to calculate the first-order momentum; Let be the momentum at time t-1; For gradient time series Perform calculations on the Long Short-Term Memory (LSTM) network model; Let be the gradient at time t; Historical gradient; The interference intensity coefficient; This is the angle between the current gradient and the historical gradient.

[0067] This disclosure presents an adaptive learning rate algorithm that combines momentum memory mechanism, directional gradient interference mechanism and sparsity adaptive momentum adjustment mechanism. In each model training, the learning rate can be adjusted in a timely manner according to the changes in the direction and value of the gradient. At the same time, a sparsity index is introduced to adjust the decay coefficient. It is particularly suitable for application scenarios with small training sample sets and content containing complex semantics and technical terms.

[0068] Furthermore, the training objective of this vector model is to make the output more closely resemble a description of the target scenario, aiming to improve the accuracy and robustness of the vector model in specific domains (such as smart parks). After fine-tuning the model parameters based on contrastive loss, the process also includes: inputting the question statement into the fine-tuned vector model, causing the vector model to output an answer to the question statement in response to the target scenario. By fine-tuning the pre-trained vector model, it is better adapted to the needs of the target task.

[0069] This disclosure provides an efficient and accurate method for fine-tuning vector models by combining an adaptive learning rate algorithm and a contrastive learning-driven strategy. It is particularly suitable for application scenarios with small training sample sets and content containing complex semantics and technical terms.

[0070] The following section uses the AI-Generated General Embedding Model m3 (bge-m3) as an example to briefly describe the specific process of fine-tuning a vector model. The bge-m3 vector model is an efficient vector model suitable for text embedding, capable of capturing the semantic information of text. The purpose of fine-tuning the bge-m3 vector model is to adapt it to the specialized terminology and context of a specific domain (such as smart parks), thereby improving the model's performance in that domain. Although the bge-m3 model has already been trained on a large-scale general corpus, fine-tuning allows the model to process domain-specific data more accurately, thus improving the accuracy and relevance of text embeddings.

[0071] Figure 3 This is a flowchart illustrating a method for fine-tuning a bge-m3 vector model according to an embodiment of this disclosure. Please refer to [link / reference]. Figure 3 This embodiment includes steps S1 to S6.

[0072] S1. Data Preparation. Collect textual data covering professional fields (such as smart park fields), including technical terms like building area and land area, and ensure the dataset covers various scenarios and contexts. Divide the dataset into training, validation, and test sets. The training set is used for model training, the validation set for hyperparameter tuning and model evaluation, and the test set for validating the final model performance.

[0073] S2. Model Selection. Download and load the bge-m3 pre-trained model and word segmenter from the Hugging Face Transformers library. Initialize the bge-m3 text embedding model to prepare for the text vectorization task.

[0074] S3. Data Preprocessing. To better adapt the bge-m3 vector model to professional fields such as smart parks, the following preprocessing steps are required: 1) Data Labeling: Label the data, including categories, relevance, semantic similarity, etc.; 2) Tokenization and Encoding: Use the bge-m3 vector model's tokenizer to segment and encode the text data, converting the text into token IDs that the model can process. Ensure that the input text retains its original semantic information during encoding. For each text, padding ensures uniform sample length within the batch, facilitating GPU parallel computing; truncation prevents the text from exceeding the model's processing limit; returning a PyTorch tensor facilitates direct input into the model for forward propagation and output; 3) Processing Long Text: For long text data, truncation or block processing is required to adapt to the model's input length limitations. Common methods include sliding window strategies or text fragmentation to ensure that important information is not lost; 4) Construction of positive and negative sample pairs: In contrastive learning-driven strategies, constructing positive sample pairs (text pairs with similar semantics) and negative sample pairs (text pairs with dissimilar semantics) is a key step. It is necessary to ensure that positive and negative sample pairs can truly reflect semantic similarities and differences; 5) Standardization processing: Ensure that all text data undergoes uniform standardization processing before being input into the model, such as removing stop words, unifying capitalization, and eliminating noise characters, to improve data consistency and model generalization ability.

[0075] S4. Hyperparameter Tuning. Proper selection and adjustment of hyperparameters are crucial during fine-tuning. The following hyperparameters are set using grid search: Epoch Number (represents the number of times the training data is processed, affecting the fit); Optimization Algorithm (represents the parameter update strategy, affecting the model's convergence speed and quality); Learning Rate (represents the step size of parameter updates, affecting convergence and convergence speed); Batch Size (represents the number of samples per update, affecting training stability and generalization ability); Warmup Steps (represents the initial increase in the learning rate, affecting stability in the early stages of training); Weight Decay (represents model complexity, preventing overfitting). The number of training epochs can be 3, 5, or 10; the optimization algorithm is the improved Adma algorithm of this disclosure; the learning rate is 1e-5 (0.00001), 2e-5, or 3e-5; the batch size is 16, 32, or 64; the warm-up steps are 0, 500, or 1000; and the weight decay is 0.01, 0.001, or 0.0001. In this embodiment, the number of training epochs is 5; the optimization algorithm is the improved Adma algorithm of this disclosure; the learning rate is 2e-5; the batch size is 32; the warm-up steps are 500; and the weight decay is 0.01.

[0076] S5. Model Fine-tuning Training. During fine-tuning, steps S10-S50 and S51-S55 above are executed to optimize the bge-m3 model. The purpose of the contrastive loss function is to maximize the similarity between semantically similar sample pairs while minimizing the similarity between semantically dissimilar sample pairs.

[0077] S6. Model Validation and Optimization. A closed-loop process of "training-evaluation-diagnosis-adjustment" is performed based on the validation and test sets. The validation set guides the direction of optimization, while the test set evaluates the model's final performance. Through multiple iterations, the ultimate goal is to obtain a vector model that is robust and reliable on unknown data.

[0078] To verify the effectiveness of the above embodiments, a comparative experiment was conducted. The contrast loss after fine-tuning using the vector model fine-tuning method of this disclosure was compared with the contrast loss after fine-tuning using the manual parameter tuning method. The comparative experiment was also implemented based on the above steps S1 to S6. The difference is that the contrast loss in the manual parameter tuning method is calculated based on Formula 11. The formula indicates that for positive sample pairs (e.g., similar text pairs), the goal of the model is to make their cosine similarity as close as possible; while for negative sample pairs (e.g., dissimilar text pairs), the goal of the model is to make their cosine similarity as far apart as possible. The specific Formula 11 is as follows: Formula 11 in, To compare the loss values; The number of sample pairs; Let be the label for sample pair iii, where 1 represents a positive sample pair and 0 represents a negative sample pair; This refers to the margin parameter in the loss function; For sample pair i, there are two embedding vectors. and Cosine similarity between them.

[0079] Figure 4 This is a schematic diagram of the comparative loss curve of a bge-m3 vector model implemented based on a traditional manual parameter tuning method, provided in an embodiment of this disclosure. Figure 5 This is a method provided in the embodiments of the present disclosure that involves steps S1 to S6. Figure 3 A schematic diagram of the contrastive loss curve for a vector model. (Example) Figures 4 to 5 As shown, the training loss curve graph contains two curves: the original curve, which represents the original training loss value calculated at each step (or each round). Due to the randomness of the data, it usually fluctuates greatly; the smoothed curve is the result of applying a smoothing algorithm such as moving average to the original loss curve. The purpose is to filter out random noise and more clearly show the overall downward trend of the loss value. The horizontal axis represents the number of training steps (step), indicating the number of iterations in the model training. For example, step 10, step 20, etc., represent how many times the model parameters have been updated. The vertical axis represents the loss value, indicating the magnitude of the model training loss. Both the original and smoothed curves show a clear downward trend. This downward trend indicates that the model is learning effectively from the training data and the parameter adjustments are in the correct direction. The smoothed curve reveals the essential trend of a stable decrease in the loss value under noise. This curve is mainly used to determine whether the training is progressing normally and whether it has converged (i.e., the curve becomes flat). Figure 4 and Figure 5 The comparison clearly shows that, after the processing disclosed in this paper, the training loss of the vector model decreases faster and reaches a lower loss value, indicating that the vector model can learn and converge more effectively.

[0080] To address the limitations of vector models in fine-tuning, this disclosure proposes a method combining an adaptive learning rate algorithm and a contrastive learning-driven strategy. During fine-tuning, the adaptive learning rate algorithm enables the model to dynamically adjust the learning rate based on the training performance of the current task, optimizing the training process and avoiding overfitting or underfitting problems caused by traditional fixed learning rates. A momentum memory mechanism, a directional gradient interference mechanism, and a data sparsity adaptive adjustment mechanism are designed to achieve dynamic learning rate adjustment of the vector model, thereby improving the model's convergence speed and generalization ability, especially its adaptability to small sample and sparse datasets, significantly enhancing training efficiency. Simultaneously, through the contrastive learning-driven strategy, the model can better understand semantic similarity and differences, further improving model performance. By employing an innovative nonlinear similarity metric function and a scene-weighted contrastive loss function, more accurate similarity judgments are achieved in high-dimensional space, improving the model's sensitivity to subtle semantic differences, particularly in handling similar data in specific scenarios, resulting in significantly improved accuracy.

[0081] This disclosure optimizes the fine-tuning process of vector models through an adaptive learning rate algorithm, combined with a contrastive learning-driven strategy to improve the model's sensitivity to subtle semantic differences. From model fine-tuning to final optimization, this disclosure constructs a complete solution, simplifying the vector model fine-tuning process, improving the model's generalization ability and adaptability, especially in complex semantic processing tasks. It reduces reliance on large datasets and complex model architectures, enabling enterprises to deploy and optimize models more efficiently, lowering the technical threshold, and allowing enterprises to maintain a competitive advantage in scenarios requiring real-time processing and high-precision responses, such as smart park management and financial risk control. Compared to traditional methods of expanding datasets or using complex hybrid models, the technical solution disclosed in this disclosure achieves a better balance between accuracy and efficiency.

[0082] Figure 6 This is a schematic diagram of a vector model fine-tuning device provided in an embodiment of this disclosure. Figure 6 As shown, the device 200 may include a sample acquisition module 210, a sample pair construction module 220, a similarity calculation module 230, a contrast loss calculation module 240, and a model parameter fine-tuning module 250.

[0083] Sample acquisition module 210 is used to acquire sample question statements; The sample pair construction module 220 is used to construct positive and negative sample pairs of problem statement samples; The similarity calculation module 230 is used to calculate the similarity between positive sample pairs and negative sample pairs after performing nonlinear transformation on them. The contrast loss calculation module 240 is used to calculate the contrast loss based on the importance and similarity of the question statement samples to the target scene; Model parameter fine-tuning module 250 is used to fine-tune the model parameters of the vector model based on contrastive loss.

[0084] In one embodiment, the comparison loss calculation module 240 is further configured to: Determine the target scenario to which the vector model is adapted; The importance of the question statement samples is determined based on their relevance to the target scenario, and sample weights are set according to their importance. Adjust the similarity of question statement samples using sample weights; Based on the adjusted similarity, the contrast loss is calculated.

[0085] In one embodiment, the model parameter fine-tuning module 250 is also used for: Extract the biased directional input of the contrastive loss with respect to the model parameters to obtain the gradient; Gradient updates are performed based on gradient time series and / or gradient direction changes; The adaptive learning rate is adjusted based on the updated gradient, and the model parameters of the vector model are fine-tuned using the adjusted adaptive learning rate.

[0086] In one embodiment, the model parameter fine-tuning module 250 is also used for: Calculate the first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient. The first-order momentum is used to characterize the direction of vector model training, and the second-order momentum is used to characterize the magnitude of vector model training. The adaptive learning rate is adjusted based on the first-order momentum and / or second-order momentum.

[0087] In one embodiment, the model parameter fine-tuning module 250 is also used for: The sparsity index is determined based on the output value of the output layer and / or the activation value of the intermediate hidden layer of the vector model. The attenuation coefficient is then adjusted based on the sparsity index to obtain the adaptive attenuation coefficient. Calculate the first-order momentum and / or second-order momentum based on the updated gradient and the adaptive decay coefficient.

[0088] In one embodiment, the model parameter fine-tuning module 250 is also used for: The time series of the gradient is input into the long short-term memory network model to obtain the first gradient. The first decay coefficient is optimized with the sparsity index to obtain the first adaptive decay coefficient. The first momentum is obtained from the first gradient and the first adaptive decay coefficient. The second gradient is obtained by adjusting the angle between the gradient and the historical gradient using the interference intensity coefficient. The second attenuation coefficient is obtained by optimizing the second attenuation coefficient using the sparsity index. The second momentum is obtained from the second gradient and the second adaptive attenuation coefficient. The adaptive learning rate is updated based on the first-order momentum and the second-order momentum.

[0089] In one embodiment, the model parameter fine-tuning module 250 is also used for: The model parameters can be fine-tuned using the following formula: in, These are the model parameters at time t+1; Here are the model parameters at time t; The original adaptive learning rate; It is second momentum; To prevent smooth terms with a denominator of zero; This is the adaptive decay coefficient used to calculate the first-order momentum; Let be the momentum at time t-1; For gradient time series Perform calculations on the Long Short-Term Memory (LSTM) network model; Let be the gradient at time t; Historical gradient; The interference intensity coefficient; This is the angle between the current gradient and the historical gradient.

[0090] Optionally, any one of the following modules—sample acquisition module 210, sample pair construction module 220, similarity calculation module 230, contrast loss calculation module 240, and model parameter fine-tuning module 250—is also used to implement: After fine-tuning the model parameters of the vector model based on contrastive loss, the question statement is input into the fine-tuned vector model, so that the vector model outputs the answer to the question statement for the target scenario.

[0091] Figure 7 A schematic diagram of the hardware structure of the vector model fine-tuning device provided in an embodiment of this disclosure is shown.

[0092] The device may include a processor 301 and a memory 302 storing computer program instructions.

[0093] Specifically, the processor 301 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this disclosure.

[0094] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. In one instance, memory 302 may include removable or non-removable (or fixed) media, or memory 302 may be non-volatile solid-state memory. Memory 302 may be internal or external to the integrated gateway disaster recovery device.

[0095] In one instance, memory 302 may be read-only memory (ROM). In one instance, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0096] Memory 302 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.

[0097] The processor 301 reads and executes computer program instructions stored in the memory 302 to achieve... Figures 1 to 3 The vector model fine-tuning method in the illustrated embodiment.

[0098] In one example, the vector model fine-tuning device may also include a communication interface 303 and a bus 304. For example, Figure 7 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 304 and complete communication with each other.

[0099] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this disclosure.

[0100] Bus 304 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 304 may include one or more buses. Although specific buses are described and illustrated in embodiments of this disclosure, this disclosure contemplates any suitable bus or interconnect.

[0101] Furthermore, in conjunction with the vector model fine-tuning methods in the above embodiments, this disclosure can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the vector model fine-tuning methods in the above embodiments.

[0102] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the vector model fine-tuning methods described in the above embodiments.

[0103] It should be clarified that this disclosure is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this disclosure is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this disclosure.

[0104] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this disclosure are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0105] It should also be noted that the exemplary embodiments mentioned in this disclosure describe methods or systems based on a series of steps or apparatus. However, this disclosure is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0106] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0107] The above are merely specific embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this disclosure is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this disclosure, and these modifications or substitutions should all be covered within the protection scope of this disclosure.

Claims

1. A method for fine-tuning a vector model, characterized in that, The method includes: Obtain a sample of the question statement; Construct positive and negative sample pairs for the problem statement samples; After performing a nonlinear transformation on the positive and negative sample pairs, the similarity between the positive and negative sample pairs is calculated. Based on the importance of the question statement samples to the target scene and the similarity, the contrast loss is calculated; The model parameters of the vector model are fine-tuned based on the contrastive loss.

2. The vector model fine-tuning method according to claim 1, characterized in that, The calculation of the contrast loss based on the importance of the question statement samples to the target scene and the similarity includes: Determine the target scenario to which the vector model is adapted; The importance of the question statement sample is determined based on the degree of correlation between the question statement sample and the target scenario, and the sample weight is set according to the importance. The similarity of the question statement samples is adjusted using the sample weights. Based on the adjusted similarity, the contrast loss is calculated.

3. The vector model fine-tuning method according to claim 1, characterized in that, Before obtaining the sample question statement, the following is included: Set hyperparameters, including the adaptive learning rate; The fine-tuning of the model parameters of the vector model based on the contrastive loss includes: Extract the biased directional input of the contrastive loss with respect to the model parameters to obtain the gradient; Gradient updates are performed based on the time series of the gradient and / or the direction changes of the gradient. The adaptive learning rate is adjusted based on the updated gradient, and the model parameters of the vector model are fine-tuned using the adjusted adaptive learning rate.

4. The vector model fine-tuning method according to claim 3, characterized in that, The step of adjusting the adaptive learning rate according to the updated gradient includes: Calculate first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient. The first-order momentum is used to characterize the direction of the vector model training, and the second-order momentum is used to characterize the magnitude of the vector model training. The adaptive learning rate is adjusted based on the first-order momentum and / or the second-order momentum.

5. The vector model fine-tuning method according to claim 4, characterized in that, The calculation of first-order momentum and / or second-order momentum based on the updated gradient and decay coefficient includes: The sparsity index is determined based on the output value of the output layer and / or the activation value of the intermediate hidden layer of the vector model. The attenuation coefficient is then adjusted based on the sparsity index to obtain an adaptive attenuation coefficient. Calculate the first-order momentum and / or second-order momentum based on the updated gradient and the adaptive decay coefficient.

6. The vector model fine-tuning method according to claim 5, characterized in that, The step of adjusting the adaptive learning rate according to the updated gradient includes: The time series of the gradient is input into the long short-term memory network model to obtain the first gradient. The first decay coefficient is optimized with the sparsity index to obtain the first adaptive decay coefficient. The first momentum is obtained from the first gradient and the first adaptive decay coefficient. The angle between the gradient and the historical gradient is adjusted by the interference intensity coefficient to obtain the second gradient. The second attenuation coefficient is optimized by the sparsity index to obtain the second adaptive attenuation coefficient. The second momentum is obtained from the second gradient and the second adaptive attenuation coefficient. The adaptive learning rate is updated based on the first-order momentum and the second-order momentum.

7. The vector model fine-tuning method according to any one of claims 1 to 6, characterized in that, The model parameters of the vector model are fine-tuned using the following formula: in, These are the model parameters at time t+1; The model parameters are at time t; The original adaptive learning rate; It is second momentum; To prevent smooth terms with a denominator of zero; This is the adaptive decay coefficient used to calculate the first-order momentum; Let be the momentum at time t-1; For gradient time series Perform calculations on the Long Short-Term Memory (LSTM) network model; Let be the gradient at time t; Historical gradient; The interference intensity coefficient; This is the angle between the current gradient and the historical gradient.

8. The vector model fine-tuning method according to claim 1, characterized in that, After fine-tuning the model parameters of the vector model based on the contrastive loss, the process includes: The question statement is input into the finely tuned vector model, which then outputs the answer to the question statement for the target scenario.

9. A vector model fine-tuning device, characterized in that, The device includes: The sample acquisition module is used to obtain samples of the question statements; The sample pair construction module is used to construct positive sample pairs and negative sample pairs for the question statement samples; The similarity calculation module is used to perform nonlinear transformation on the positive sample pairs and negative sample pairs and then calculate the similarity between the positive sample pairs and negative sample pairs. The contrast loss calculation module is used to calculate the contrast loss based on the importance of the question statement sample to the target scene and the similarity. The model parameter fine-tuning module is used to fine-tune the model parameters of the vector model based on the contrastive loss.

10. A vector model fine-tuning device, characterized in that, The device includes: a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the vector model fine-tuning method as described in any one of claims 1 to 8.

11. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, implement the vector model fine-tuning method as described in any one of claims 1 to 8.

12. A computer program product, characterized in that, Includes a computer program, which, when executed, implements the vector model fine-tuning method as described in any one of claims 1 to 8.