Domain intention recognition method based on positive and negative correlation sample fine-tuning large model
By fine -tuning large models under specific industry data, using positive and negative related sample examples and industry -specific Embedding models to solve the problem of limited intent to identify in specific fields in specific fields, and achieve better intent to identify effects and understanding ability.
Patent Information
- Application Number
- CN202411429061.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-28
AI Technical Summary
Existing large models have limited intent recognition capabilities in specific fields or industries, especially when there are many intent categories and unbalanced data, resulting in poor recognition results.
By fine -tuning large models under specific industry data, we use a positive and negative related sample minimum method to build a specific EMBEDDING model and vector line library in the industry, conduct similar sentence retrieval and candidate intention, and finally fine -tuned large models to improve the intent to identify the ability to identify the ability to identify the ability to identify the ability to identify the ability. Essence
Effectively enhance the intent to identify the intention of large models in specific fields or industries, adapt to multi -intention scenes, reduce the problem of missing recall and error recall, and improve the understanding and recognition ability of the model in the field.
Smart Images

Figure CN119378560A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing technology, and specifically is a method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples. Background Art
[0002] In intelligent customer service applications, the core module of conversational robots is intent recognition, which aims to understand user questions and give the correct intent category. For different industries, the defined intent sets are different. Before the emergence of large models, intent recognition mostly used traditional deep learning models or BERT-type pre-trained language models, which require industry-specific data for training or fine-tuning. The model effect depends on the quality and richness of the data. Especially when there are many intent categories, data imbalance is a common problem. Intents with small amounts of data often have limited recognition effects; and the scale and complexity of traditional models also limit the capabilities of the model.
[0003] Since the large model has integrated the relevant knowledge of large-scale data in the pre-training stage and the instruction fine-tuning stage, the model already has a certain expressive ability. In the prediction stage, it can be directly classified based on the instruction prompt words. However, for industry scenarios containing hundreds or even thousands of intents, due to the limitation of context length, it may not be possible to give all the intent names in the prompt words, and the model is prone to forgetting. In order to solve the problem of multiple intents, similar sentences and corresponding intents of the current user's question can be retrieved through the retrieval-augmented generation (RAG) method to limit the number of intents provided to the large model. Although this method alleviates the recognition problem of multiple intents to a certain extent, it still affects the recognition effect of the large model due to missed recall and wrong recall problems. Moreover, the recognition ability of the large model depends on the data seen in the pre-training and instruction fine-tuning stages. If the amount of data in a certain industry in the pre-training stage is small, then the model lacks knowledge and understanding of the industry. The lack of industry information will limit the understanding and recognition ability of the large model in this field, affecting the recognition effect.
[0004] Therefore, there is a need for an intent recognition method based on a large model for specific fields or industries, which can adapt to multi-intent recognition scenarios while having industry recognition capabilities. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention provides a domain intent recognition method based on fine-tuning a large model based on positive and negative correlation samples. In scenarios where intent recognition or classification relies on a large model, the present invention can solve the problem that the large model has limited intent recognition capabilities in specific fields or industries due to the lack of industry information. By fine-tuning the large model based on specific industry data, the recognition effect of the industry is improved. At the same time, for industries with a large number of intents, good recognition effects can also be achieved.
[0006] The technical solution of the present invention is as follows: A method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples, the steps are as follows:
[0007] S1. Sentence vector generation: fine-tuning an industry-specific embedding model through the industry’s unlabeled data;
[0008] S2. Build a vector index. Generate a vector of industry labeled data through the embedding model obtained in step S1 and build a vector index library.
[0009] S3, construct candidate intents and examples, perform similar sentence retrieval based on the index library, and generate candidate intents and examples for the current sample;
[0010] S4. Fine-tune the large model and construct fine-tuning data to fine-tune the large model.
[0011] Preferably, step S1 in the sentence vector generation stage aims to generate vector representations for industry corpus and user query to provide input data for the subsequent retrieval stage; although there are some general embedding models for retrieval, the retrieval capabilities for specific industries are still limited; in order to enhance the recall and retrieval capabilities of specific vertical fields, industry-specific embedding models are required.
[0012] Preferably, the training method of the specific industry-specific embedding model in step S1 is as follows:
[0013] 1) Data preparation: Prepare a large amount of unlabeled data set U in the industry;
[0014] 2) Model preparation: Two models need to be prepared, one as the teacher model for sample screening, and the other as the student model for fine-tuning. Through API calls, the qwen series model is selected as the teacher model, denoted as model T, and BGE-large-zh-v1.5 is selected as the student model, denoted as model S.
[0015] 3) Construction of positive and negative samples: Each sample u in the dataset U iInput the model S to obtain the vector set HU; by calculating the cosine similarity between the vectors, give each sample u in the data set U i Recall the topK similar sentences; take the similar sentences with similarity scores higher than the threshold as x i The candidate positive sample set x takes similar sentences with similarity scores between 0.4 and 0.7 as the candidate negative sample set; sort the samples in the candidate positive sample set from large to small according to similarity, and take the current sample x i The candidate positive samples are input to the model T to let it judge their similarity, and the candidate positive samples judged by the model T as similar are added to x i The positive sample set P i ={p k ,k∈R K} (K represents the size of the positive sample set), until the set size reaches the preset value; for the candidate negative sample set, randomly select a negative sample and let the model T judge whether the negative sample is different from the current sample x i The similarity of x is calculated by adding the samples judged as dissimilar by model T to x i The negative sample set N i ={n j ,j∈R J} (J represents the size of the negative sample set), until the size of the negative sample set meets the preset value; select the positive sample set size K = 1, the negative sample set size J = 5;
[0016] 4) Model fine-tuning: Through the construction of positive and negative samples, each fine-tuning data can be obtained in the format of {x, P, N}, where x is the current question, P is the positive sample set of x, and N is the negative sample set of x. All fine-tuning data are input into the model S for fine-tuning, and the fine-tuned model (denoted as S') is stored for vector generation in subsequent steps.
[0017] Preferably, in the step S2, during the vector index building phase, the corpus vectors generated in step 1 are stored in the database to generate a vector index.
[0018] Preferably, the specific execution steps in step S2 are as follows:
[0019] 1) Data preparation: In the industry intent recognition task, it is necessary to prepare a labeled dataset C = {X, Y} for classification, that is, for each input sentence x i There is a corresponding intent label y i ;
[0020] 2) Index construction: The vector model S' obtained in step S1 is for each input sample x in the dataset C i Generate the corresponding vector and get the vector set H of labeled data T={h i ,i∈R N}(N represents the size of the data set); Generate the vector set H through the vector retrieval tool Faiss T The vector index library I is used to store the vector.
[0021] Preferably, when the big model is used to classify intent in step S3, it is necessary to provide the big model with optional intents; in a multi-intent scenario, in order to ensure the effectiveness of the model, it is necessary to limit the number of intents provided to the big model; at the same time, in order to enhance the big model's ability to understand specific industries, in addition to the positively correlated samples where the correct intent is in the candidate intents, negatively correlated samples where the correct intent is not in the candidate intents are also constructed.
[0022] Preferably, the specific execution steps of constructing candidate intents and example sentences in step S3 are as follows:
[0023] 1) Traverse each sample x in the labeled dataset C i In the index library I generated in step S2, recall the topK similar sentences (excluding x i ), each similar sentence has a corresponding intention, and these intentions are used as samples x i The candidate intent of i The candidate intention and example sentence set of l i Indicates candidate intention, S i Indicates candidate intention i The example sentence set of example sentence set size | S i |The maximum is 5, the size of the set L |L i | Sort by similarity and take at most the top 10 candidate intents;
[0024] 2) According to y i Is it in the candidate intention set L i In the above example, the candidate intent set is divided into L P and L N , L P is a set of positively correlated samples, that is, the candidate intent set contains the correct intent y i ; L N is a negatively correlated sample set, that is, the candidate intent set does not contain the correct intent L P , L P and L N The proportions are r and 1-r respectively;
[0025] 3) After similar sentences are retrieved, L N The ratio often does not reach the expected value, and it is necessary to expand this part of the sample. First, randomly select a sample x i , then in addition to yi Randomly select k intentions from other intentions as candidate intentions (k∈[1,10]), and calculate the current sample x i The cosine similarity with all the corpora under these k intents. For each candidate intent, m samples with similarity greater than 0.5 are randomly selected as examples of the intent (m∈[1,5]). This process is repeated until L N ratio meets the requirement.
[0026] Preferably, in step S4, after the previous step, each piece of data includes an input sample x i , correct intention i , and the candidate intention and example sentence set L i ; Use these domain data to fine-tune the large model and obtain an intent recognition model for a specific domain.
[0027] Preferably, the specific fine-tuning steps of step S4 are as follows:
[0028] 1) Intent shuffling: Shuffle the order of candidate intents and the order of example sentences for each candidate intent to prevent the model from learning the position information of the correct intent in the candidate intent and ignoring the meaning of the intent itself;
[0029] 2) Construct prompt words: transform sample x i and the candidate intention and example sentence set L i Input it into the prompt word template to generate the instruction prompt word Prompt for the intent recognition task;
[0030] 3) Construct fine-tuning data: The large model fine-tuning data consists of prompt words and output. For each fine-tuning data, prompt word Prompt = Template (x i ,L i ), large model output Output = y i ;
[0031] 4) Base model selection: Select a large instruction version model as the base model for fine-tuning;
[0032] 5) Fine-tuning: Provide the sorted fine-tuning data to the base model, and use the LORA fine-tuning method to fine-tune the large model; store the fine-tuned large model M for the subsequent prediction stage of intent recognition;
[0033] The method of screening candidate intents through similar sentences can adapt to classification scenarios with a large number of intents; and the method of integrating positive and negative correlated candidate intents and examples in fine-tuning data enables the large model to fully understand the intent, rather than relying entirely on the provided candidate intents for intent recognition. Even when the correct intent is not among the candidate intents, better recognition results can be achieved.
[0034] Preferably, in the step S1-sentence vector generation stage, different large models and sentence vector generation models can be selected as basic models for fine-tuning; in the process of constructing positive and negative samples, the similarity can be calculated by other similarity measurement methods such as Euclidean distance; in addition to selecting candidate negative samples according to a specific score interval, they can also be randomly selected;
[0035] In step S3-constructing candidate intents and example sentences, the similarity measurement method for vector recall can use other methods besides cosine similarity; similar sentences with a similarity threshold higher than a certain threshold can also be selected as candidate intent example sentences; L N The sample can also be expanded directly by random sampling, as long as L N The intention in does not contain the correct intention;
[0036] In step S4 - the large model fine-tuning stage, the prompt word template can be different, as long as the task description is clear; the base large model can also be different; and the fine-tuning method can also be different.
[0037] The present invention has the following beneficial effects and advantages: in scenarios where large models are relied upon for intent recognition or classification, it can solve the problem of limited intent recognition capabilities of large models in specific fields or industries due to the lack of industry information, and improve industry recognition effects by fine-tuning the large model based on specific industry data; at the same time, good recognition effects can also be achieved for industries with a large number of intents. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION
[0039] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the invention, so the present invention is not limited by the specific implementation disclosed below.
[0040] Example 1
[0041] A domain intent recognition method based on fine-tuning a large model with positive and negative correlation samples, such as Figure 1As shown in the figure, it is divided into four steps: S1 first fine-tunes an industry-specific embedding model through the industry's unlabeled data; S2 then generates vectors of industry labeled data through this embedding model and builds a vector index library; S3 then performs similar sentence retrieval based on the index library to generate candidate intents and example sentences for the current sample. S4 Finally, constructs fine-tuning data to fine-tune the large model. The specific implementation of each step will be described in detail below.
[0042] Step S1-sentence vector generation
[0043] In the sentence vector generation stage, the goal is to generate vector representations for industry corpora and user queries to provide input data for the subsequent retrieval stage. Although there are some general embedding models for retrieval, the retrieval capabilities for specific industries are still limited. In order to enhance the recall and retrieval capabilities of specific vertical fields, industry-specific embedding models are required.
[0044] The following will explain how to train specific industry embedding models.
[0045] 1. Data preparation: Prepare a large amount of unlabeled data sets U in the industry
[0046] 2. Model preparation: Two models need to be prepared, one as a teacher model for sample screening, and the other as a student model for fine-tuning. In this invention, the qwen series model is selected as the teacher model (denoted as model T) through API calls, and BGE-large-zh-v1.5 is selected as the student model (denoted as model S)
[0047] 3. Construction of positive and negative samples: Each sample u in the dataset U i Input model S to get vector set H U By calculating the cosine similarity between vectors, for each sample u in the dataset U i Recall the topK similar sentences. The similar sentences with similarity scores higher than the threshold (the threshold in this invention is 0.85) are taken as x i The candidate positive sample set x takes similar sentences with similarity scores between 0.4 and 0.7 as the candidate negative sample set. Sort the samples in the candidate positive sample set from large to small according to similarity, and take the current sample x i The candidate positive samples are input to the model T to let it judge their similarity, and the candidate positive samples judged by the model T as similar are added to x i The positive sample set P i ={p k ,k∈R K} (K represents the size of the positive sample set) until the set size reaches the preset value. For the candidate negative sample set, randomly select a negative sample and let the model T judge whether the negative sample is different from the current sample x i The similarity of x is calculated by adding the samples judged as dissimilar by model T to x i The negative sample set N i ={n j ,j∈R J} (J represents the size of the negative sample set), until the size of the negative sample set meets the preset value. In the present invention, the positive sample set size K=1 and the negative sample set size J=5 are selected.
[0048] 4. Model fine-tuning: Through the construction of positive and negative samples, each fine-tuning data can be obtained in the format of {x, P, N}, where x is the current question, P is the positive sample set of x, and N is the negative sample set of x. All fine-tuning data are input into the model S for fine-tuning, and the fine-tuned model (denoted as S') is stored for vector generation in subsequent steps.
[0049] Step S2: Build vector index
[0050] In the vector index building phase, the corpus vectors generated in step S1 are stored in the database to generate a vector index.
[0051] The specific execution steps are as follows:
[0052] 1. Data preparation: In the industry's intent recognition task, it is necessary to prepare a labeled dataset C = {X, Y} for classification, that is, for each input sentence x i There is a corresponding intent label y i .
[0053] 2. Index construction: The vector model S' obtained in step S1 is for each input sample x in the dataset C i Generate the corresponding vector and get the vector set H of labeled data T ={h i ,i∈R N}(N represents the size of the data set). Generate the vector set H using the vector search tool Faiss T The vector index library I is used to store the vector.
[0054] Step S3: Construct candidate intents and examples
[0055] When using a large model for intent classification, it is necessary to provide the large model with optional intents. In a multi-intent scenario, in order to ensure the effectiveness of the model, it is necessary to limit the number of intents provided to the large model. At the same time, in order to enhance the large model's ability to understand specific industries, in addition to the positively correlated samples where the correct intent is in the candidate intents, additionally negatively correlated samples are constructed where the correct intent is not in the candidate intents.
[0056] The specific execution steps are as follows:
[0057] Traverse each sample x in the labeled dataset C i In the index library I generated in step S2, recall the topK similar sentences (excluding x i ), each similar sentence has a corresponding intention, and these intentions are used as samples x i The candidate intent of i The candidate intention and example sentence set of l i Indicates candidate intention, S i Indicates candidate intention i The example sentence set of the present invention has a size of |S i |The maximum is 5, the size of the set L |L i |Sort by similarity and take at most the top 10 candidate intents.
[0058] According to y i Is it in the candidate intention set L i In the above example, the candidate intent set is divided into L P and L N , L P is a set of positively correlated samples, that is, the candidate intent set contains the correct intent y i ; L N is a negatively correlated sample set, that is, the candidate intent set does not contain the correct intent L P , L P and L N The proportions are r and 1-r respectively.
[0059] After similar sentence retrieval, L N The proportion of often does not reach the expected value, and it is necessary to expand this part of the sample. First, randomly select a sample x i , then in addition to y i Randomly select k intentions from other intentions as candidate intentions (k∈[1,10]), and calculate the current sample x i The cosine similarity with all the corpora under these k intents. For each candidate intent, m samples with similarity greater than 0.5 are randomly selected as examples of the intent (m∈[1,5]). This process is repeated until L NThe ratio of meets the requirements. The value of the ratio r in the present invention is 0.6.
[0060] Step S4 - Fine-tuning the large model
[0061] After the previous step, each piece of data includes an input sample x i , correct intention i , and the candidate intention and example sentence set L i . The large model is fine-tuned using these domain data to obtain an intent recognition model for a specific domain.
[0062] The specific fine-tuning steps are as follows:
[0063] 1. Intent shuffling: Shuffle the order of candidate intents and the order of example sentences for each candidate intent to prevent the model from learning the position information of the correct intent in the candidate intent and ignoring the meaning of the intent itself
[0064] 2. Construct prompt words: transform sample x i and the candidate intention and example sentence set L i Input it into the prompt word template to generate the command prompt word Prompt for the intent recognition task. The following is an example of a prompt word template:
[0065]
[0066] 3. Construct fine-tuning data: The large model fine-tuning data consists of prompt words and output. For each fine-tuning data, prompt word Prompt = Template (x i ,L i ), large model output Output = y i
[0067] 4. Base model selection: select a large model of the instruction version as the base model for fine-tuning. The present invention adopts the Qwen2-7B-Instruct model.
[0068] 5. Fine-tuning: Provide the sorted fine-tuning data to the base model, and use the LORA fine-tuning method to fine-tune the large model. Store the fine-tuned large model M for the subsequent prediction stage of intent recognition.
[0069] The method of screening candidate intents through similar sentences can adapt to classification scenarios with a large number of intents. The method of integrating positive and negative related candidate intents and samples in fine-tuning data allows the large model to fully understand the intent, rather than relying entirely on the provided candidate intents for intent recognition. Even when the correct intent is not among the candidate intents, better recognition results can be achieved.
[0070] Example 2
[0071] In step S1-sentence vector generation stage, different large models and sentence vector generation models can be selected as the basic models for fine-tuning. In the process of constructing positive and negative samples, the similarity can be calculated by other similarity measurement methods such as Euclidean distance; in addition to selecting candidate negative samples according to a specific score range, you can also randomly select
[0072] Example 3
[0073] In step S3-constructing candidate intents and example sentences, the similarity measurement method for vector recall can use other methods besides cosine similarity; similar sentences with a similarity threshold higher than a certain threshold can also be selected as candidate intent example sentences; L N The sample can also be expanded directly by random sampling, as long as L N The intention in does not contain the correct intention.
[0074] Example 4
[0075] In step S4-large model fine-tuning stage, the prompt word template can be different, as long as the task description is clear; the base large model can also be different, such as using Llama3-8b-Instruct, but the instruction version of the base model is better; the fine-tuning method can also be different, such as using QLORA, etc.
[0076] It should be noted that the embodiments mentioned above illustrate rather than limit the present invention, and those skilled in the art will be able to design alternative embodiments without departing from the scope of the claims. Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, so the scope of protection of the present invention shall be subject to the scope defined by the claims.
Claims
1. A method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples, characterized in that: The steps are as follows: S1. Sentence vector generation: fine-tuning an industry-specific embedding model through the industry’s unlabeled data; S2. Build a vector index. Generate a vector of industry labeled data through the embedding model obtained in step S1 and build a vector index library. S3, construct candidate intents and examples, perform similar sentence retrieval based on the index library, and generate candidate intents and examples for the current sample; S4. Fine-tune the large model and construct fine-tuning data to fine-tune the large model.
2. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 1 is characterized in that: The step S1 in the sentence vector generation stage aims to generate vector representations for industry corpus and user query to provide input data for the subsequent retrieval stage; although there are some general embedding models for retrieval, the retrieval capabilities for specific industries are still limited; in order to enhance the recall and retrieval capabilities of specific vertical fields, industry-specific embedding models are required.
3. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 2 is characterized in that: The training method of the specific industry-specific embedding model in step S1 is as follows: 1) Data preparation: Prepare a large amount of unlabeled data set U in the industry; 2) Model preparation: Two models need to be prepared, one as the teacher model for sample screening, and the other as the student model for fine-tuning. Through API calls, the qwen series model is selected as the teacher model, denoted as model T, and BGE-large-zh-v1.5 is selected as the student model, denoted as model S. 3) Construction of positive and negative samples: Each sample u in the dataset U i Input model S to get vector set H U ; By calculating the cosine similarity between vectors, for each sample u in the dataset U i Recall topK similar sentences; Take similar sentences with similarity scores higher than the threshold as x i The candidate positive sample set x takes similar sentences with similarity scores between 0.4 and 0.7 as the candidate negative sample set; sort the samples in the candidate positive sample set from large to small according to similarity, and take the current sample x i The candidate positive samples are input to the model T to let it judge their similarity, and the candidate positive samples judged by the model T as similar are added to x i The positive sample set P i ={p k ,k∈R K } (K represents the size of the positive sample set), until the set size reaches the preset value; for the candidate negative sample set, randomly select a negative sample and let the model T judge whether the negative sample is different from the current sample x i The similarity of x is calculated by adding the samples judged as dissimilar by model T to x i The negative sample set N i ={n j ,j∈R J } (J represents the size of the negative sample set), until the size of the negative sample set meets the preset value; select the positive sample set size K = 1, the negative sample set size J = 5; 4) Model fine-tuning: Through the construction of positive and negative samples, each fine-tuning data can be obtained in the format of {x, P, N}, where x is the current question, P is the positive sample set of x, and N is the negative sample set of x. All fine-tuning data are input into the model S for fine-tuning, and the fine-tuned model (denoted as S') is stored for vector generation in subsequent steps.
4. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 1 is characterized in that: In the step S2, during the vector index building phase, the corpus vectors generated in step 1 are stored in the database to generate a vector index.
5. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 4 is characterized in that: The specific execution steps in step S2 are as follows: 1) Data preparation: In the industry intent recognition task, it is necessary to prepare a labeled dataset C = {X, Y} for classification, that is, for each input sentence x i There is a corresponding intent label y i ; 2) Index construction: The vector model S' obtained in step S1 is for each input sample x in the dataset C i Generate the corresponding vector and get the vector set H of labeled data T ={h i ,i∈R N }(N represents the size of the data set); Generate the vector set H through the vector retrieval tool Faiss T The vector index library I is used to store the vector.
6. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 1, characterized in that: When the big model is used to classify intents in step S3, it is necessary to provide the big model with optional intents; in the scenario of multiple intents, in order to ensure the effectiveness of the model, it is necessary to limit the number of intents provided to the big model; at the same time, in order to enhance the big model's ability to understand specific industries, in addition to the positively correlated samples where the correct intent is in the candidate intents, negatively correlated samples where the correct intent is not in the candidate intents are also constructed.
7. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 6 is characterized in that: The specific execution steps of constructing candidate intents and example sentences in step S3 are as follows: 1) Traverse each sample x in the labeled dataset C i In the index library I generated in step S2, recall the topK similar sentences (excluding x i ), each similar sentence has a corresponding intention, and these intentions are used as samples x i The candidate intent of i The candidate intention and example sentence set of l i Indicates candidate intention, S i Indicates candidate intention i The example sentence set of example sentence set size | S i |The maximum is 5, the size of the set L |L i | Sort by similarity and take at most the top 10 candidate intents; 2) According to y i Is it in the candidate intention set L i In the above example, the candidate intent set is divided into L P and L N , L P is a positively correlated sample set, that is, the candidate intent set contains the correct intent y i ; L N is a negatively correlated sample set, that is, the candidate intent set does not contain the correct intent L P , L P and L N The proportions are r and 1-r respectively; 3) After similar sentences are retrieved, L N The ratio often does not reach the expected value, and it is necessary to expand this part of the sample. First, randomly select a sample x i , then in addition to y i Randomly select k intentions from other intentions as candidate intentions (k∈[1,10]), and calculate the current sample x i The cosine similarity with all the corpora under these k intents. For each candidate intent, m samples with similarity greater than 0.5 are randomly selected as examples of the intent (m∈[1,5]). This process is repeated until L N ratio meets the requirement.
8. The method for identifying domain intent based on fine-tuning a large model with positive and negative correlation samples according to claim 1 is characterized in that: After the previous step in step S4, each piece of data includes an input sample x i , correct intention i , and the candidate intention and example sentence set L i ; The large model is fine-tuned using these domain data to obtain an intent recognition model for a specific domain.
9. The method for identifying domain intent based on fine-tuning a large model with positive and negative correlation samples according to claim 8 is characterized in that: The specific fine-tuning steps of step S4 are as follows: 1) Intent shuffling: Shuffle the order of candidate intents and the order of example sentences for each candidate intent to prevent the model from learning the position information of the correct intent in the candidate intent and ignoring the meaning of the intent itself; 2) Construct the prompt word: transform the sample x i and the candidate intention and example sentence set L i Input it into the prompt word template to generate the instruction prompt word Prompt for the intent recognition task; 3) Construct fine-tuning data: The large model fine-tuning data consists of prompt words and output. For each fine-tuning data, prompt word Prompt = Template (x i ,L i ), large model output Output = y i ; 4) Base model selection: Select a large instruction version model as the base model for fine-tuning; 5) Fine-tuning: Provide the sorted fine-tuning data to the base model, and use the LORA fine-tuning method to fine-tune the large model; The fine-tuned large model M is stored for subsequent intent recognition prediction stage; The method of filtering candidate intents by similar sentences can adapt to classification scenarios with a large number of intents; By integrating positive and negative correlated candidate intents and examples into the fine-tuning data, the large model can fully understand the intent instead of relying entirely on the provided candidate intents for intent recognition. Even when the correct intent is not among the candidate intents, better recognition results can be achieved.
10. The method for identifying domain intent based on fine-tuning a large model based on positive and negative correlation samples according to claim 1, characterized in that: In the step S1-sentence vector generation stage, different large models and sentence vector generation models can be selected as basic models for fine-tuning; in the process of constructing positive and negative samples, the similarity can be calculated by other similarity measurement methods such as Euclidean distance; In addition to selecting candidate negative samples based on a specific score range, they can also be selected randomly; In step S3-constructing candidate intents and example sentences, the similarity measurement method for vector recall can use other methods besides cosine similarity; similar sentences with a similarity threshold higher than a certain threshold can also be selected as candidate intent example sentences; L N The sample can also be expanded directly by random sampling, as long as L N The intention in does not contain the correct intention; In step S4 - the large model fine-tuning stage, the prompt word template can be different, as long as the task description is clear; the base large model can also be different; and the fine-tuning method can also be different.
Citation Information
Cited By
E-commerce customer service response intention recognition method and system
CN119719316A
A method and system for identifying e-commerce customer service response intention
CN119719316B
BGE model fine tuning method and system based on vector retrieval precision enhancement
CN121212333A
A BGE model fine-tuning method and system based on vector retrieval precision enhancement
CN121212333B