A text intent recognition method and related equipment

By constructing a target sample set and performing supervised fine-tuning on the text intent recognition model, the text intent type can be directly identified end-to-end, solving the problem of low recognition accuracy in existing technologies and achieving higher text intent recognition accuracy.

CN118861278BActive Publication Date: 2025-09-16TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410377711.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2025-09-16
Estimated Expiration
2044-03-28

AI Technical Summary

Technical Problem

In the question-answering scenario of a large language model, the existing two-stage framework for text intent recognition suffers from error transmission, resulting in low recognition accuracy.

Method used

By obtaining a target sample set, using the output of a large language model to perform text rewriting and intent recognition, a target sample set is constructed, and the pre-trained text intent recognition model is fine-tuned in a supervised manner to obtain a fine-tuned model that directly recognizes text intent types end-to-end.

Benefits of technology

It improves the accuracy of text intent recognition, avoids the deviation in intent understanding caused by text rewriting, and improves recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118861278B_ABST
    Figure CN118861278B_ABST
Patent Text Reader

Abstract

This application discloses a method and related equipment for text intent recognition. Embodiments of the present application can obtain a target sample set, comprising multiple labeled target samples obtained by integrating the output of a large language model based on preset prompts, including a text rewriting portion and an intent recognition portion. Based on the target sample set, a pre-trained text intent recognition model is fine-tuned in a supervised manner to obtain a fine-tuned text intent recognition model. The text to be recognized is obtained, comprising one or more rounds of conversation. The fine-tuned text intent recognition model is invoked and an end-to-end approach is used to identify the text intent type corresponding to the text to be recognized. This application can improve the accuracy of text intent recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text intent recognition method and related equipment. Background Art

[0002] In the question-answering scenario of a large language model, the text to be recognized is usually directly input into the large language model, and the corresponding results are output through the large language model. However, since the input text to be recognized may exist in multiple rounds of scenarios, a text rewriting model is needed to convert the text to be recognized into prompts with complete semantics. In addition, a large language model often cannot solve the problems of various plug-ins, so it is necessary to use the intent recognition model to determine the text intent type of the text to be recognized, and then distribute it to each special plug-in model to obtain the corresponding results. This is the two-stage framework of "multiple rounds of rewriting first, then intent recognition", but this two-stage framework will have the problem of error transmission, thereby reducing the accuracy of text intent recognition. Summary of the Invention

[0003] An embodiment of the present application provides a text intent recognition method and related equipment. The related equipment may include a text intent recognition device, an electronic device, a computer-readable storage medium and a computer program product, which can improve the accuracy of text intent recognition.

[0004] This embodiment of the present application provides a method for identifying text intent, including:

[0005] Obtaining a target sample set, the target sample set including a plurality of target samples carrying labels, the target samples being obtained by integrating the results output by a large language model according to preset prompts, the preset prompts including a text rewriting portion and an intent recognition portion;

[0006] Based on the target sample set, supervised fine-tuning is performed on the pre-trained text intent recognition model to obtain a fine-tuned text intent recognition model;

[0007] Acquire a text to be recognized, where the text to be recognized includes one or more rounds of conversation;

[0008] The fine-tuned text intent recognition model is called to identify the text intent type corresponding to the text to be recognized in an end-to-end manner.

[0009] Accordingly, an embodiment of the present application provides a text intent recognition device, comprising:

[0010] A first acquisition unit is configured to acquire a target sample set, wherein the target sample set includes a plurality of target samples carrying labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts, wherein the preset prompts include a text rewriting portion and an intent recognition portion;

[0011] A fine-tuning unit, configured to perform supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model;

[0012] A second acquiring unit is configured to acquire a text to be recognized, where the text to be recognized includes one or more rounds of conversation;

[0013] The recognition unit is used to call the fine-tuned text intent recognition model and identify the text intent type corresponding to the text to be recognized in an end-to-end manner.

[0014] Optionally, in some embodiments of the present application, the first acquisition unit may include a first acquisition subunit, a second acquisition subunit, and an integration subunit, as follows:

[0015] A first acquisition subunit is used to acquire a large language model and preset prompts;

[0016] A second acquisition subunit is configured to acquire an initial text and call the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompt, thereby obtaining a text rewriting result corresponding to the initial text and a text intent type corresponding to the initial text;

[0017] The integration subunit is used to integrate the text rewriting result corresponding to the initial text and the text intention type corresponding to the initial text to construct a target sample set.

[0018] Optionally, in some embodiments of the present application, the second acquisition sub-unit can be specifically used to obtain the initial text, and call the text intention recognition module of the large language model to perform reference recognition on the initial text according to the text rewriting part in the preset prompt to obtain the reference words in the initial text; perform reference resolution on the reference words, and perform text rewriting on the initial text according to the reference resolution result to obtain the text rewriting result corresponding to the initial text; call the text intention recognition module of the large language model to perform intent recognition on the text rewriting result according to the intent recognition part in the preset prompt to obtain the text intent type corresponding to the initial text.

[0019] Optionally, in some embodiments of the present application, the second acquisition sub-unit can be specifically used to acquire the initial text, and call the text structure recognition module of the large language model to identify the text structure type corresponding to the initial text; input the initial text and the text structure type corresponding to the initial text into the text intention recognition module of the large language model, and perform text intention recognition on the initial text according to the preset prompt and the text structure type through the text intention recognition module to obtain the text rewriting result corresponding to the initial text and the text intention type corresponding to the initial text.

[0020] Optionally, in some embodiments of the present application, the first acquisition subunit can be specifically used to obtain an initial sample data set, a data set to be labeled, and multiple initial small language models; determine the initial sample data set as a training set, and determine the data set to be labeled as a test set; train the initial small language model through the training set to obtain a trained small language model; call the trained small language model to perform label prediction on the test set to obtain a label prediction result; filter out prediction error data with incorrect predictions from the label prediction results; add the prediction error data to the training set to update the training set; train the initial small language model through the training set to obtain a trained small language model; call the trained small language model to perform label prediction on the test set to obtain a label prediction result; compare the label prediction result of this round with the label prediction result of the previous round to obtain a difference result; filter out prediction error data with incorrect predictions from the difference result; add the prediction error data to the training set to update the training set; return to execute the steps of training the initial small language model through the training set and determining the prediction error data through the test set, until the accuracy of the trained small language model reaches a preset standard, and the target difficult sample is obtained.

[0021] Optionally, in some embodiments of the present application, the fine-tuning unit can be specifically used to call the pre-trained text intent recognition model to predict multiple words in the target sample to obtain a prediction result; calculate the model loss based on the difference between the target sample and the prediction result; adjust the model parameters of the pre-trained text intent recognition model based on the model loss to obtain a fine-tuned text intent recognition model.

[0022] Optionally, in some embodiments of the present application, the recognition unit can be specifically used to input the text to be recognized into the fine-tuned text intent recognition model; perform text intent recognition on the text to be recognized based on the fine-tuned text intent recognition model, and output the text intent type corresponding to the text to be recognized.

[0023] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps in the text intent recognition method provided in the embodiment of the present application are implemented.

[0024] In addition, an embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in the text intent recognition method provided in an embodiment of the present application.

[0025] The embodiment of the present application provides a text intent recognition method and related equipment, which can obtain a target sample set, the target sample set includes multiple target samples with labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts, and the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, the pre-trained text intent recognition model is supervised fine-tuned to obtain a fine-tuned text intent recognition model; the text to be recognized is obtained, and the text to be recognized includes one or more rounds of conversations; the fine-tuned text intent recognition model is called, and an end-to-end method is used to identify the text intent type corresponding to the text to be recognized. The present application can directly identify the text intent type corresponding to the text to be recognized through the text intent recognition model, avoid executing the text rewriting step, eliminate the intention understanding deviation problem caused by text rewriting, and improve the accuracy of text intent recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 Schematic diagram of a scenario of a text intent recognition method provided by an embodiment of the present application;

[0028] Figure 2 This is a first flow chart of the text intent recognition method provided by an embodiment of the present application;

[0029] Figure 3 This is a second flow chart of the text intent recognition method provided by an embodiment of the present application;

[0030] Figure 4 This is a structural block diagram of the text intent recognition method provided by an embodiment of the present application;

[0031] Figure 5 is a schematic diagram of a target sample acquisition method provided in an embodiment of the present application;

[0032] Figure 6 is a schematic diagram of a difficult sample acquisition method provided in an embodiment of the present application;

[0033] Figure 7 Schematic diagram of a text intent recognition device provided in an embodiment of the present application;

[0034] Figure 8 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.

[0036] The present invention provides a method and related equipment for text intent recognition, which may include a text intent recognition device, an electronic device, a computer-readable storage medium, and a computer program product. The text intent recognition device may be integrated into an electronic device, such as a terminal or a server.

[0037] It is understandable that the text intent recognition method of this embodiment can be executed on a terminal, on a server, or jointly by a terminal and a server. The above examples should not be construed as limiting the present application.

[0038] like Figure 1 As shown, a text intent recognition method is performed jointly by a terminal and a server as an example. The text intent recognition system provided in the embodiment of the present application includes a terminal and a server, etc. The terminal and the server are connected via a network, such as a wired or wireless network, wherein the text intent recognition device can be integrated into the server.

[0039] The server can be used to: obtain a target sample set, the target sample set includes multiple target samples with labels, the target samples are obtained by integrating the results output by a large language model according to preset prompts, the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, supervised fine-tuning the pre-trained text intent recognition model to obtain a fine-tuned text intent recognition model; obtain the text to be recognized, the text to be recognized includes one or more rounds of conversations; call the fine-tuned text intent recognition model, and apply an end-to-end approach to identify the text intent type corresponding to the text to be recognized. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The text intent recognition method or device disclosed in this application, wherein multiple servers can be composed of a blockchain, and the server is a node on the blockchain.

[0040] The terminal can be used to receive text intent types from the server and make decisions based on the text intent types. Terminals can include mobile phones, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, tablets, laptops, or personal computers (PCs). The terminal can also be configured with a client, which can be an application client or a browser client, among others.

[0041] It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.

[0042] This embodiment will be described from the perspective of a text intent recognition device, which can be integrated into an electronic device, such as a server or terminal. This embodiment can be applied to various scenarios such as cloud technology, artificial intelligence, smart transportation, and assisted driving.

[0043] It is understandable that in the specific implementation of this application, related data such as user information (such as text to be recognized) is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0044] like Figure 2 As shown, the specific process of the text intent recognition method can be as follows:

[0045] S201: Obtain a target sample set.

[0046] The target sample set includes multiple target samples with labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts.

[0047] Among them, the large language model in the embodiment of the present application is a network model used to obtain target samples. Therefore, the large language model can be an external open source network model, or it can be a large language model developed independently, etc. Since the embodiment of the present application involves a technical solution for processing text, the large language model can specifically be a large language model.

[0048] Among them, in the field of artificial intelligence, a preset prompt is a text or instruction that points to the input of a network model to guide the network model to generate a specific output. The preset prompt is the text or instruction provided by the user based on needs and scenarios when interacting with the network model. It is used to describe the information, answers, text, etc. that the user hopes to obtain from the network model. During the text generation process, the network model will understand the preset prompt and generate corresponding responses based on its understanding.

[0049] In one embodiment, the preset prompt may include a text rewriting part and an intent recognition part, that is, the large language model will perform text rewriting operations and intent recognition operations according to the preset prompt.

[0050] Among them, text rewriting is a text processing method that rewrites the original text to improve the reading quality and readability. Multi-round text rewriting is a technology used in question-answering scenarios in natural language processing tasks. Its purpose is to continuously rewrite or adjust the input text through multiple rounds of dialogue to complete reference resolution and omission. Therefore, the model needs to understand and retain the contextual information in the text to maintain consistency and accuracy during the rewriting process.

[0051] For example, the original session is:

[0052] Question 1: What’s the weather like today?

[0053] Answer 1: It’s sunny today

[0054] Question 2: What about tomorrow?

[0055] The original conversation can be rewritten as "How is the weather tomorrow?" by text rewriting. Compared with the original conversation, the rewritten text is easier to read and easier to understand its meaning.

[0056] Among them, intent recognition helps the system better understand user needs by determining the intention or purpose expressed by the input text, so as to better answer questions or provide related services. For example, when the input text is "What will the weather be like tomorrow", the input text can be determined as a weather type through intent recognition. Different text intent types can be implemented through different plug-ins.

[0057] Optionally, in one embodiment, since the cost of manually labeling the data required for text intent recognition is high, preset prompts can be written in advance, and a large language model can be requested to obtain corresponding output results according to the preset prompts. Manual data cleaning is then performed to obtain labels to construct the final target sample set. The step of "obtaining the target sample set" may include:

[0058] Get large language models and preset prompts;

[0059] Obtain the initial text and call the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompts, and obtain the text rewriting result corresponding to the initial text and the text intent type corresponding to the initial text;

[0060] The text rewriting results corresponding to the initial text and the text intent type corresponding to the initial text are integrated to construct a target sample set.

[0061] The large language model includes a text intent recognition module, which is used to rewrite the input text and recognize the intent.

[0062] For example, in order to obtain a suitable target sample set, we can first obtain a pre-trained large language model and preset prompts written according to the requirements, where the preset prompts can be as follows:

[0063] "Complete text understanding tasks based on the context of multiple rounds of conversation:

[0064] Task 1, text rewriting: If the text contains omitted content or reference content, complete the reference resolution and obtain the text rewriting result; if the text does not contain omitted content or reference content, there is no need to rewrite the text;

[0065] Task 2, intent recognition: Identify the text intent type to which the text belongs, including:

[0066] - Main model: does not belong to other plugins

[0067] - Acrostic Poetry: Acrostic Poetry Creation is considered a positive example, and Acrostic Poetry Encyclopedia is considered a negative example

[0068] - Wenshengtu: Picture creation / picture editing is considered a positive example, and instructions that do not generate pictures are considered a negative example.

[0069] -Calendar: Date query / date calculation with positive examples, age calculation / eight characters / almanac / zodiac / time reasoning with negative examples

[0070] - Weather: Weather query / activity suggestion counts as positive, Weather Encyclopedia / UV / PM2.5 / UV Index / flood counts as negative

[0071] - Ancient Poetry: Reciting ancient poetry / appreciating ancient poetry counts as positive examples, while ancient poetry encyclopedia counts as negative examples

[0072] -Stocks: Stock information query / company information query / market information query counts as positive examples, stock encyclopedia / stock analysis / stock historical information counts as negative examples

[0073] -Code Interpreter: Code understanding, modification, repair, optimization, completion, implementation, transfer, execution, error explanation, visualization, and concept explanation are counted as positive examples, while code multiple-choice questions / programming learning / mind mapping / interview questions are counted as negative examples.

[0074] -Calculation: math problems / size comparison / proof problems / logical reasoning and positive examples

[0075] - Map: Route planning / route time / surrounding search are counted as positive examples, while train and flight information / surrounding road conditions / travel guide / transportation costs are counted as negative examples

[0076] -PDF summary: given a PDF file, questions are counted as positive examples

[0077] -Website: Website navigation needs are considered positive examples

[0078] - Picture description: Picture description is a positive example

[0079] -Exchange rate: exchange rate query calculation example

[0080] -Translation: Translation requests are considered positive examples"

[0081] The preset prompt includes two tasks: Task 1 is to rewrite the text, and Task 2 is to identify the intent. The preset prompt clearly states the specific requirements for intent identification in Task 2, that is, the boundaries between what each plug-in supports (positive examples) and what it does not support (negative examples). The preset prompt includes one main model and 14 plug-ins. After confirming the preset prompt, you can obtain the initial text, which can be as follows:

[0082] Question 1: What’s the weather like today?

[0083] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0084] Question 2: What about tomorrow?

[0085] The initial text is then input into the large language model, and the text intent recognition module of the large language model is used to recognize the text intent of the initial text and output the following content:

[0086] "Text rewriting result: Shenzhen City tomorrow's weather forecast

[0087] Text intent type: weather type"

[0088] After obtaining the initial text, the text rewriting result corresponding to the initial text, and the text intent type, the above content can be manually cleaned and the data can be integrated to obtain target samples with labels, and multiple target samples can be collected to form a target sample set.

[0089] In one embodiment, the text rewriting results and text intent types corresponding to the acquired initial text may be manually marked and reviewed, and the above information may be spliced ​​together using a pre-designed template to obtain a target sample. The pre-designed template may be as follows:

[0090] "Input: {target prompt}

[0091] Output: {text rewriting result, text intent type}"

[0092] Examples of target samples obtained based on the above template can be as follows:

[0093] "enter:

[0094] Question 1: What’s the weather like today?

[0095] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0096] Question 2: Lunar calendar date 2024

[0097] Output:

[0098] Text rewriting result: [2024 Lunar Calendar Date], text intent type: [Calendar]"

[0099] You can also:

[0100] "enter:

[0101] Question 1: Write an acrostic poem starting with Lian Peitao

[0102] Answer 1: My residence is near the bamboo forest, and the shade of the mountain is built on the hillside. The hills are built up to the clouds above the stream, and the waves come straight from the deep stream. For the love of the subtle fragrance, I come to the small couch, open the window, sit among the bamboos and chant. There is no need to call the monks, the monks of the white mountain always have their hearts.

[0103] Question 2: Wang Yi

[0104] Output:

[0105] Text rewriting result: [Write an acrostic poem starting with Wang Yi], text intent type: [Acrostic poem]

[0106] Optionally, in one embodiment, the step of "obtaining the initial text, and calling the text intent recognition module of the large language model to perform text intent recognition on the initial text according to preset prompts, and obtaining a text rewriting result corresponding to the initial text, and a text intent type corresponding to the initial text" may include:

[0107] Obtain the initial text and call the text intent recognition module of the large language model to perform reference recognition on the initial text based on the text rewriting part in the preset prompt to obtain the reference words in the initial text;

[0108] Performing referential resolution on the referential words, and rewriting the initial text according to the referential resolution results to obtain a text rewriting result corresponding to the initial text;

[0109] The text intent recognition module of the large language model is called to perform intent recognition on the text rewriting result according to the intent recognition part in the preset prompt to obtain the text intent type corresponding to the initial text.

[0110] Among them, reference refers to the use of abbreviations or aliases in the following text to replace a word that has appeared in the previous text in daily language. The reference phenomenon can avoid problems such as bloated sentences and redundancy caused by the repeated appearance of the same word, but it will also cause problems of unclear reference.

[0111] Among them, reference resolution is the process of formally dividing different references representing the same entity into an equivalent set. Reference resolution can effectively solve the problem of ambiguous reference in the text.

[0112] For example, the preset prompts can be as follows:

[0113] "Complete text understanding tasks based on the context of multiple rounds of conversation:

[0114] Task 1, text rewriting: If the text contains omitted content or reference content, complete the reference resolution and obtain the text rewriting result; if the text does not contain omitted content or reference content, there is no need to rewrite the text;

[0115] Task 2, intent recognition: Identify the text intent type to which the text belongs, including:

[0116] - Weather: Weather query / activity suggestion counts as positive, Weather Encyclopedia / UV / PM2.5 / UV index / flood counts as negative

[0117] The initial text obtained can be as follows:

[0118] Question 1: What’s the weather like today?

[0119] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0120] Question 2: What about tomorrow?

[0121] Then the initial text is input into the large language model, and the text intent recognition module of the large language model is used to perform reference recognition according to the preset prompt "Task 1, text rewriting: if the text contains omitted content or referential content, complete the reference resolution and obtain the text rewriting result; if the text does not contain omitted content or referential content, there is no need to rewrite the text". All possible referential words in the initial text are identified, and these words are reference resolved. It can be analyzed that "tomorrow" in question 2 is asking about tomorrow's weather conditions. The initial text can be rewritten as "Shenzhen tomorrow's weather forecast" and the text recognition module of the large language model is called. According to the preset prompt "Task 2, intent recognition: identify the text intent type to which the text belongs, including: - Weather: weather query / activity suggestion is considered a positive example, weather encyclopedia / ultraviolet / PM2.5 / UV index / flood is considered a negative example", the rewritten text rewriting result "Shenzhen tomorrow's weather forecast" is subjected to intent recognition to obtain the text intent type "weather type" corresponding to the initial text.

[0122] Optionally, in one embodiment, in order to improve the wide application of the target sample, it is necessary to ensure that its conversation distribution is uniform, that is, to cover both simple structure multi-round conversation texts and complex structure multi-round conversation texts. The step of "obtaining the initial text, and calling the text intent recognition module of the large language model to perform text intent recognition on the initial text according to preset prompts, and obtaining the text rewriting result corresponding to the initial text and the text intent type corresponding to the initial text" may include:

[0123] Obtain the initial text and call the text structure recognition module of the large language model to identify the text structure type corresponding to the initial text;

[0124] The initial text and the text structure type corresponding to the initial text are input into the text intent recognition module of the large language model, and the text intent recognition module performs text intent recognition on the initial text according to preset prompts and text structure types to obtain the text rewriting result corresponding to the initial text and the text intent type corresponding to the initial text.

[0125] Among them, the large language model also includes a text structure recognition module, which is used to identify whether the text belongs to a simple structure multi-round conversation text or a complex structure multi-round conversation text.

[0126] A simple multi-turn conversation text is one that contains complete semantic information. The network model can directly output results based on the conversation. For example, the conversation "2024 Lunar Calendar Date" is complete in both form and content and can be answered without the need for context. For example, the following conversation is a simple multi-turn conversation text:

[0127] Question 1: What’s the weather like today?

[0128] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0129] Question 2: Lunar calendar date 2024

[0130] Complex multi-turn conversations can include both referential and ellipsis types. Referential texts contain referential vocabulary (you / me / him / this / that, etc.). Network models require contextual conversation information to understand them. For example, in a conversation, "How did you get this?" To answer the question, the network model needs to understand and query the context for the meaning of "this." For example, the following is a complex multi-turn conversation:

[0131] Question 1: What’s the weather like today?

[0132] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0133] Question 2: How did you get this?

[0134] Omission refers to conversations that omit key information and require contextual completion. For example, in the conversation "What about tomorrow?", the network model needs to infer from the context that the question is about the weather tomorrow. For example, the following conversation is a complex, multi-turn conversation with omissions:

[0135] Question 1: What’s the weather like today?

[0136] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0137] Question 2: What about tomorrow?

[0138] In one embodiment, in order to improve the richness of the target sample set finally obtained, the text structure type can also be taken into consideration, for example, Figure 5 As shown, after obtaining the initial text, the initial text can be input into the large language model. The text structure recognition module in the large language model can then be used to identify the text structure type corresponding to the initial text. In other words, it can be determined whether the initial text belongs to a simple structure multi-turn conversation text or a complex structure multi-turn conversation text. The text intent recognition module of the large language model can then be used to perform text intent recognition on the initial text to obtain the text rewriting result corresponding to the initial text and the text intent type corresponding to the initial text.

[0139] Specifically, for example, Figure 5 As shown, if the initial text is as follows:

[0140] Question 1: What’s the weather like today?

[0141] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0142] Question 2: Lunar calendar date 2024

[0143] Through the text structure recognition module in the large language model, it can be learned that the initial text belongs to a simple structure multi-round conversation text. Then, through the text intent recognition module in the large language model, it can be learned that the text rewriting result corresponding to the initial text is "Lunar Calendar Date 2024" and the text intent type corresponding to the initial text is "Main Model".

[0144] For example, Figure 5 As shown, if the initial text is as follows:

[0145] Question 1: What’s the weather like today?

[0146] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0147] Question 2: How did you get this?

[0148] The text structure recognition module in the large language model can determine that the initial text belongs to the reference class in the complex structure multi-round conversation text. Then, the text intent recognition module in the large language model can determine that the text rewrite result corresponding to the initial text is "How do you get the weather data?" and the text intent type corresponding to the initial text is "main model".

[0149] For example, Figure 5 As shown, if the initial text is as follows:

[0150] Question 1: What’s the weather like today?

[0151] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0152] Question 2: What about tomorrow?

[0153] The text structure recognition module in the large language model can be used to determine that the initial text belongs to the omission category in complex structure multi-round conversation texts. Then, the text intent recognition module in the large language model can be used to determine that the text rewriting result corresponding to the initial text is "What will the weather be like tomorrow?" and that the text intent type corresponding to the initial text is "weather type."

[0154] Optionally, in one embodiment, since different samples may present different degrees of difficulty to the network model, the performance of the network model may be further improved by identifying difficult samples. The step of "obtaining a target sample set" may further include:

[0155] Obtain an initial sample data set, a data set to be labeled, and multiple initial small language models;

[0156] The initial sample data set is determined as the training set, and the data set to be labeled is determined as the test set;

[0157] Train an initial small language model using the training set and determine prediction errors using the test set.

[0158] Add the predicted error data to the training set and update the training set;

[0159] Return to the steps of training the initial small language model using the training set and determining the prediction error data using the test set, until the accuracy of the trained small language model reaches the preset standard, and the target difficult sample is obtained.

[0160] Optionally, in one embodiment, the step of “training the initial small language model using the training set and determining prediction error data using the test set” may include:

[0161] Train the initial small language model using the training set to obtain a trained small language model;

[0162] Call the trained small language model to predict labels for the test set and obtain the label prediction results;

[0163] Filter prediction error data from label prediction results.

[0164] Optionally, in one embodiment, the step of “returning to the step of training the initial small language model using the training set and determining prediction error data using the test set until the accuracy of the trained small language model reaches a preset standard, thereby obtaining a target difficult sample” may include:

[0165] Train the initial small language model using the training set to obtain a trained small language model;

[0166] Call the trained small language model to predict labels for the test set and obtain the label prediction results;

[0167] Compare the label prediction results of this round with those of the previous round to obtain the difference results;

[0168] Filter the prediction error data from the difference results;

[0169] Add the predicted error data to the training set and update the training set;

[0170] Return to the steps of training the initial small language model using the training set and determining the prediction error data using the test set, until the accuracy of the trained small language model reaches the preset standard, and the target difficult sample is obtained.

[0171] For example, Figure 6 As shown, we can first obtain an initial sample data set 0, a data set to be labeled, and multiple initial small language models. The initial sample data set is used as a training set for training the network model, and the data set to be labeled is used as a test set for testing the network model. Then, we can use the training set to train the initial small language model 0 to obtain the trained small language model 0. The trained small language model 0 is called to perform label prediction on the test set to obtain the label prediction result 1. A portion of data is randomly sampled from the label prediction result 1, and after manual participation in labeling, the prediction error data 1 with incorrect predictions is filtered out.

[0172] Then, the initial sample data set 0 and the predicted error data 1 are used as new training sets. The initial small language model 1 is trained with the new training set. The trained small language model 1 is called to perform label prediction on the test set to obtain the label prediction result 2. The label prediction result 1 and the label prediction result 2 are compared to obtain the parts with differences. After manual labeling, the predicted error data 2 with incorrect predictions is filtered out.

[0173] Then, the initial sample data set 0, the predicted error data 1, and the predicted error data 2 are used as new training sets. The initial small language model 2 is trained with the new training set. The trained small language model 2 is called to perform label prediction on the test set to obtain the label prediction result 3. The label prediction result 2 and the label prediction result 3 are compared to obtain the parts with differences. After manual labeling, the predicted error data 3 with incorrect predictions is filtered out.

[0174] Repeat the above steps and iterate until the accuracy of the trained small language model reaches a preset standard. The iteration is completed, and the prediction error data 1, prediction error data 2, prediction error data 3, etc. are used as target difficult samples. These target difficult samples can be added to the target sample set for final network model training. In one embodiment, a small language model is used to facilitate rapid iteration.

[0175] S202. Based on the target sample set, the pre-trained text intent recognition model is fine-tuned in a supervised manner to obtain a fine-tuned text intent recognition model.

[0176] Among them, supervised fine-tuning refers to a method that uses labeled specific task data to further fine-tune the already trained language model, so that the network model has the ability to follow instructions.

[0177] Although the pre-trained text intent recognition model has undergone a pre-training process, in order to make it more suitable for actual application tasks, it can be further fine-tuned through a target sample set to obtain a fine-tuned text intent recognition model. The fine-tuned text intent recognition model can better adapt to actual application scenarios and has a higher degree of adaptability to tasks.

[0178] Optionally, in one embodiment, the step of “performing supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model” may include:

[0179] Call the pre-trained text intent recognition model to predict multiple words in the target sample and obtain the prediction results;

[0180] Calculate the model loss based on the difference between the target sample and the predicted result;

[0181] The model parameters of the pre-trained text intent recognition model are adjusted based on the model loss to obtain a fine-tuned text intent recognition model.

[0182] For example, in an embodiment of the present application, a pre-trained GPT (a pre-trained model base for multi-round conversation scenarios) can be used for supervised fine-tuning. GPT can be constructed using a Transformer decoder, thereby constructing a pre-trained text intent recognition model. This pre-trained text intent recognition model is then trained using an autoregressive language model, the goal of which is to predict the next token based on the current and previous tokens.

[0183] The Transformer decoder consists of multiple self-attention layers and positional feedforward neural networks, stacked together via residual connection layers and normalization layers. Layer normalization is applied after each layer's output, accelerating model convergence and mitigating vanishing or exploding gradients in the network. Furthermore, the self-attention mechanism can be applied to capture contextually relevant information in text sequences. The calculation of the self-attention mechanism involves three weight matrices: the query matrix Q, the key matrix K, and the value matrix V. Attention weights are calculated through dot products, scaling, softmax activation, and weighted summation. When using the Transformer decoder, only the content preceding the character to be predicted is known; the content following the character to be predicted is overwritten during calculations. This ensures that the neural network's predictions are based solely on the information preceding the character to be predicted, enabling the Transformer to more efficiently capture long-distance dependencies in sequence data.

[0184] In one embodiment, the parameters of the Transformer decoder may be set as follows:

[0185]

[0186]

[0187] According to the table above, the size of the network model is 7B (Billion), the number of layers is 32, the hidden layer size is 4096, the number of multi-head attention is 32, the hidden layer size of the feedforward neural network is 16384, and the attention head size is 128.

[0188] After building a pre-trained text intent recognition model based on the Transformer decoder, the autoregressive language model training method can be used to perform supervised fine-tuning on the text intent recognition model. The loss function used in the supervised fine-tuning stage is consistent with the loss function used in the pre-training stage, as shown in the following formula. The language model can be used to minimize the maximum likelihood function:

[0189]

[0190] Among them, U represents the unsupervised corpus used as a sample, the above formula means using the first k tokens to predict the probability of the i-th token, and k represents the window size.

[0191] S203: Obtain the text to be recognized.

[0192] The text to be recognized includes one or more rounds of conversations. For example, the text to be recognized may be as follows:

[0193] Question 1: What’s the weather like today?

[0194] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0195] Question 2: What about tomorrow?

[0196] S204: Call the fine-tuned text intent recognition model and use an end-to-end approach to identify the text intent type corresponding to the text to be recognized.

[0197] In the question-answering scenario of a large language model, the text to be recognized is usually directly input into the large language model, and the corresponding results are output through the large language model. However, since the input text to be recognized may exist in multiple rounds of scenarios, a text rewriting model is needed to convert the text to be recognized into prompts with complete semantics. In addition, a large language model often cannot solve the problems of various plug-ins, so it is necessary to use the intent recognition model to determine the text intent type of the text to be recognized, and then distribute it to each special plug-in model to obtain the corresponding results. This is the two-stage framework of "multiple rounds of rewriting first, then intent recognition".

[0198] However, this two-stage framework may have the problem of error transmission. For example, the text to be recognized can be as follows:

[0199] “Question 1: Next I need you to help me with the Chinese-English translation task

[0200] Answer 1: Of course, please tell me what you need to translate

[0201] Question 2: I want to lie down

[0202] Answer 2: "I want to lie flat" or "I want to relax" may be appropriate translations depending on the context. Please provide more information for a more accurate translation.

[0203] Question 3: What’s the weather like today?

[0204] The two-stage framework may mistakenly rewrite the text to be recognized as "today's weather" and mistakenly determine the text intent type as "weather type". However, the correct rewriting should be "Chinese to English, today's weather", and the text intent type should be "main model". This is an intent error caused by a rewriting error.

[0205] For another example, the text to be recognized can be as follows:

[0206] Question 1: Write an acrostic poem and I will buy you a birthday present.

[0207] Answer 1: I love the mountains, so I plant pine trees in my garden. You love the people in the mountains, so you buy land and plant a vegetable garden.

[0208] Question 2: I’ll buy you a gift.”

[0209] The two-stage framework may mistakenly rewrite the text to be recognized as "I buy you a gift" and mistakenly determine the text intent type as "main model". However, the correct rewriting should be "Write an acrostic poem, I buy you a gift", and the text intent type should be "acrostic poem". This is an intent error caused by a rewriting error.

[0210] Since this two-stage framework may have the problem of error transmission, the embodiment of the present application adopts an end-to-end approach to avoid meaning graph recognition errors caused by multiple rounds of rewriting errors. Specifically, the text to be recognized is input into the large language model, and the text intent type corresponding to the text to be recognized is directly output without text rewriting.

[0211] Optionally, in one embodiment, the step of “calling the fine-tuned text intent recognition model and identifying the text intent type corresponding to the text to be recognized in an end-to-end manner” may include:

[0212] Input the text to be recognized into the fine-tuned text intent recognition model;

[0213] Based on the fine-tuned text intent recognition model, text intent recognition is performed on the text to be recognized, and the text intent type corresponding to the text to be recognized is output.

[0214] For example, Figure 4 As shown, the text to be recognized can be input into the fine-tuned text intent recognition model, and then the text intent type corresponding to the text to be recognized can be directly output without going through the text rewriting stage.

[0215] In one embodiment, not only can the 7B GPT model be used for supervised fine-tuning, but also a GPT model with larger-scale parameters can be used for supervised fine-tuning.

[0216] The application of the technical solution of this application can achieve a text intent recognition accuracy rate of 91%.

[0217] As can be seen from the above, this embodiment can obtain a target sample set, which includes multiple target samples with labels. The target samples are obtained by integrating the results output by a large language model according to preset prompts, and the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, the pre-trained text intent recognition model is supervised fine-tuned to obtain a fine-tuned text intent recognition model; the text to be recognized is obtained, and the text to be recognized includes one or more rounds of conversations; the fine-tuned text intent recognition model is called, and an end-to-end approach is used to identify the text intent type corresponding to the text to be recognized. The present application can directly identify the text intent type corresponding to the text to be recognized through the text intent recognition model, avoid executing the text rewriting step, eliminate the intention understanding deviation problem caused by text rewriting, and improve the accuracy of text intent recognition.

[0218] According to the method described in the previous embodiment, the following will be further described in detail by taking the text intention recognition device as an example of being specifically integrated into an electronic device. The embodiment of the present application provides a text intention recognition method, such as Figure 3 As shown, the specific process of the text intent recognition method can be as follows:

[0219] S301: The electronic device obtains a large language model and a preset prompt.

[0220] For example, in the embodiment of the present application, the large language model may be a pre-trained large language model developed independently, which includes a text structure recognition module and a text intent recognition module.

[0221] Among them, the preset prompts can be as follows:

[0222] "Complete text understanding tasks based on the context of multiple rounds of conversation:

[0223] Task 1, text rewriting: If the text contains omitted content or reference content, complete the reference resolution and obtain the text rewriting result; if the text does not contain omitted content or reference content, there is no need to rewrite the text;

[0224] Task 2, intent recognition: Identify the text intent type to which the text belongs, including:

[0225] - Main model: does not belong to other plugins

[0226] - Acrostic Poetry: Acrostic Poetry Creation is considered a positive example, and Acrostic Poetry Encyclopedia is considered a negative example

[0227] - Wenshengtu: Picture creation / picture editing is considered a positive example, and instructions that do not generate pictures are considered a negative example.

[0228] -Calendar: Date query / date calculation with positive examples, age calculation / eight characters / almanac / zodiac / time reasoning with negative examples

[0229] - Weather: Weather query / activity suggestion counts as positive, Weather Encyclopedia / UV / PM2.5 / UV Index / flood counts as negative

[0230] - Ancient Poetry: Reciting ancient poetry / appreciating ancient poetry counts as positive examples, while ancient poetry encyclopedia counts as negative examples

[0231] -Stocks: Stock information query / company information query / market information query counts as positive examples, stock encyclopedia / stock analysis / stock historical information counts as negative examples

[0232] -Code Interpreter: Code understanding, modification, repair, optimization, completion, implementation, transfer, execution, error explanation, visualization, and concept explanation are counted as positive examples, while code multiple-choice questions / programming learning / mind mapping / interview questions are counted as negative examples.

[0233] -Calculation: math problems / size comparison / proof problems / logical reasoning and positive examples

[0234] - Map: Route planning / route time / surrounding search are counted as positive examples, while train and flight information / surrounding road conditions / travel guide / transportation costs are counted as negative examples

[0235] -PDF summary: given a PDF file, questions are counted as positive examples

[0236] -Website: Website navigation needs are considered positive examples

[0237] - Picture description: Picture description is a positive example

[0238] -Exchange rate: exchange rate query calculation example

[0239] -Translation: Translation requests are considered positive examples"

[0240] Among them, the preset prompt includes two tasks, Task 1 is text rewriting, and Task 2 is intent recognition. The preset prompt clearly informs the specific requirements for intent recognition in Task 2, that is, the boundary between each plug-in support (positive example) and non-support (negative example). The above preset prompt includes 1 main model and 14 plug-ins.

[0241] S302: The electronic device obtains an initial text and calls a text structure recognition module of a large language model to identify a text structure type corresponding to the initial text.

[0242] S303: The electronic device uses the text intent recognition module of the large language model to perform text intent recognition on the initial text according to preset prompts, and obtains a text rewriting result corresponding to the initial text and a text intent type.

[0243] For example, the initial text obtained can be as follows:

[0244] Question 1: What’s the weather like today?

[0245] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0246] Question 2: Lunar calendar date 2024

[0247] Through the text structure recognition module in the large language model, it can be learned that the initial text belongs to a simple structure multi-round conversation text. Then, through the text intent recognition module in the large language model, it can be learned that the text rewriting result corresponding to the initial text is "Lunar Calendar Date 2024" and the text intent type corresponding to the initial text is "Main Model".

[0248] For another example, the initial text obtained can be as follows:

[0249] Question 1: What’s the weather like today?

[0250] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0251] Question 2: How did you get this?

[0252] The text structure recognition module in the large language model can determine that the initial text belongs to the reference class in the complex structure multi-round conversation text. Then, the text intent recognition module in the large language model can determine that the text rewrite result corresponding to the initial text is "How do you get the weather data?" and the text intent type corresponding to the initial text is "main model".

[0253] For another example, the initial text obtained can be as follows:

[0254] Question 1: What’s the weather like today?

[0255] Answer 1: Today's weather in Shenzhen (xxxx-xx-xx, Monday): Showers turning to light rain, High: 29°C, Low: 21°C, Relative humidity: 91%, Breeze, Wind speed: Level 4-5 turning to Level 1

[0256] Question 2: What about tomorrow?

[0257] The text structure recognition module in the large language model can be used to determine that the initial text belongs to the omission category in complex structure multi-round conversation texts. Then, the text intent recognition module in the large language model can be used to determine that the text rewriting result corresponding to the initial text is "What will the weather be like tomorrow?" and that the text intent type corresponding to the initial text is "weather type."

[0258] S304: The electronic device obtains an initial sample data set, a data set to be labeled, and a plurality of initial small language models, and determines the initial sample data set as a training set and the data set to be labeled as a test set.

[0259] S305: The electronic device trains an initial small language model using the training set, and determines prediction error data using the test set.

[0260] S306. The electronic device adds the predicted error data to the training set, updates the training set, trains the initial small language model with the training set to obtain a trained small language model, calls the trained small language model to perform label prediction on the test set to obtain a label prediction result, compares the label prediction result of this round with the label prediction result of the previous round to obtain a difference result, and filters the predicted error data with incorrect prediction from the difference result, adds the predicted error data to the training set, and updates the training set.

[0261] S307: The electronic device returns to execute the steps of training the initial small language model through the training set and determining the prediction error data through the test set, until the accuracy of the trained small language model reaches a preset standard, and the target difficult sample is obtained.

[0262] For example, Figure 6As shown, we can first obtain an initial sample data set 0, a data set to be labeled, and multiple initial small language models. The initial sample data set is used as a training set for training the network model, and the data set to be labeled is used as a test set for testing the network model. Then, we can use the training set to train the initial small language model 0 to obtain the trained small language model 0. The trained small language model 0 is called to perform label prediction on the test set to obtain the label prediction result 1. A portion of data is randomly sampled from the label prediction result 1, and after manual participation in labeling, the prediction error data 1 with incorrect predictions is filtered out.

[0263] Then, the initial sample data set 0 and the predicted error data 1 are used as new training sets. The initial small language model 1 is trained with the new training set. The trained small language model 1 is called to perform label prediction on the test set to obtain the label prediction result 2. The label prediction result 1 and the label prediction result 2 are compared to obtain the parts with differences. After manual labeling, the predicted error data 2 with incorrect predictions is filtered out.

[0264] Then, the initial sample data set 0, the predicted error data 1, and the predicted error data 2 are used as new training sets. The initial small language model 2 is trained with the new training set. The trained small language model 2 is called to perform label prediction on the test set to obtain the label prediction result 3. The label prediction result 2 and the label prediction result 3 are compared to obtain the parts with differences. After manual labeling, the predicted error data 3 with incorrect predictions is filtered out.

[0265] And so on, repeat the above steps until the accuracy of the trained small language model reaches the preset standard, complete the iteration, and use predicted error data 1, predicted error data 2, predicted error data 3... as target difficult samples.

[0266] S308: The electronic device constructs a target sample set based on the text rewriting result corresponding to the initial text, the text intention type, and the target difficult sample.

[0267] S309: The electronic device performs supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model.

[0268] S310: The electronic device obtains the text to be recognized, calls the fine-tuned text intent recognition model, and uses an end-to-end approach to identify the text intent type corresponding to the text to be recognized.

[0269] As can be seen from the above, this embodiment can obtain a large language model and preset prompts through an electronic device; obtain an initial text, and call the text structure recognition module of the large language model to identify the text structure type corresponding to the initial text; use the text intention recognition module of the large language model to perform text intention recognition on the initial text according to the preset prompt, and obtain the text rewriting result and text intention type corresponding to the initial text; obtain an initial sample data set, a data set to be labeled, and multiple initial small language models, and determine the initial sample data set as a training set, and determine the data set to be labeled as a test set; train the initial small language model through the training set, and determine the predicted error data through the test set; add the predicted error data to the training set, update the training set, train the initial small language model through the training set, obtain the trained small language model, and call the trained small language model to The test set performs label prediction to obtain label prediction results, compares the label prediction results of this round with the label prediction results of the previous round to obtain difference results, and filters the prediction error data of the prediction errors from the difference results, adds the prediction error data to the training set, and updates the training set; returns to execute the steps of training the initial small language model through the training set, and determining the prediction error data through the test set, until the accuracy of the trained small language model reaches the preset standard, and obtains the target difficult sample; constructs a target sample set based on the text rewriting results, text intent types, and target difficult samples corresponding to the initial text; based on the target sample set, performs supervised fine-tuning on the pre-trained text intent recognition model to obtain a fine-tuned text intent recognition model; obtains the text to be recognized, and calls the fine-tuned text intent recognition model, and applies an end-to-end approach to identify the text intent type corresponding to the text to be recognized. The present application can directly identify the text intent type corresponding to the text to be recognized through the text intent recognition model, avoids executing the text rewriting step, eliminates the intention understanding deviation problem caused by text rewriting, and improves the accuracy of text intent recognition.

[0270] In order to better implement the above method, the embodiment of the present application also provides a text intention recognition device, such as Figure 7 As shown, the text intent recognition device may include a first acquisition unit 701, a fine-tuning unit 702, a second acquisition unit 703, and a recognition unit 704, as follows:

[0271] A first acquisition unit 701 is configured to acquire a target sample set, wherein the target sample set includes a plurality of target samples carrying labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts, wherein the preset prompts include a text rewriting portion and an intent recognition portion;

[0272] A fine-tuning unit 702 is configured to perform supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model;

[0273] The second acquiring unit 703 is configured to acquire a text to be recognized, where the text to be recognized includes one or more rounds of conversation;

[0274] The recognition unit 704 is configured to call the fine-tuned text intent recognition model and identify the text intent type corresponding to the to-be-recognized text in an end-to-end manner.

[0275] Optionally, in some embodiments of the present application, the first acquisition unit may include a first acquisition subunit, a second acquisition subunit, and an integration subunit, as follows:

[0276] A first acquisition subunit is used to acquire a large language model and preset prompts;

[0277] A second acquisition subunit is configured to acquire an initial text and call the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompt, thereby obtaining a text rewriting result corresponding to the initial text and a text intent type corresponding to the initial text;

[0278] The integration subunit is used to integrate the text rewriting result corresponding to the initial text and the text intention type corresponding to the initial text to construct a target sample set.

[0279] Optionally, in some embodiments of the present application, the second acquisition sub-unit can be specifically used to obtain the initial text, and call the text intention recognition module of the large language model to perform reference recognition on the initial text according to the text rewriting part in the preset prompt to obtain the reference words in the initial text; perform reference resolution on the reference words, and perform text rewriting on the initial text according to the reference resolution result to obtain the text rewriting result corresponding to the initial text; call the text intention recognition module of the large language model to perform intent recognition on the text rewriting result according to the intent recognition part in the preset prompt to obtain the text intent type corresponding to the initial text.

[0280] Optionally, in some embodiments of the present application, the second acquisition sub-unit can be specifically used to acquire the initial text, and call the text structure recognition module of the large language model to identify the text structure type corresponding to the initial text; input the initial text and the text structure type corresponding to the initial text into the text intention recognition module of the large language model, and perform text intention recognition on the initial text according to the preset prompt and the text structure type through the text intention recognition module to obtain the text rewriting result corresponding to the initial text and the text intention type corresponding to the initial text.

[0281] Optionally, in some embodiments of the present application, the first acquisition subunit can be specifically used to obtain an initial sample data set, a data set to be labeled, and multiple initial small language models; determine the initial sample data set as a training set, and determine the data set to be labeled as a test set; train the initial small language model through the training set to obtain a trained small language model; call the trained small language model to perform label prediction on the test set to obtain a label prediction result; filter out prediction error data with incorrect predictions from the label prediction results; add the prediction error data to the training set to update the training set; train the initial small language model through the training set to obtain a trained small language model; call the trained small language model to perform label prediction on the test set to obtain a label prediction result; compare the label prediction result of this round with the label prediction result of the previous round to obtain a difference result; filter out prediction error data with incorrect predictions from the difference result; add the prediction error data to the training set to update the training set; return to execute the steps of training the initial small language model through the training set and determining the prediction error data through the test set, until the accuracy of the trained small language model reaches a preset standard, and the target difficult sample is obtained.

[0282] Optionally, in some embodiments of the present application, the fine-tuning unit can be specifically used to call the pre-trained text intent recognition model to predict multiple words in the target sample to obtain a prediction result; calculate the model loss based on the difference between the target sample and the prediction result; adjust the model parameters of the pre-trained text intent recognition model based on the model loss to obtain a fine-tuned text intent recognition model.

[0283] Optionally, in some embodiments of the present application, the recognition unit can be specifically used to input the text to be recognized into the fine-tuned text intent recognition model; perform text intent recognition on the text to be recognized based on the fine-tuned text intent recognition model, and output the text intent type corresponding to the text to be recognized.

[0284] As can be seen from the above, this embodiment can obtain a target sample set through the first acquisition unit 701. The target sample set includes multiple target samples with labels. The target samples are obtained by integrating the results output by a large language model according to preset prompts. The preset prompts include a text rewriting part and an intent recognition part. The fine-tuning unit 702 performs supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model. The second acquisition unit 703 obtains the text to be recognized. The text to be recognized includes one or more rounds of conversations. The fine-tuned text intent recognition model is called by the recognition unit 704, and an end-to-end approach is used to identify the text intent type corresponding to the text to be recognized. The present application can directly identify the text intent type corresponding to the text to be recognized through the text intent recognition model, avoid executing the text rewriting step, eliminate the intention understanding deviation problem caused by text rewriting, and improve the accuracy of text intent recognition.

[0285] The present application also provides an electronic device, such as Figure 8 , which shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application. The electronic device may be a terminal or a server, etc. Specifically:

[0286] The electronic device may include one or more processors 801, one or more computer-readable storage media memories 802, a power supply 803, an input unit 804, and other components. It will be understood by those skilled in the art that Figure 8 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.

[0287] The processor 801 is the control center of the electronic device. It connects all parts of the electronic device using various interfaces and circuits. It performs various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 802 and accessing data stored in the memory 802. Optionally, the processor 801 may include one or more processing cores. Preferably, the processor 801 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 801.

[0288] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing by running the software programs and modules stored in the memory 802. The memory 802 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 802 may also include a memory controller to provide the processor 801 with access to the memory 802.

[0289] The electronic device also includes a power supply 803 for supplying power to various components. Preferably, the power supply 803 can be logically connected to the processor 801 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 803 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.

[0290] The electronic device may further include an input unit 804, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0291] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 801 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 802 according to the following instructions, and the processor 801 will run the application programs stored in the memory 802 to implement various functions as follows:

[0292] An embodiment of the present application provides a text intent recognition method and related equipment, which can obtain a target sample set, wherein the target sample set includes multiple target samples with labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts, and the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, the pre-trained text intent recognition model is supervised fine-tuned to obtain a fine-tuned text intent recognition model; the text to be recognized is obtained, and the text to be recognized includes one or more rounds of conversations; the fine-tuned text intent recognition model is called, and the text intent type corresponding to the text to be recognized is identified in an end-to-end manner.

[0293] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0294] As can be seen from the above, this embodiment can obtain a target sample set, which includes multiple target samples with labels. The target samples are obtained by integrating the results output by a large language model according to preset prompts, and the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, the pre-trained text intent recognition model is supervised fine-tuned to obtain a fine-tuned text intent recognition model; the text to be recognized is obtained, and the text to be recognized includes one or more rounds of conversations; the fine-tuned text intent recognition model is called, and an end-to-end approach is used to identify the text intent type corresponding to the text to be recognized. The present application can directly identify the text intent type corresponding to the text to be recognized through the text intent recognition model, avoid executing the text rewriting step, eliminate the intention understanding deviation problem caused by text rewriting, and improve the accuracy of text intent recognition.

[0295] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0296] To this end, an embodiment of the present application provides a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps of any of the text intent recognition methods provided in the embodiments of the present application. For example, the instructions can execute the following steps:

[0297] An embodiment of the present application provides a text intent recognition method and related equipment, which can obtain a target sample set, wherein the target sample set includes multiple target samples with labels, and the target samples are obtained by integrating the results output by a large language model according to preset prompts, and the preset prompts include a text rewriting part and an intent recognition part; based on the target sample set, the pre-trained text intent recognition model is supervised fine-tuned to obtain a fine-tuned text intent recognition model; the text to be recognized is obtained, and the text to be recognized includes one or more rounds of conversations; the fine-tuned text intent recognition model is called, and the text intent type corresponding to the text to be recognized is identified in an end-to-end manner.

[0298] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0299] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0300] Since the instructions stored in the computer-readable storage medium can execute the steps in any text intent recognition method provided in the embodiments of the present application, the beneficial effects that can be achieved by any text intent recognition method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0301] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the aforementioned text intent recognition.

[0302] The above is a detailed introduction to a text intent recognition method and related equipment provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for identifying text intent, characterized in that: include: Obtaining a target sample set, the target sample set including a plurality of labeled target samples, the target samples being obtained by integrating results output by a large language model according to preset prompts, the preset prompts including a text rewriting portion and an intent recognition portion, the target samples including a text rewriting result and a text intent type for an initial text, the large language model including a text intent recognition module, the text intent recognition module being configured to perform text rewriting and intent recognition on an input text; Based on the target sample set, supervised fine-tuning is performed on the pre-trained text intent recognition model to obtain a fine-tuned text intent recognition model; Acquire a text to be recognized, where the text to be recognized includes one or more rounds of conversation; The fine-tuned text intent recognition model is called to identify the text intent type corresponding to the text to be recognized in an end-to-end manner. The fine-tuned text intent recognition model does not go through the text rewriting stage and directly outputs the text intent type corresponding to the text to be recognized.

2. The text intent recognition method according to claim 1, characterized in that The large language model includes a text intent recognition module, and obtaining a target sample set includes: Get large language models and preset prompts; Acquire an initial text, and call the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompt, to obtain a text rewriting result corresponding to the initial text and a text intent type corresponding to the initial text; The text rewriting result corresponding to the initial text and the text intention type corresponding to the initial text are integrated to construct a target sample set.

3. The text intent recognition method according to claim 2, characterized in that: The obtaining of the initial text and calling the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompt to obtain a text rewriting result corresponding to the initial text and a text intent type corresponding to the initial text include: Acquire an initial text, and call the text intention recognition module of the large language model to perform reference recognition on the initial text according to the text rewriting part in the preset prompt to obtain the reference words in the initial text; Performing a referential resolution on the referential words, and rewriting the initial text according to the referential resolution result to obtain a text rewriting result corresponding to the initial text; The text intention recognition module of the large language model is called to perform intention recognition on the text rewriting result according to the intention recognition part in the preset prompt to obtain the text intention type corresponding to the initial text.

4. The text intent recognition method according to claim 2, characterized in that: The large language model further includes a text structure recognition module, which obtains the initial text and calls the text intent recognition module of the large language model to perform text intent recognition on the initial text according to the preset prompt, thereby obtaining a text rewriting result corresponding to the initial text and a text intent type corresponding to the initial text, including: Acquire an initial text, and call the text structure recognition module of the large language model to identify a text structure type corresponding to the initial text; The initial text and the text structure type corresponding to the initial text are input into the text intent recognition module of the large language model, and the text intent recognition module performs text intent recognition on the initial text according to the preset prompts and the text structure type to obtain the text rewriting result corresponding to the initial text and the text intent type corresponding to the initial text.

5. The text intent recognition method according to claim 1, characterized in that: The obtaining of the target sample set includes: Obtain an initial sample data set, a data set to be labeled, and multiple initial small language models; Determine the initial sample data set as a training set, and determine the to-be-labeled data set as a test set; Training the initial small language model using the training set, and determining prediction error data using the test set; Adding the predicted error data to the training set to update the training set; Return to the step of training the initial small language model using the training set and determining prediction error data using the test set until the accuracy of the trained small language model reaches a preset standard, thereby obtaining a target difficult sample.

6. The text intention recognition method according to claim 5, characterized in that: The step of training the initial small language model using the training set and determining prediction error data using the test set includes: Training the initial small language model using the training set to obtain a trained small language model; Calling the trained small language model to perform label prediction on the test set to obtain a label prediction result; Filtering prediction error data of prediction errors from the label prediction results.

7. The text intent recognition method according to claim 5, characterized in that: The returning step of training the initial small language model using the training set and determining prediction error data using the test set until the accuracy of the trained small language model reaches a preset standard, thereby obtaining a target difficult sample, includes: Training the initial small language model using the training set to obtain a trained small language model; Calling the trained small language model to perform label prediction on the test set to obtain a label prediction result; Compare the label prediction results of this round with those of the previous round to obtain the difference results; filtering prediction error data of prediction errors from the difference results; Adding the predicted error data to the training set to update the training set; Return to the step of training the initial small language model using the training set and determining prediction error data using the test set until the accuracy of the trained small language model reaches a preset standard, thereby obtaining a target difficult sample.

8. The text intent recognition method according to claim 1, characterized in that: The method of performing supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model includes: Calling the pre-trained text intent recognition model to predict multiple words in the target sample to obtain prediction results; Calculating a model loss based on the difference between the target sample and the predicted result; The model parameters of the pre-trained text intent recognition model are adjusted based on the model loss to obtain a fine-tuned text intent recognition model.

9. The text intent recognition method according to claim 1, characterized in that: The calling of the fine-tuned text intent recognition model and identifying the text intent type corresponding to the to-be-recognized text in an end-to-end manner includes: Inputting the text to be recognized into the fine-tuned text intent recognition model; Based on the fine-tuned text intent recognition model, text intent recognition is performed on the text to be recognized, and a text intent type corresponding to the text to be recognized is output.

10. A text intention recognition device, characterized in that: include: A first acquisition unit is configured to acquire a target sample set, wherein the target sample set includes a plurality of target samples carrying labels, the target samples being obtained by integrating the results output by a large language model according to preset prompts, the preset prompts including a text rewriting portion and an intent recognition portion, the target samples including a text rewriting result and a text intent type for an initial text, the large language model including a text intent recognition module, the text intent recognition module being configured to perform text rewriting and intent recognition on an input text; A fine-tuning unit, configured to perform supervised fine-tuning on the pre-trained text intent recognition model based on the target sample set to obtain a fine-tuned text intent recognition model; A second acquiring unit is configured to acquire a text to be recognized, where the text to be recognized includes one or more rounds of conversation; The recognition unit is used to call the fine-tuned text intent recognition model and apply an end-to-end approach to identify the text intent type corresponding to the text to be recognized. The fine-tuned text intent recognition model does not go through the text rewriting stage and directly outputs the text intent type corresponding to the text to be recognized.

11. An electronic device, characterized in that: It comprises a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to perform the operations in the text intent recognition method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, which are suitable for being loaded by a processor to execute the steps in the text intent recognition method according to any one of claims 1 to 9.

13. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the text intent recognition method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Method for obtaining target intention recognition model and intention recognition method

    CN114757176A

  • Information processing method and device based on large language model, equipment and storage medium

    CN117521675A