Intention recognition method, system and equipment
By building a retrieval database and using similar queries and intent tags as reference examples, the prompt text input is spliced into a large language model, which solves the problem of insufficient accuracy of large language models in intent recognition, achieving higher accuracy and stronger generalization and expansion capabilities.
Patent Information
- Application Number
- CN202411396876.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-01-24
AI Technical Summary
The existing large language models have insufficient accuracy in intention recognition, making it difficult to effectively process unseen data and dynamically add new intention recognition.
By building a pre-built retrieval library, using the embedding model to vectorize user queries, searching for similar queries in the retrieval library, selecting similar queries and corresponding intent tags as reference examples, and splicing them into a prompt text input large language model to Improve the accuracy of intent recognition.
It has significantly improved the accuracy of the identification of large models, enhanced the generalization and expansion capabilities of the model, and can dynamically process unsight data and new intent.
Smart Images

Figure CN119358563A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an intent recognition method, system and device. Background Art
[0002] Intent recognition is an important part of natural language processing (NLP) technology, which aims to understand the real intention or purpose of users when interacting with the system. Its importance is reflected in many aspects, including improving user experience, achieving automation and efficiency improvement, data-driven decision-making, personalized services, and cross-domain applications. Intent recognition not only promotes the development of human-computer interaction, but also brings huge efficiency improvement and innovation opportunities to all walks of life. With the continuous advancement of technology, intent recognition will play its value in more scenarios and bring greater convenience and benefits to society.
[0003] At present, intent recognition is often implemented based on a large language model (LLM). The large language model is trained with a large amount of corpus, and the powerful language understanding and generation capabilities of the large language model are used to implement intent recognition in combination with prompt technology. How to improve the accuracy of large model intent recognition has always been a technical problem that technicians in this field need to face and work on. Summary of the invention
[0004] In view of this, the present application provides an intent recognition method, system and electronic device, the main purpose of which is to improve the accuracy of large model intent recognition.
[0005] According to one aspect of the present application, there is provided an intent recognition method, comprising:
[0006] Perform a vector representation on the current user query, and use the vector representation of the user query to search in a pre-built search library to obtain similar queries, and select at least one similar query and the corresponding intent label as a reference sample;
[0007] splicing a prompt text with the intent label description text, the user query and the reference example, wherein the intent label description text defines the intent label in each scenario;
[0008] The prompt text is input into a pre-trained large language model to obtain an intent recognition result.
[0009] In one implementation, the method further includes:
[0010] Constructing the search library includes:
[0011] Get training samples;
[0012] The training samples are respectively processed by intention labeling, index identification creation and sample vector representation;
[0013] The intention labels, index identifiers and sample vectors are correspondingly saved to obtain the retrieval library.
[0014] In one implementation, the method further includes:
[0015] New training samples are obtained from an external knowledge base or data source, and intent labels of the new training samples are annotated.
[0016] In one implementation, the similarity query retrieval process further includes:
[0017] The user query is represented by a vector using an embedding model, and based on the vector representation of the user query, a search is performed in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
[0018] In one implementation, selecting at least one similar query and a corresponding intent tag as a reference example includes:
[0019] Based on the preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low;
[0020] The intent labels corresponding to the candidate similar queries are counted, similar queries are deduplicated based on the intent labels, and similar queries and corresponding intent labels retained after deduplication are used as the reference samples.
[0021] In one implementation, the deduplication processing of similar queries based on intent tags includes:
[0022] Similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label.
[0023] According to one aspect of the present application, a method for training an intent recognition model is provided, comprising:
[0024] Obtain training samples, perform intent labeling, index identification creation, and sample vector representation on the training samples, respectively, save the intent labels, index identification, and sample vectors in correspondence, and obtain a retrieval library;
[0025] Perform vector representation on historical user queries, and use the vector representation of user queries to search in a pre-built search library to obtain similar queries, select at least one similar query and the corresponding intent label as a reference sample, and splice prompt text with the intent label description text, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario;
[0026] The large language model structure is trained based on the prompt text and training samples to obtain the intent recognition model.
[0027] In one implementation, the method further includes:
[0028] New training samples are obtained from an external knowledge base or data source, and intent labels of the new training samples are annotated.
[0029] In one implementation, the similarity query retrieval process further includes:
[0030] The user query is represented by a vector using an embedding model, and based on the vector representation of the user query, a search is performed in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
[0031] In one implementation, selecting at least one similar query and a corresponding intent tag as a reference example includes:
[0032] Based on the preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low;
[0033] The intent labels corresponding to the candidate similar queries are counted, similar queries are deduplicated based on the intent labels, and similar queries and corresponding intent labels retained after deduplication are used as the reference samples.
[0034] In one implementation, the deduplication processing of similar queries based on intent tags includes:
[0035] Similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label.
[0036] According to one aspect of the present application, there is provided an intention recognition system, comprising:
[0037] A retrieval module is used to perform vector representation on the current user query, and to search for similar queries in a pre-built retrieval library using the vector representation of the user query, and to select at least one similar query and the corresponding intent label as a reference sample;
[0038] A prompt splicing module, used to splice prompt text with the intent label description text, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario;
[0039] The intention recognition execution module is used to input the prompt text into a pre-trained large language model to obtain an intention recognition result.
[0040] According to one aspect of the present application, there is provided an intention recognition training system, comprising:
[0041] The retrieval library construction module is used to obtain training samples, perform intent labeling, index identification creation and sample vector representation on the training samples, and save the intent labels, index identification and sample vectors in correspondence to obtain a retrieval library;
[0042] A retrieval module is used to vectorize historical user queries, and to search for similar queries in a pre-built retrieval library using the vectorized representation of user queries, and to select at least one similar query and the corresponding intent label as a reference example;
[0043] A prompt splicing module, used to splice prompt text with the intent label definition, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario;
[0044] The model training module trains the large language model structure based on the prompt text and training samples to obtain the intent recognition model.
[0045] According to one aspect of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the above-mentioned intention recognition method.
[0046] By means of the above technical solution, the present application provides an intent recognition method, system and device, which adds intent label description text and reference examples to the prompt, so that the large model can refer to the intent labels of similar queries and determine the intent label of the current query based on the intent label description text. It can be seen that by retrieving similar queries for the current query and splicing them into the prompt as reference examples, the model can be prevented from hallucinating and the accuracy of the model can be significantly improved. Moreover, since the intent label description text can support the addition of new intent labels in various scenarios, the generalization and expansion capabilities of the large model are enhanced. In addition, in order to address the problem that the existing model cannot handle unseen data, new samples are inserted into the retrieval library through retrieval augmentation generation (RAG) to further improve the generalization and scalability of the model.
[0047] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0049] Figure 1 A flow chart of an intention recognition method provided by an embodiment of the present application is shown;
[0050] Figure 2 A logic diagram of an intention recognition method provided by an embodiment of the present application is shown;
[0051] Figure 3 A schematic diagram of prompt splicing in an intention recognition method provided in an embodiment of the present application is shown;
[0052] Figure 4 A flow chart of an intent recognition model training method provided in an embodiment of the present application is shown;
[0053] Figure 5 A schematic diagram of the structure of an intention recognition system provided by an embodiment of the present application is shown;
[0054] Figure 6 A schematic diagram of the structure of an intent recognition training system provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0055] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0056] The embodiment of the present application provides an intent recognition method based on a large language model. To address the problem that the existing model cannot dynamically add new intent recognition, this solution solves it by dynamically adjusting the prompt word (Prompt); in addition, to address the problem that the existing model cannot process unseen data, this solution solves it by inserting new samples into the retrieval library. Thus, by combining the large model prompt construction and retrieval enhancement generation (RAG) method, the generalization and scalability of the model are improved.
[0057] First, the terms used in this article are explained as follows.
[0058] LLM (Large Language Model): a natural language processing model based on deep learning technology.
[0059] SFT (Supervised Fine-Tuning): is a commonly used technique in the fields of machine learning and natural language processing (NLP). It further trains the pre-trained model on a dataset for a specific task so that it can better adapt to the needs of the task.
[0060] RAG (Retrieval-Augmented Generation): is a technique that combines information retrieval and generative models to improve the quality and accuracy of text generation tasks.
[0061] Few-shot learning is a machine learning method that aims to enable the model to effectively learn and generalize on a specific task with a very small number of training samples (usually a few or a few groups).
[0062] vLLM (Vectorized Large Language Model Serving System): is a large language model reasoning acceleration tool that significantly improves the reasoning speed and efficiency of large language models by optimizing memory management, continuous batch processing, CUDA core optimization, and distributed reasoning support.
[0063] See also Figure 1 , shows a flow chart of an intention recognition method provided by an embodiment of the present application. The intention recognition method includes the following steps S101-S103.
[0064] S101: Perform a vector representation on the current user query, and use the vector representation of the user query to search in a pre-built search library to obtain similar queries, and select at least one similar query and a corresponding intent label as a reference sample.
[0065] Before step S101, a search library can be pre-built. The process of building a search library may include: data labeling and cleaning, index creation and vector representation, and data storage. First, sample data is obtained from local documents, the sample data is labeled with intent labels, data that does not conform to the intent labels is removed, and the labeled data is deduplicated; then, a unique index identifier is created for each piece of data, and the data is vectorized, for example, using an embedding model (bge-base-zh or CoSENT) to vectorize the data and obtain a vector representation; finally, the intent labels, index identifiers, and sample vectors are saved respectively to complete the search library.
[0066] In order to solve the problem that the existing model cannot handle unseen data, the embodiment of the present application solves it by inserting new samples into the retrieval library. For example, RAG technology can be used to obtain new samples from an external knowledge base or data source, determine the intent label of the new sample, and add the new sample to the retrieval library based on the intent label. Thus, in practical applications, new data that the model has not seen can be dynamically added to the retrieval library. The experimental results show that without reducing the accuracy of the model, the model can still successfully complete the intent recognition task of new data, thereby verifying its good generalization ability. It can be seen that the above method can be used to dynamically add new data to the retrieval library. When some new queries that the model has not seen appear, these data can be inserted into the retrieval library in real time, thereby ensuring that the model can also make correct intent recognition for new data.
[0067] After building the search library, you can search for the current user query based on the search library. First, the query is represented by a vector, for example, the user query is represented by a vector using an embedding model; then, a similarity search is performed on the vector representation of the query based on the search library to determine at least one similar query similar to the current user query, which is then used as a component of the spliced prompt. For example, based on the vector representation of the user query, the search is performed in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query. Similar queries and their corresponding intent labels will be used as reference examples and added to the prompt, which can not only reduce the model's hallucinations, but also improve the model's accuracy.
[0068] S102: splicing prompt text with intent label description text, user query and reference examples, wherein the intent label description text defines the intent label in each scenario.
[0069] Prompt is a prompt method based on a pre-trained model. It guides the model to generate the desired output by designing a text template. There is no need to modify the model parameters. Only the input text needs to be adjusted to adapt to different task requirements. Prompt plays the role of providing context and parameter information of input information to the model in the AI model. It helps the model better understand the input intent and improves interpretability and accessibility.
[0070] After theoretical analysis and experimental research, the applicant found that the effects of different splicing methods of prompts (different elements combined into prompts) are not the same. The embodiment of the present application innovatively proposes that the prompt is spliced with a combination of intent label description text, user query and reference examples, which has the best effect. In the embodiment of the present application, the way of organizing prompts (prompt text), especially through the introduction of reference examples, can teach the large model to learn the intent of the current query. For example, assuming that the current query is "How is the weather today?", first determine that similar queries may be "How was the weather yesterday?", "How was the weather the day before yesterday?" and so on. When organizing the prompt, use the similar query and its intent label as a reference example to guide the model based on the intent label description text (i.e., define the intent label under each scenario), refer to the intent labels of similar queries "How was the weather yesterday?" and "How was the weather the day before yesterday", and learn the intent label of the current query "How is the weather today?".
[0071] In the embodiment of the present application, the intent label text defines the intent label in each scenario. Taking the application scenario of online learning of the learning machine as an example, it is further subdivided into multiple sub-scenarios, such as application sub-scenarios such as finding learning materials, correcting homework, checking time, etc. In each scenario, a different intent label corresponds. For example, the "correct questions" intent label can be described as: the user inputs instructions to correct homework, correct questions, and correct exercises; the "check time" intent label can be described as: the user inputs instructions related to time. It can be understood that the above is only an exemplary description. In actual applications, there is no specific limitation on the intent label text. The intent label text can be added, deleted, and updated to meet the needs of specific application scenarios. In a specific implementation, an intent label definition entry can be provided to receive a new intent addition request from a user (such as a research and development personnel), and in response to the new intent addition request, a correspondence between a new intent label and an application scenario is generated by adding a new intent label, wherein the intent label definition includes an intent category and an intent description. For example, if you need to add an "intent to find resources for a certain cartoon", then you can complete the definition of the new intent by setting the "intent category (for example, using numbers or letters as category identifiers to distinguish)" and "picture description (the user wants to find resources for a certain cartoon)" of the intent.
[0072] Among them, in an optional manner, the number of results of similar queries retrieved in the above step S102 can be limited. For example, based on a preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low. Assuming that the preset candidate threshold k=50, after similar queries are queried (for example, 80 similar queries are queried in total), only the top 50 similar queries from high to low similarity are included. Since the retrieval results are sorted from high to low by similarity, there may be multiple similar queries under the same intent label. In this case, the selection of the number of user queries under the same intent label has a greater impact on the accuracy of the model. Therefore, in an implementation method, the retained k candidate similar queries can be further deduplicated. That is, the intent labels corresponding to each candidate similar query are counted, and the similar queries are deduplicated based on the intent labels, and the similar queries and corresponding intent labels retained after deduplication are used as reference samples.
[0073] For example, suppose that for the current query, the top 50 similar queries similar query1-similar query50 with similarity from high to low are retained, and the intent label of each similar query is determined respectively, for example, as shown in Table 1, where similar query1, similar query2, and similar query3 all correspond to intent label 1, similar query4 corresponds to intent label 2, and so on. Among them, for the case where similar query1, similar query2, and similar query3 all correspond to intent label 1, deduplication processing is required, that is, similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label. In this example, it is assumed that m=1, that is, 1 similar query is retained under each intent label. Then, for the case where intent label 1 corresponds to similar query1, similar query2, and similar query3, only one similar query is retained, for example, only similar query1 with the highest similarity is retained.
[0074] Table 1
[0075]
[0076] Based on this, the above-mentioned operations of sorting similar queries by similarity and deduplicating similar queries according to the intent tags of similar queries in the embodiment of the present application can simplify the complexity of the spliced prompts, and select a smaller number (for example, m=1) of similar queries with the highest similarity under each intent tag to splice prompts, so that the reference examples are more instructive and can improve the accuracy and efficiency of the teaching model.
[0077] S103: Input the prompt text into a pre-trained large language model to obtain an intent recognition result.
[0078] Combine the following Figure 2-3 , an exemplary introduction to the embodiments of the present application is given.
[0079] See also Figure 2 , which shows a logic diagram of an intention recognition method provided by an embodiment of the present application. Figure 2 As shown in the figure, it mainly includes three steps. Step 1: Complete the construction of the search library; Step 2: Complete the splicing of prompts; Step 3: Complete the model fine-tuning and deployment. The specific execution process of each step will be introduced in detail below.
[0080] Step 1: Search library construction
[0081] The process of building a retrieval library includes three main stages: data annotation and cleaning, index creation and vector representation, and data storage.
[0082] First, the user query samples (for example, from local files) are labeled with intent labels, and data that does not conform to the intent labels is removed. Next, the labeled data is deduplicated, and finally the two parts of information [user query, intent label] are retained. Subsequently, a unique index identifier is created for each piece of data, and the user query is encoded into a 768-dimensional vector representation using an embedding model (for example, bge-base-zh). Finally, [index identifier, user query, vector representation of user query, intent label, data source] are saved correspondingly to provide a data basis for the Prompt construction in step 2. Among them, the data source field is used to identify the source of the data.
[0083] In practical applications, new data that the model has not seen can be dynamically added to the retrieval library. Experimental results show that the model can still successfully complete the intent recognition task of new data without reducing the accuracy of the model, thus verifying its good generalization ability.
[0084] Step 2: Prompt Build
[0085] Prompt build process as follows Figure 3 As shown, it mainly includes two stages: encoding and retrieval of user queries and splicing of prompts.
[0086] In the encoding and retrieval stage of the user query, the embedding model (such as bge-base-zh) is first used to generate a vector representation of the user query. Based on the vector representation, for example, through algorithms such as the HNSW algorithm and the cosine similarity, the retrieval of queries similar to the current user query is completed. Similar queries and their corresponding intent labels are added to Prompt as reference samples, which can not only reduce the hallucinations of the model, but also improve the accuracy of the model. As described above, in an embodiment of the present application, the number of retrieval results is limited, and only the top K similar queries are finally selected as candidate similar queries, where the value of K is selected through comparative experiments, and the specific value is not limited. Since the retrieval results are sorted from high to low by similarity, there may be multiple similar queries under the same intent label. In this case, the selection of the number of similar queries under the same intent label has a greater impact on the accuracy of the model. Based on this, the embodiments of the present application draw the following two conclusions through experiments: (1) Compared with the case where no reference samples are used, the use of reference samples can significantly improve the accuracy of the model; (2) When selecting reference samples, the model effect is best when only a small number of similar queries (for example, m=1) are retained under each intent label.
[0087] When splicing prompts, you need to combine the intent label description text, reference examples, and user queries. The introduction of intent label description text and reference examples can teach the model to refer to the intent labels corresponding to similar queries and identify the intent label corresponding to the current query in the intent label description text.
[0088] For example, a prompt template example is:
[0089] "You are now going to complete an intent classification task. Based on the intent definition and the given examples, give the correct intent recognition result for the user question. Note that you only output the intent recognition result and do not output any other information. The following is the definition of the intent label description text:
[0090] 1. Intent Category 1: Intent Content
[0091] 2. Intent Category 2: Intent Content
[0092] 3. Intent Category 3: Intent Content
[0093] The following is an example of the intent recognition results for the current user query and its similar queries:
[0094] User Query: User Query
[0095] Similar User Query 1, Intent Recognition Result: Intent Label 1
[0096] Similar User Query 2, Intent Recognition Result: Intent Label 2
[0097] So now the user inputs: The intent recognition result of User Query is: ".
[0098] It can be understood that the intent tag description text has different definitions depending on the application scenario. For example, common question-and-answer application scenarios may include online learning question-and-answer application scenarios (online learning using a learning machine), online medical application scenarios, online shopping application scenarios, etc. The embodiments of the present application do not limit this.
[0099] The embodiment of the present application introduces the intent label description text in the prompt, so that the model has good scalability. Specifically, in the actual application process, new intent definitions can be added dynamically without re-fine-tuning the model. The effectiveness of this method has been verified by experiments.
[0100] Step 3: Model fine-tuning and deployment
[0101] Based on the above steps 1 and 2, by dynamically adding new intent definitions to the prompt and inserting new data into the search library, the model has good scalability and generalization. Furthermore, in order to improve the accuracy of the native large language model, the embodiment of the present application can perform supervised fine-tuning on the large model based on the mixed data of the above-constructed prompt and general data, and use vLLM and other methods to complete the final deployment of the fine-tuned model.
[0102] It can be seen that the embodiment of the present application realizes intent recognition based on a large language model, wherein the intent label description text and reference examples are added to the prompt, so that the large model can refer to the intent labels of similar queries and determine the intent label of the current query based on the intent label description text. It can be seen that by retrieving similar queries for the current query and splicing them into the prompt as reference examples, the model can be prevented from hallucinating and the accuracy of the model can be significantly improved. Moreover, since the intent label description text can support the addition of new intent labels in various scenarios, the generalization and expansion capabilities of the large model are enhanced.
[0103] See also Figure 4 , shows a flow chart of an intention recognition model training method provided in an embodiment of the present application. The intention recognition model training method includes:
[0104] S401: Acquire training samples, perform intent labeling, index identification creation, and sample vector representation on the training samples, respectively, save the intent labels, index identification, and sample vectors in correspondence, and obtain a retrieval library;
[0105] S402: Perform vector representation on historical user queries, and use the vector representation of user queries to search in a pre-built search library to obtain similar queries, select at least one similar query and the corresponding intent label as a reference sample, and splice prompt text with the intent label description text, user query and reference sample, wherein the intent label description text defines the intent label in each scenario;
[0106] S403: Train a large language model structure based on the prompt text and training samples to obtain an intent recognition model.
[0107] In one implementation, the method further includes:
[0108] New training samples are obtained from an external knowledge base or data source, and intent labels of the new training samples are annotated.
[0109] In one implementation, the similarity query retrieval process further includes:
[0110] The user query is represented by a vector using an embedding model, and based on the vector representation of the user query, a search is performed in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
[0111] In one implementation, selecting at least one similar query and a corresponding intent tag as a reference example includes:
[0112] Based on the preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low;
[0113] The intent labels corresponding to the candidate similar queries are counted, similar queries are deduplicated based on the intent labels, and similar queries and corresponding intent labels retained after deduplication are used as the reference samples.
[0114] In one implementation, the deduplication processing of similar queries based on intent tags includes:
[0115] Similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label.
[0116] See also Figure 5 , shows a schematic diagram of the structure of an intention recognition system provided by an embodiment of the present application. The intention recognition system includes:
[0117] The retrieval module 501 is used to perform vector representation on the current user query, and to search the pre-built retrieval library for similar queries using the vector representation of the user query, and to select at least one similar query and the corresponding intent label as a reference example;
[0118] A prompt splicing module 502 is used to splice prompt text with the intention label description text, user query and reference examples, wherein the intention label description text defines the intention label in each scenario;
[0119] The intention recognition execution module 503 is used to input the prompt text into the pre-trained large language model to obtain the intention recognition result.
[0120] In one implementation, the method further includes:
[0121] The retrieval library construction module 500 is used to construct the retrieval library, wherein training samples are obtained; the training samples are respectively subjected to intention labeling processing, index identifier creation processing and sample vector representation processing; the intention labels, index identifiers and sample vectors are correspondingly saved to obtain the retrieval library.
[0122] In one implementation, it further includes:
[0123] The retrieval enhancement generation unit 5001 obtains new training samples from an external knowledge base or data source, and annotates the intention labels of the new training samples.
[0124] In one implementation, the retrieval module 501 further includes:
[0125] The similarity query subunit 5011 is used to use the embedding model to perform vector representation on the user query, and based on the vector representation of the user query, perform a search in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
[0126] The retrieval module 501 further comprises:
[0127] The similar query candidate subunit 5012 is used to select k similar queries as candidate similar queries based on a preset candidate threshold k and according to the similarity between the similar queries and the user query from high to low;
[0128] The deduplication subunit 5013 is used to count the intent labels corresponding to each candidate similar query, perform deduplication processing on the similar queries based on the intent labels, and use the similar queries and corresponding intent labels retained after the deduplication processing as the reference samples.
[0129] In one implementation,
[0130] The deduplication processing subunit 5013 is specifically used to classify similar queries based on intent tags, and only retain a preset number m of similar queries under each intent tag.
[0131] See also Figure 6, shows a schematic diagram of the structure of an intention recognition training system provided in an embodiment of the present application. The intention recognition training system includes:
[0132] The retrieval library construction module 600 is used to obtain training samples, perform intention labeling processing, index identification creation processing and sample vector representation processing on the training samples, and store the intention labels, index identifications and sample vectors in correspondence to obtain a retrieval library;
[0133] A retrieval module 601 is used to perform vector representation on historical user queries, and to search for similar queries in a pre-built retrieval library using the vector representation of the user queries, and to select at least one similar query and a corresponding intent label as a reference example;
[0134] A prompt splicing module 602 is used to splice prompt texts based on intent label definitions, user queries, and reference examples, wherein the intent label description text defines intent labels in various scenarios;
[0135] The model training module 603 trains a large language model structure based on the prompt text and training samples to obtain an intent recognition model.
[0136] In one implementation, the search construction module 600 further includes:
[0137] The retrieval enhancement generation unit 6001 is used to obtain new training samples from an external knowledge base or data source, and mark the intention labels of the new training samples.
[0138] In one implementation, the retrieval module 601 further includes:
[0139] The similarity query subunit 6011 is used to use the embedding model to perform vector representation on the user query, and based on the vector representation of the user query, perform a search in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
[0140] The retrieval module 601 further includes:
[0141] The similar query candidate subunit 6012 is used to select k similar queries as candidate similar queries based on a preset candidate item threshold k and according to the similarity between the similar queries and the user query from high to low;
[0142] The deduplication subunit 6013 is used to count the intent labels corresponding to each candidate similar query, perform deduplication processing on similar queries based on the intent labels, and use the similar queries and corresponding intent labels retained after the deduplication processing as the reference samples.
[0143] In one implementation,
[0144] The deduplication processing subunit 6013 is specifically used to classify similar queries based on intent tags, and only retain a preset number m of similar queries under each intent tag.
[0145] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0146] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0147] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0148] Perform a vector representation on the current user query, and use the vector representation of the user query to search in a pre-built search library to obtain similar queries, and select at least one similar query and the corresponding intent label as a reference sample; splice a prompt text with the intent label description text, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario; input the prompt text into a pre-trained large language model to obtain an intent recognition result; or,
[0149] Acquire training samples, perform intent labeling, index identification creation and sample vector representation on the training samples respectively, save the intent labels, index identification and sample vectors accordingly, and obtain a retrieval library; perform vector representation on historical user queries, and use the vector representation of user queries to search in a pre-built retrieval library to obtain similar queries, select at least one similar query and the corresponding intent label as a reference example, and splice prompt text with the intent label description text, the user query and the reference example, wherein the intent label description text defines the intent labels in each scenario; train a large language model structure based on the prompt text and the training samples to obtain an intent recognition model.
[0150] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0151] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0152] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0153] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0156] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0157] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for intention recognition, characterized in that: include: Perform a vector representation on the current user query, and use the vector representation of the user query to search in a pre-built search library to obtain similar queries, and select at least one similar query and the corresponding intent label as a reference sample; splicing a prompt text with the intent label description text, the user query and the reference example, wherein the intent label description text defines the intent label in each scenario; The prompt text is input into a pre-trained large language model to obtain an intent recognition result.
2. The method according to claim 1, characterized in that: Also includes: Constructing the search library includes: Get training samples; The training samples are respectively processed by intention labeling, index identification creation and sample vector representation; The intention labels, index identifiers and sample vectors are correspondingly saved to obtain the retrieval library.
3. The method according to claim 2, characterized in that Also includes: New training samples are obtained from an external knowledge base or data source, and intent labels of the new training samples are annotated.
4. The method according to claim 1, characterized in that The retrieval process of the similar query further includes: The user query is represented by a vector using an embedding model, and based on the vector representation of the user query, a search is performed in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
5. The method according to claim 1, characterized in that The selecting at least one similar query and the corresponding intent label as a reference example includes: Based on the preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low; The intent labels corresponding to the candidate similar queries are counted, similar queries are deduplicated based on the intent labels, and similar queries and corresponding intent labels retained after deduplication are used as the reference samples.
6. The method according to claim 5, characterized in that The deduplication processing of similar queries based on intent tags includes: Similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label.
7. A method for training an intent recognition model, characterized in that: include: Obtain training samples, perform intent labeling, index identification creation, and sample vector representation on the training samples, respectively, save the intent labels, index identification, and sample vectors in correspondence, and obtain a retrieval library; Perform vector representation on historical user queries, and use the vector representation of user queries to search in a pre-built search library to obtain similar queries, select at least one similar query and the corresponding intent label as a reference sample, and splice prompt text with the intent label description text, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario; The large language model structure is trained based on the prompt text and training samples to obtain the intent recognition model.
8. The method according to claim 7, characterized in that Also includes: New training samples are obtained from an external knowledge base or data source, and intent labels of the new training samples are annotated.
9. The method according to claim 7, characterized in that: The retrieval process of the similar query further includes: using an embedding model to vectorize the user query, and based on the vector representation of the user query, searching in the search library through an indexing algorithm or a similarity algorithm to obtain at least one similar query to the user query.
10. The method according to claim 7, characterized in that The selecting at least one similar query and the corresponding intent label as a reference example includes: Based on the preset candidate threshold k, k similar queries are selected as candidate similar queries according to the similarity between similar queries and user queries from high to low; The intent labels corresponding to the candidate similar queries are counted, similar queries are deduplicated based on the intent labels, and similar queries and corresponding intent labels retained after deduplication are used as the reference samples.
11. The method according to claim 10, characterized in that The deduplication processing of similar queries based on intent tags includes: Similar queries are classified based on intent labels, and only a preset number of m similar queries are retained under each intent label.
12. An intention recognition system, characterized in that: include: A retrieval module is used to perform vector representation on the current user query, and to search for similar queries in a pre-built retrieval library using the vector representation of the user query, and to select at least one similar query and the corresponding intent label as a reference sample; A prompt splicing module, used to splice prompt text with the intent label description text, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario; The intention recognition execution module is used to input the prompt text into a pre-trained large language model to obtain an intention recognition result.
13. An intention recognition training system, characterized in that: include: The retrieval library construction module is used to obtain training samples, perform intent labeling, index identification creation and sample vector representation on the training samples, and save the intent labels, index identification and sample vectors in correspondence to obtain a retrieval library; A retrieval module is used to vectorize historical user queries, and to search for similar queries in a pre-built retrieval library using the vectorized representation of user queries, and to select at least one similar query and the corresponding intent label as a reference example; A prompt splicing module, used to splice prompt text with the intent label definition, the user query and the reference sample, wherein the intent label description text defines the intent label in each scenario; The model training module trains the large language model structure based on the prompt text and training samples to obtain the intent recognition model.
14. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 11.
Citation Information
Cited By
Index extraction method, electronic equipment and computer program product
CN119938870A
Index extraction method, electronic device and computer program product
CN119938870B
Vehicle-mounted user intention recognition method and system based on large model
CN120705304A
A large model-based vehicle-mounted user intention recognition method and system
CN120705304B
Multi-stage intention recognition method and system for adaptive context learning
CN121233768A