An embedding model fine-tuning method and system for asymmetric text matching

By generating query text and searchable text pairs and optimizing the embedding model weights using a contrastive learning framework and encoding matrix, the problem of decreased accuracy of embedding models in asymmetric text matching tasks is solved, thereby improving model training efficiency and accuracy.

CN117290475BActive Publication Date: 2025-12-12WUHAN KOTEI INFORMATICS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311187805.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-12
Publication Date
2025-12-12
Estimated Expiration
2043-09-12

AI Technical Summary

Technical Problem

Existing embedding models suffer from decreased accuracy when handling asymmetric text matching tasks in specific domains, failing to meet the processing requirements of those domains, especially when faced with a large number of abbreviations, repeated words, and technical terms.

Method used

By generating unique pairs of query text and text to be retrieved, a contrastive loss function is used for model training. A contrastive learning framework and a covering mechanism are employed to optimize the weights of the embedding model to improve matching accuracy.

Benefits of technology

It effectively expands training data, improves model training efficiency, overcomes structural differences in asymmetric text, enhances the matching accuracy of embedding vectors, and ensures model convergence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117290475B_ABST
    Figure CN117290475B_ABST
Patent Text Reader

Abstract

The application provides an embedding model fine-tuning method and system for asymmetric text matching, which comprises the following steps: generating a plurality of non-repeating query texts according to the to-be-retrieved texts and prompt words, and screening the generated query texts; forming to-be-retrieved text and query text pairs according to the one-to-one pairing principle until a data set containing all to-be-retrieved text and query text pairs is generated; training the embedding model using the data set; through the back propagation of the training process, the embedding model output iteratively approaches the true value in the way of minimizing the contrast loss function, so as to obtain an optimized embedding model. The application adopts a data completion strategy, can effectively expand the training data, and improve the model training efficiency; the contrast learning framework is adopted, so that the model can extract information related to the text matching task, weaken useless information, and at the same time ensure that the model training can converge, thereby improving the matching accuracy of the embedding vector.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language processing in deep learning (artificial intelligence), and more particularly to an embedding model fine-tuning method and system for asymmetric text matching. BACKGROUND

[0002] In recent years, with the rapid development of large language models, embedding vectors are widely used in text search, program code search, and intelligent question answering, etc., most of which are asymmetric text matching tasks. Many large model service companies provide general embedding models for customers to convert text into vectors and then perform text matching tasks, such as the text-embedding-ada-002 model of OpenAI company.

[0003] Such embedding models have high accuracy when processing general text matching tasks, but when applied to certain specific fields, the model effect drops sharply. For example, text contains a large number of abbreviations, repeated words, combined words, and professional terms, etc., which will affect the text matching effect, and cannot meet the processing needs of text in specific fields, so it is necessary to fine-tune the embedding model.

[0004] Therefore, for some asymmetric text in certain specific fields, it is necessary to provide an embedding model fine-tuning method for asymmetric text matching to improve the matching accuracy of embedding vectors. SUMMARY

[0005] The present application provides an embedding model fine-tuning method and system for asymmetric text matching to improve the matching accuracy of embedding vectors to solve the technical problems existing in the prior art.

[0006] According to a first aspect of the present application, an embedding model fine-tuning method for asymmetric text matching is provided, comprising:

[0007] According to the to-be-retrieved text and the prompt word, a plurality of non-repeating query texts are generated, and the generated query texts are filtered; the to-be-retrieved text and the query text pair are formed according to the one-to-one pairing principle until a data set containing all to-be-retrieved text and query text pairs is generated;

[0008] The embedding model is trained using the data set, and through the back propagation of the training process, the embedding model output is iteratively approximated to the true value in a way of minimizing the contrast loss function, so as to obtain an optimized embedding model.

[0009] On the basis of the above technical solution, the present application can also be improved as follows.

[0010] Optionally, the generating a plurality of non-repeating query texts according to the text to be retrieved and the prompt word comprises:

[0011] The text to be retrieved and the corresponding prompt word are output to an AI large model to obtain a plurality of non-repeating query texts generated by the AI large model, wherein the number of the query texts is determined according to the length of the text to be retrieved.

[0012] Optionally, the screening the generated query texts comprises:

[0013] In the plurality of generated query texts, the query texts irrelevant to the content of the text to be retrieved and / or containing text errors are removed.

[0014] Optionally, in the process of pairing the text to be retrieved with the query texts one by one, the data set comprises a plurality of samples, and each sample comprises a text to be retrieved and a query text, wherein the same text to be retrieved corresponds to a plurality of query texts.

[0015] Optionally, the embedding model is trained by using the data set, and through back propagation in the training process, the embedding model outputs an iterative approximation of the true value in a manner of minimizing the contrast loss function, so as to obtain an optimized embedding model, comprising:

[0016] Any text to be retrieved and query text pair in the data set is input into the embedding model as a sample pair, a single sample pair comprises a query text Q and a text to be retrieved K, and the total number of sample pairs in the data set is n;

[0017] The query text Q is input into a Q encoding module to generate an embedding vector q with a length of m, and the text to be retrieved K is input into a K encoding module to generate an embedding vector k with a length of m;

[0018] An encoding matrix is set to store all vectors k, which are spliced by n vectors k with a length of m, each vector k corresponds to a unique text to be retrieved, and each text to be retrieved will update the old vector k after generating a new vector k;

[0019] The vector q and the updated encoding matrix are used for similarity calculation to obtain a similarity result vector with a length of n;

[0020] The loss value of the similarity result vector is calculated by using a contrast loss function, the Q encoding module is updated through back propagation in the training process, and the internal weights of the updated Q encoding module are used to update the internal weights of the K encoding module in a preset proportion, so as to obtain an optimized embedding model.

[0021] Optionally, the Q encoding module and the K encoding module are composed of a text encoding model, and the weights of the Q encoding module and the K encoding module are the same in the initial state.

[0022] Optionally, the similarity calculation method is inner product similarity, cosine similarity and / or Euclidean similarity calculation.

[0023] According to a second aspect of the present application, an embedding model fine-tuning system for asymmetric text matching is provided, comprising:

[0024] A data completion module is configured to generate a plurality of non-repeated query texts according to the to-be-retrieved texts and the prompt words, filter the generated query texts, and form to-be-retrieved text and query text pairs according to a one-to-one pairing principle until a data set containing all to-be-retrieved text and query text pairs is generated.

[0025] A fine-tuning module is configured to train the embedding model using the data set, and through back propagation in the training process, the embedding model output iteratively approaches the true value in a manner of minimizing the contrast loss function, so as to obtain an optimized embedding model.

[0026] According to a third aspect of the present application, an electronic device is provided, comprising a memory and a processor, wherein the processor is configured to implement the steps of the above-mentioned embedding model fine-tuning method for asymmetric text matching when executing a computer management program stored in the memory.

[0027] According to a fourth aspect of the present application, a computer readable storage medium is provided, which stores a computer management program, wherein the computer management program is configured to implement the steps of the above-mentioned embedding model fine-tuning method for asymmetric text matching when executed by a processor.

[0028] The embedding model fine-tuning method, system, electronic device and storage medium for asymmetric text matching provided by the present application can effectively expand the training data and improve the model training efficiency by using the data completion strategy. The use of the contrast learning framework enables the model to effectively overcome the problems of difficulty in extracting key information and establishing the relevance and correspondence between texts caused by the characteristics of asymmetric texts, such as different lengths, large structural differences and scattered key information, extract information related to the text matching task, weaken useless information, and ensure the convergence of model training, thereby improving the matching accuracy of embedding vectors. BRIEF DESCRIPTION OF DRAWINGS

[0029] Figure 1 A flowchart of the embedding model fine-tuning method for asymmetric text matching provided by the present application is provided.

[0030] Figure 2 A data completion schematic diagram is provided for an embodiment.

[0031] Figure 3A schematic diagram of the fine-tuning process provided for an embodiment;

[0032] Figure 4 A block diagram of an embedding model fine-tuning system for asymmetric text matching provided for the present application;

[0033] Figure 5 A schematic diagram of a possible hardware structure of an electronic device provided for the present application;

[0034] Figure 6 A schematic diagram of a possible hardware structure of a computer readable storage medium provided for the present application. DETAILED DESCRIPTION

[0035] The specific embodiments of the present application are described in further detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not intended to limit the scope of the present application.

[0036] Figure 1 A flowchart of an embedding model fine-tuning method for asymmetric text matching provided for the present application, as shown in Figure 1 The method comprises steps S1-S2:

[0037] S1. Data completion: generate a plurality of non-repeating query texts according to the texts to be retrieved and the prompt words, filter the generated query texts; form pairs of texts to be retrieved and query texts according to the one-to-one pairing principle until a data set containing all pairs of texts to be retrieved and query texts is generated;

[0038] S2. Model fine-tuning (model training): train the embedding model using the data set, through backpropagation in the training process, in a way that minimizes the contrastive loss function, constantly change the embedding model weights to make the embedding model output iterative approximation to the true value, to obtain an optimized embedding model.

[0039] It can be understood that based on the defects in the background art, the embodiment of the application proposes an embedding model fine-tuning method for asymmetric text matching. The method of the application aims at the problem that there are a large number of to-be-retrieved texts in the asymmetric text matching task, but there is a lack of query texts, for example, in the knowledge question answering task, there are a large number of content samples (to-be-retrieved texts), but there is a lack of question samples (query texts). In view of the problem of incomplete data in the asymmetric text task, the application designs a strategy of using an AI large language model to complete the data, which can effectively expand the training data and improve the model training efficiency. Since the asymmetric text may have the characteristics of long and short, large structural difference, and scattered key information, it is difficult for an ordinary model to extract key information and establish the relevance and correspondence between texts; at the same time, the asymmetric text often has the characteristics of “one-to-many”, that is, one to-be-retrieved text can match multiple different query texts, so that the model is difficult to converge in training. In view of the above problems, the application designs a contrastive learning framework, which can effectively overcome the above problems of asymmetric text, extract information related to the text matching task, weaken useless information, and at the same time ensure that the model training can converge, thereby improving the matching accuracy of the embedding vector.

[0040] In a possible embodiment, in step S1, data completion mainly includes sub-steps S101-S104.

[0041] The principle of data completion is as shown in Figure 2 In the scene where the query text is lacking, the AI large language model is used to generate the query text for model training. The specific steps are as follows:

[0042] S101. Data generation: taking the to-be-retrieved text as input, and designing a corresponding prompt word, the AI large model generates a plurality of non-repeated query texts. For example, in the problem task, the AI large model can be added with the following prompt word “please propose 5 related questions according to the given text”. According to the length of the to-be-retrieved text content, the number of generated query texts is flexibly set.

[0043] S102. Data screening: using artificial or AI model to screen the query texts generated in step S101, and eliminating the contents that are not related to the to-be-retrieved text content and contain text errors.

[0044] S103. Data pairing: according to the “one-to-one pairing” principle, to-be-retrieved text and query text pairs are formed, the to-be-retrieved text can be paired multiple times, and the query text can be paired only once.

[0045] S104. Repeat steps S101-S103 to complete the data completion of all to-be-retrieved texts, and generate a data set containing to-be-retrieved text and query text pairs. The generated data set is used for subsequent model fine-tuning (model training).

[0046] In one possible implementation manner, the model fine-tuning (model training) procedure of step S2 is as shown in Figure 3 , and the specific technical route mainly includes steps S201-S207.

[0047] S201. The model input is a sample pair, and a single sample pair contains a query text Q and a retrieval text K. The total number of retrieval texts in the model training data set is n, that is, the number of sample pairs is n.

[0048] S202. Construct a Q encoding module, which is used to encode the query text Q to generate an embedding vector q with a length of m. The Q encoding module is internally composed of a text encoding model, which can be a pre-trained language model such as BERT, GPT, etc.

[0049] S203. Construct a K encoding module, which is used to encode the retrieval text K to generate an embedding vector k with a length of m. The K encoding module has the same structure as the Q encoding module (both have the same weights in the initial state).

[0050] S204. Construct an encoding matrix, which is used to store all k vectors, which are concatenated by n k vectors with a length of m. Each k vector corresponds to a unique retrieval text K. After generating a new vector k, the old vector k is overwritten, thereby updating the encoding matrix.

[0051] It can be understood that the embedding model has problems such as large consumption of computing resources, large training fluctuation, and slow convergence speed due to large training data volume. The embodiment of the present application designs an encoding matrix with an updating mechanism, which can effectively reduce the computing resource and training fluctuation by reducing the fluctuation amplitude of the contrast term in the loss function, thereby accelerating the convergence of the embedding model.

[0052] S205. Use the vector q and the updated encoding matrix to perform similarity calculation, including but not limited to inner product, cosine similarity, and Euclidean similarity.

[0053] S206. Calculate the loss value of the similarity result using the contrast loss function, including but not limited to InfoNCEloss (contrast learning loss).

[0054] S207. After obtaining the loss value of the similarity result, update the Q encoding module through the back propagation of the neural network. The K encoding module does not participate in the back propagation, but copies the internal weights of the Q encoding module and updates the internal weights of the K encoding module by a predetermined proportion, thereby realizing the fine-tuning (training) of the embedding module.

[0055] In order to more clearly illustrate the present application, a specific implementation scenario is taken as an example.

[0056] 1. Data generation. The text to be retrieved is input, and the corresponding prompt word is designed, and the AI large model generates several non-repeated query texts. According to the length of the text to be retrieved, the number of generated query texts is flexibly set, and in the present application, the number of generated texts is about: 2-4 / 100 words, that is, 2-4 query texts are generated for every 100 words in the text to be retrieved. The generated query document does not necessarily cover the content of the text to be retrieved.

[0057] 2. Data filtering. The query texts generated in step 1 are filtered using artificial or AI model, and the contents unrelated to the content of the text to be retrieved and containing text errors are removed.

[0058] 3. Data pairing. According to the "one-to-one pairing" principle, the text to be retrieved and the query text pair are formed, and the text to be retrieved can be paired multiple times, and the query text can be paired only once.

[0059] 4. Repeat steps 1-3 to complete the data completion of all texts to be retrieved, and generate a data set containing the text to be retrieved and the query text pair for subsequent model fine-tuning. If the data in the task does not need to be completed, only step 3 is needed, and the corresponding data set is formed.

[0060] 5. The query text Q and the text to be retrieved K in a data pair are input into the Q encoding module and the K encoding module respectively, and the corresponding q vector and k vector are generated, and the vector length of the q vector and the k vector is m. The Q encoding module and the K encoding module are language pre-training models with the same initial weight parameters and structure, including but not limited to bert, GPT and other models.

[0061] 6. The encoding matrix is initialized with a random number, with a dimension of n*m. n represents the total number of texts to be retrieved, and m is the length of a single vector. Each text to be retrieved corresponds to a vector. Each time a new k vector is generated, the corresponding old k vector is covered, and the encoding matrix is updated.

[0062] 7. The similarity is calculated using the q vector and the updated encoding matrix, and the similarity calculation result is a vector with a length of n, that is, the similarity of the q vector and each text to be retrieved.

[0063] 8. The loss function is calculated using InfoNCE loss (contrastive learning loss) and the like, and the Q encoding module is updated in reverse.

[0064] 9. After updating the Q encoding module, its weight parameters are copied and updated to the K encoding module weight according to a predetermined proportion. In this way, the weight of the encoder K will not fluctuate greatly, effectively reducing the training fluctuation and making the model converge quickly.

[0065] 10. Repeat steps 5-9 until the loss function reaches a certain threshold or the number of training reaches a set value.

[0066] Figure 4 A structure diagram of an embedding model fine-tuning system for asymmetric text matching provided by an embodiment of the present application is shown in Figure 4 The embedding model fine-tuning system for asymmetric text matching comprises a data completion module and a fine-tuning module, wherein:

[0067] The data completion module is configured to generate a plurality of non-repeated query texts according to the texts to be retrieved and the prompt words, and filter the generated query texts; and is further configured to form pairs of the texts to be retrieved and the query texts according to a one-to-one pairing principle until a data set containing all pairs of the texts to be retrieved and the query texts is generated.

[0068] The fine-tuning module is configured to train the embedding model using the data set, and through back propagation in the training process, constantly change the embedding model weights in a way that the contrast loss function is minimized, so that the embedding model output iteratively approaches the true value, to obtain an optimized embedding model.

[0069] It can be understood that the embedding model fine-tuning system for asymmetric text matching provided by the present application corresponds to the embedding model fine-tuning method for asymmetric text matching provided by the aforementioned embodiments, and the technical features of the embedding model fine-tuning system for asymmetric text matching can refer to the technical features of the embedding model fine-tuning method for asymmetric text matching, which will not be described here.

[0070] Please refer to Figure 5 , Figure 5 An embodiment of the electronic device provided by the present application is shown in Figure 5 The electronic device 500 comprises a memory 510, a processor 520, and a computer program 511 stored in the memory 510 and executable on the processor 520, and the processor 520 implements the following steps when executing the computer program 511:

[0071] According to the texts to be retrieved and the prompt words, a plurality of non-repeated query texts are generated, and the generated query texts are filtered; pairs of the texts to be retrieved and the query texts are formed according to a one-to-one pairing principle until a data set containing all pairs of the texts to be retrieved and the query texts is generated.

[0072] The embedding model is trained using the data set, and through back propagation in the training process, the embedding model weights are constantly changed in a way that the contrast loss function is minimized, so that the embedding model output iteratively approaches the true value, to obtain an optimized embedding model.

[0073] Please refer to Figure 6 ,Figure 6 An embodiment of a computer readable storage medium provided by the present application is shown. As shown, the embodiment provides a computer readable storage medium 600, which stores a computer program 611, and the computer program 611 is executed by a processor to implement the following steps: Figure 6

[0074] According to the text to be searched and the prompt word, a plurality of non-repeating query texts are generated, the generated query texts are screened, and the text to be searched and the query text are paired according to the one-to-one pairing principle until a data set containing all the text to be searched and the query text pair is generated.

[0075] The embedding model is trained using the data set, and through the back propagation of the training process, the embedding model weight is changed constantly in a way that the contrast loss function is minimized, so that the embedding model output iteratively approaches the true value, to obtain an optimized embedding model.

[0076] The embodiment of the present application provides an embedding model fine-tuning method and system for asymmetric text matching, and the following advantages are provided compared with the prior art:

[0077] 1. The AI model is used to generate training data, and the whole model fine-tuning process belongs to unsupervised or semi-supervised learning, which is different from other supervised learning models, and solves the problem of incomplete training data. Since contrast learning is used, the generated query document does not have to completely cover the content of the text to be searched, and the model can automatically learn the ability to extract key information.

[0078] 2. The model uses a contrast learning framework, which is different from the regression or classification learning framework used by traditional embedding models, and can extract more fine-grained language / lexical features, thereby improving the accuracy of text matching.

[0079] 3. The input data can realize that one text to be searched corresponds to multiple query texts, which is different from the traditional one-to-one data mode, and improves the utilization efficiency of data.

[0080] 4. The coding matrix with the coverage mechanism is used to effectively reduce the training fluctuation and quickly converge.

[0081] It should be noted that in the above embodiments, the description of each embodiment is focused on, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0082] ​Those skilled in the art will appreciate that embodiments of the present application can be devised for a variety of applications. It is intended that the present application be limited only by the scope of the appended claims, and it is intended that various modifications and alterations made by those skilled in the art be considered as within the scope of the present application. The embodiments of the present application will be described with reference to the attached drawings, wherein:

[0083] The present application is described in reference to the drawings using a flowchart and / or a block diagram of the method, apparatus (system) and computer program product according to embodiments of the application. It will be understood that each block of the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0084] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0086] While the preferred embodiments of the application have been described, additional variations and modifications can be made to the embodiments by those skilled in the art once they learn of the basic inventive concepts. Therefore, the appended claims are intended to cover all such modifications and variations as fall within the scope of the present application.

[0087] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. An embedding model fine-tuning method for asymmetric text matching, characterized in that, The method comprises the following steps: According to the to-be-retrieved text and the prompt word, a plurality of non-repeating query texts are generated, and the generated query texts are screened; According to the one-to-one pairing principle, to-be-retrieved text and query text pairs are formed until a data set containing all to-be-retrieved text and query text pairs is generated, wherein the same to-be-retrieved text corresponds to a plurality of query texts; The embedding model is trained using the data set, and through back propagation in the training process, the embedding model output iteratively approaches the true value in a way that minimizes the contrast loss function, and the embedding model weights are constantly changed to obtain an optimized embedding model, comprising: Input any to-be-retrieved text and query text pair in the data set into the embedding model as a sample pair, a single sample pair includes one query text Q and one to-be-retrieved text K, and the total number of sample pairs in the data set is n; Input the query text Q into the Q encoding module to generate an embedding vector q with a length of m, and input the to-be-retrieved text K into the K encoding module to generate an embedding vector k with a length of m; Set the encoding matrix to store all vectors k, which are spliced from n vectors k with a length of m, and each vector k corresponds to a unique to-be-retrieved text, and each to-be-retrieved text will update the old vector k after generating a new vector k; Use the vector q and the updated encoding matrix to calculate the similarity, and obtain a similarity result vector with a length of n; Use the contrast loss function to calculate the loss value of the similarity result vector, update the Q encoding module through back propagation in the training process, and update the internal weights of the K encoding module according to the updated internal weights of the Q encoding module in a preset proportion to obtain an optimized embedding model.

2. The method of claim 1, wherein, The method comprises the following steps: Output the to-be-retrieved text and the corresponding prompt word into the AI large model to obtain a plurality of non-repeating query texts generated by the AI large model, wherein the number of query texts is determined according to the length of the to-be-retrieved text.

3. The method of claim 1, wherein, The method comprises the following steps: In the generated plurality of query texts, remove the query texts that are not related to the content of the to-be-retrieved text and / or contain text errors.

4. The method of claim 1, wherein, In the process of forming to-be-retrieved text and query text pairs according to the one-to-one pairing principle, the data set includes a plurality of samples, each sample includes a to-be-retrieved text and a query text, and the same to-be-retrieved text corresponds to a plurality of query texts.

5. The method of claim 1, wherein, The Q encoding module and the K encoding module are composed of a text encoding model, and the weights of the Q encoding module and the K encoding module are the same in the initial state.

6. The method of claim 1, wherein, The similarity calculation method is inner product similarity, cosine similarity or Euclidean similarity calculation.

7. An embedding model fine-tuning system for asymmetric text matching, characterized in that, The method comprises the following steps: A data completion module is used to generate a plurality of non-repeating query texts according to the to-be-retrieved text and the prompt word, screen the generated query texts, and form to-be-retrieved text and query text pairs according to the one-to-one pairing principle until a data set containing all to-be-retrieved text and query text pairs is generated, wherein the same to-be-retrieved text corresponds to a plurality of query texts. The fine-tuning module is used to train the embedding model with the data set, and through the back propagation of the training process, the embedding model output iteratively approaches the true value in the way of minimizing the contrastive loss function, so as to obtain the optimized embedding model, comprising: Inputting any one of the data set to be retrieved text and the query text pair as a sample pair into the embedding model, a single sample pair comprising a query text Q and a to-be-retrieved text K, the total number of sample pairs in the data set being n; Inputting the query text Q into the Q encoding module to generate an embedding vector q with a length of m, and inputting the to-be-retrieved text K into the K encoding module to generate an embedding vector k with a length of m; Setting an encoding matrix for storing all vectors k, which are spliced by n vectors k with a length of m, each vector k corresponding to a unique to-be-retrieved text, and each to-be-retrieved text updating the old vector k after generating a new vector k; Using the vector q and the updated encoding matrix to perform similarity calculation to obtain a similarity result vector with a length of n; Using the contrastive loss function to calculate the loss value of the similarity result vector, updating the Q encoding module through the back propagation of the training process, and updating the internal weight of the K encoding module according to the preset proportion after updating the internal weight of the Q encoding module, so as to obtain the optimized embedding model.

8. An electronic device, comprising: The memory, the processor, the processor is used to execute the computer management class program stored in the memory, and realize the steps of the fine-tuning method of the embedding model for asymmetric text matching according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, A computer readable storage medium having stored thereon a computer management class program, the computer management class program being executed by a processor to realize the steps of the fine-tuning method of the embedding model for asymmetric text matching according to any one of claims 1-6.

Citation Information

Patent Citations

  • Method and device for training semantic feature vector generation model and semantic search

    CN116450778A

  • Method and equipment for converting text into SQL (Structured Query Language) statement

    CN116629227A