Regular expression generation and intention recognition method, related equipment and program product

By performing semantic similarity clustering and large model generation on the corpus data of intent recognition tasks, the problems of high cost and low quality of manually writing regular expressions in existing technologies are solved, and efficient and accurate regular expression generation and intent recognition are achieved.

CN121901424APending Publication Date: 2026-04-21IFLYTEK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
IFLYTEK CO LTD
Filing Date
2025-12-18
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing technologies rely on manual coding to generate regular expressions, which is costly and results in low-quality regular expressions that are prone to missed or false positives, especially in complex business scenarios.

Method used

By acquiring corpus data of intent recognition tasks in the target scene, semantic similarity clustering is performed, and regular expressions for subcategories are generated using a large model. Then, deduplication and similarity merging are performed to generate a high-quality set of regular expressions.

Benefits of technology

It improves the intelligence and quality of regular expression generation, adapts to complex business scenarios, reduces reliance on manual intervention, and enhances the recognition effect of intent recognition tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121901424A_ABST
    Figure CN121901424A_ABST
Patent Text Reader

Abstract

The invention discloses a regular expression generation and intention recognition method, related equipment and a program product, original texts of the same intention label are clustered, regular expressions are generated in a classified mode, it can be ensured that the generated regular expressions are more accurately matched with specific business scenes, and the user experience is improved. And confusion of different types of texts is avoided. Furthermore, through structured combination (de-duplication and similar combination) processing on the regular expressions belonging to the sub-categories of the same intention label, the regular expressions can be more universal, and meanwhile, the high matching accuracy of the regular expressions can be kept. Compared with a method of directly generating a general regular expression for all original texts under one intention label, the regular expression obtained by adopting the method is higher in quality and can better adapt to a complex business scene, and the recognition effect of a subsequent intention recognition task is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intent recognition technology, and more specifically, to a regular expression generation and intent recognition method, related equipment and program products. Background Technology

[0002] There is a need for intent recognition in various scenarios, such as intelligent customer service scenarios, where intent recognition is performed on customer questions to determine the customer's intent, such as loan applications, credit card applications, investment consultations, etc.

[0003] One common intent recognition method employs a regular expression matching strategy, where pre-edited regular expressions correspond to different intent tags. Upon receiving the request text, each regular expression is matched against the request text, and the intent tag corresponding to a successfully matched regular expression is taken as the intent recognition result. Regarding regular expression creation, current technologies generally rely on business experts writing regular expressions based on their business experience. This approach is heavily dependent on manual labor, resulting in high costs and long development times. Some solutions collect corpus data for different intent tags, call a model to analyze the full corpus data for each intent tag, and directly generate the corresponding regular expression. However, this approach generates overly generalized regular expressions when facing complex business scenarios, meaning the generated regular expressions are of low quality and prone to missed or false positives. Summary of the Invention

[0004] In view of the above problems, this application is proposed to provide a regular expression generation and intent recognition method, related equipment, and program products, so as to improve the intelligence level of the regular expression generation process for intent recognition tasks and improve the quality of the generated regular expressions. The specific solution is as follows:

[0005] Firstly, a method for generating regular expressions is provided, including:

[0006] Acquire corpus data for the intent recognition task of the target scene, wherein the corpus data includes the original text and labeled intent tags;

[0007] The original text sets belonging to the same intent tag are clustered according to semantic similarity to obtain more than one sub-category;

[0008] For each subcategory of original text, a large model is invoked to extract common patterns from the subcategory of original text, generating a regular expression for the subcategory. The regular expressions of each subcategory under the same intent tag form the initial set of regular expressions for the intent tag.

[0009] For each intent tag, an initial set of regular expressions is used to deduplicate the initial set of regular expressions and merge similar regular expressions into more general regular expressions, thereby obtaining a set of regular expressions corresponding to each intent tag in the target scenario.

[0010] In one possible design, in another implementation of the first aspect of the embodiments of this application, after calling the large model to generate the regular expression for each subcategory, the method further includes:

[0011] The performance metrics of the regular expression for each subcategory are obtained by performing a matching test on the original text subset of the corresponding category and / or other categories.

[0012] If the performance metrics of a target subcategory's regular expression do not meet the set performance requirements, then the original texts that mismatch the target subcategory's regular expression are filtered out, and the mismatched original texts are used to guide the large model to optimize and adjust the target subcategory's regular expression, resulting in the adjusted target subcategory's regular expression.

[0013] In one possible design, another implementation of the first aspect of the embodiments of this application further includes:

[0014] Calculate the center vector of each subcategory based on the original text subset under each subcategory;

[0015] Upon receiving incremental corpus data, the similarity between the vector of the original text in the incremental corpus data and the center vector of each sub-category is calculated. Based on the similarity, the sub-category to which the original text in the incremental corpus data belongs is determined, and the original text subset under the sub-category is added.

[0016] When the set update cycle is reached, the regular expression for each subcategory is updated based on the latest subset of original text under each subcategory, and the set of regular expressions corresponding to each intent tag is updated.

[0017] In one possible design, in another implementation of the first aspect of the embodiments of this application, after adding the original text from the incremental corpus data to the subset of original texts under the corresponding subcategory, the method further includes:

[0018] Update the center vector of the subcategory to which the original text belongs in the incremental corpus data.

[0019] In one possible design, another implementation of the first aspect of the embodiments of this application further includes:

[0020] Record the matching accuracy of the regular expression corresponding to each intent tag. The matching accuracy is obtained by performing a matching test on the corpus data using the regular expression.

[0021] Secondly, an intent recognition method is provided, including:

[0022] Obtain the request text for the intent recognition task in the target scene;

[0023] The regular expressions in the set of regular expressions corresponding to each intent tag in the target scenario are called, and the request text is matched against the entire text one by one. The set of regular expressions corresponding to each intent tag in the target scenario is obtained by the regular expression generation method described in claim 5.

[0024] If a matching regular expression exists and the matching accuracy of the matching regular expression exceeds a first accuracy threshold, then the intent label corresponding to the matching regular expression is taken as the final intent recognition result.

[0025] In one possible design, another implementation of the second aspect of the embodiments of this application further includes:

[0026] If the matching accuracy of the successfully matched regular expression is between the second accuracy threshold and the first accuracy threshold, then the intent tag corresponding to the successfully matched regular expression is taken as a regular expression candidate result, and the second accuracy threshold is less than the first accuracy threshold.

[0027] The intent recognition model related to the target scene is invoked to perform intent recognition on the request text, and model candidate results are obtained;

[0028] The final intent recognition result is determined based on the regularization candidate results and the model candidate results.

[0029] In one possible design, another implementation of the second aspect of the embodiments of this application further includes:

[0030] If the matching accuracy of the successfully matched regular expression does not exceed the second accuracy threshold, or if there is no successfully matched regular expression, then the intent recognition model related to the target scene is invoked to perform intent recognition on the request text, and the intent recognition result output by the model is taken as the final intent recognition result, wherein the second accuracy threshold is less than the first accuracy threshold.

[0031] Thirdly, an electronic device is provided, comprising: a memory and a processor;

[0032] The memory is used to store programs;

[0033] The processor is configured to execute the program to implement the steps of the regular expression generation method described in any of the first aspects of this application, or to implement the steps of the intent recognition method described in any of the second aspects of this application.

[0034] Fourthly, a readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the regular expression generation method described in any of the preceding first aspects of this application, or implements the steps of the intent recognition method described in any of the preceding second aspects of this application.

[0035] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the steps of the regular expression generation method described in any of the first aspects of this application, or implements the steps of the intent recognition method described in any of the second aspects of this application.

[0036] By using the above technical solution, this application can automatically generate a set of regular expressions corresponding to different intent tags based on the corpus data of the intent recognition task in the target scene, reducing the dependence on manual labor and improving the generation efficiency of regular expressions.

[0037] Furthermore, this application employs a three-stage generation strategy. In the first stage, the original texts under the same intent tag are clustered according to semantic similarity, resulting in subsets of original texts corresponding to more than one subcategory. In the second stage, a large model is invoked to generate regular expressions for each subcategory's original text subset. In the third stage, the regular expressions of each subcategory under the same intent tag are combined to form an initial set of regular expressions corresponding to the intent tag, and the large model is invoked to remove duplicates and merge similar regular expressions, resulting in an optimized set of regular expressions for each intent tag. By clustering the original texts under the same intent tag and generating regular expressions category by category, this application ensures that the generated regular expressions more accurately match specific business scenarios and avoids confusion between texts of different categories. Furthermore, by performing "structured merging" (duplicate removal and similarity merging) on ​​regular expressions belonging to subcategories of the same intent tag, the regular expressions can be made more universal while maintaining high matching accuracy. Compared to directly generating a general regular expression for all original text under an intent label, the regular expression obtained by the method in this application is of higher quality, can better adapt to complex business scenarios, and improves the recognition effect of subsequent intent recognition tasks. Attached Figure Description

[0038] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0039] Figure 1 A schematic diagram of an implementation system architecture for the regular expression generation and intent recognition method provided in this application embodiment;

[0040] Figure 2 This is a schematic diagram of a regular expression generation method provided in an embodiment of this application;

[0041] Figure 3 A flowchart illustrating the automated generation of regular expressions for an incremental update process, provided as an embodiment of this application;

[0042] Figure 4 This is a schematic flowchart of an intent recognition method provided in an embodiment of this application;

[0043] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0044] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0045] It is understood that before using the technical solutions disclosed in the various embodiments of this application, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this application in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0046] In terms of generating regular expressions for intent recognition tasks, some solutions rely on business experts writing regular expressions based on their business experience. This approach is heavily dependent on manual labor, which is costly and time-consuming.

[0047] Other solutions collect corpus data with different intent tags, call the model to analyze the full corpus data for each intent tag, and directly generate the regular expression corresponding to the intent tag. However, intent tags for intent recognition tasks are generally manually set based on business needs (e.g., intent tags in the intelligent customer service scenario of the financial industry include "query business," "submit application," "complaint and suggestion," etc.). These intent tags are usually business logic-driven, summarizing the user's ultimate goal, but do not specify the specific expression path for the user to achieve that goal. Therefore, the text corpus under the same broad intent tag may have multiple completely different semantic subclasses in terms of implementation method, triggering conditions, and specific objects. The above solutions, which call the model to directly generate regular expressions based on the full corpus of intent tags, treat a heterogeneous text set as a homogeneous whole, requiring the model to "generalize" a single rule covering all variations. This forces the generation process to make a difficult trade-off between "overfitting a few patterns" and "overgeneralization leading to loss of accuracy," and the resulting regular expressions are prone to the following defects:

[0048] The trade-off between precision and recall: In order to cover all cases, the generated regular expression may use broad matching, leading to a surge in false matches.

[0049] Ignoring key constraints: For keywords or fixed sentence structures that must appear in different subclasses, since these constraints are not universal in the global context, the generated regular expression cannot accurately capture these key constraints.

[0050] As can be seen from the above, the regular expressions generated by the above solutions are of low quality and are prone to problems such as missed judgments and false judgments, especially when facing complex business scenarios, the problems are more serious.

[0051] This application provides a scheme for automatically generating regular expressions for intent recognition tasks, which can improve the quality of the generated regular expressions. The regular expression generation scheme provided in this application can be applied to intent recognition tasks in a variety of different scenarios, such as intelligent customer service scenarios in the financial industry, where intent recognition is performed on customer dialogue data. This application will not exhaustively list all applicable scenarios.

[0052] This application provides a method for generating regular expressions and a method for intent recognition based on the generated regular expressions. The above method can be applied to, for example... Figure 1 The system architecture shown may include a terminal 100 and a server 200. The server 200 may include one or more servers (…). Figure 1 (This example uses a server as an illustration).

[0053] Either terminal 100 or server 200 can be used independently to execute the regular expression generation method or intent recognition method provided in the embodiments of this application. Alternatively, terminal 100 and server 200 can also be used collaboratively to execute the regular expression generation method or intent recognition method provided in the embodiments of this application.

[0054] The following description Figure 1 The product form of the mid-terminal 100;

[0055] The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle-mounted device, conference terminal, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.

[0056] First, the regular expression generation method provided in the embodiments of this application will be introduced, taking the application of this method to a computer device as an example. Specifically, the computer device may be... Figure 1 The system consists of terminal 100 or a combination of terminal 100 and server 200. (Refer to...) Figure 2 The regular expression generation method specifically includes the following steps:

[0057] Step S100: Obtain the corpus data of the intent recognition task of the target scene, wherein the corpus data includes the original text and the labeled intent tags.

[0058] The regular expression generation method of this application can be applied to the intent recognition task of the target scene to generate regular expressions corresponding to each set intent label of the intent recognition task.

[0059] The target scenarios can be varied, such as intelligent customer service scenarios, voice assistant scenarios, information recommendation scenarios, advertising and marketing scenarios, etc.

[0060] Taking the intelligent customer service scenario in the financial industry as an example, the intent tags corresponding to the intent recognition task can be several tags set by humans based on business needs, including but not limited to: loan application, credit card application, investment consultation, etc.

[0061] This application can collect corpus data related to intent recognition tasks in target scenes, including raw text and labeled intent tags.

[0062] Taking intelligent customer service scenarios in the financial industry as an example, multi-channel dialogue data from financial institutions such as banks, securities firms, and credit card centers can be collected, including but not limited to intelligent customer service text dialogues, transcripts of outbound call recordings, and online consultation messages. Based on this, valid data can be filtered according to business intent tags, eliminating meaningless dialogues (such as blank content or purely verbal interactions), duplicate dialogues (such as records of the same customer repeatedly asking the same question), and sensitive information data, ensuring that the data is strongly correlated with the financial business intent.

[0063] Further, optionally, the data can be standardized. This includes removing special symbols (such as "【】", "@", "#"), redundant spaces, and transcribed characters (such as meaningless interjections like "um" or "ah" in audio transcription). A terminology mapping table can be used to standardize synonymous expressions (e.g., "credit card limit increase", "increase credit card limit", "adjust limit" should be standardized to "credit card limit increase").

[0064] Data labelers accurately label the dialogue data according to the financial intent classification system, forming a structured dataset of "raw text - intent label".

[0065] In some possible implementations, considering the imbalance of the corpus data in the target scenario, a data augmentation process can be added to the corpus data.

[0066] This embodiment provides a data augmentation method, including but not limited to: "semantic restatement" and "boundary case generation".

[0067] "Semantic paraphrasing" refers to using a large model to paraphrase the original text of a few samples, ensuring that the semantics remain unchanged but the expressions are diversified. For example, for the few sample text "I want to apply for a mortgage loan", after paraphrasing by the large model, we can get multiple enhanced texts with the same semantics but different expressions, such as "How do I apply for a mortgage loan?" and "I need to apply for a mortgage loan to buy a house".

[0068] "Boundary case generation" refers to manually supplementing boundary cases. Boundary cases refer to data of a category that accounts for a small proportion of the corpus data, and similar corpus data is manually added for these cases.

[0069] Step S110: Cluster the original text sets belonging to the same intent tag according to semantic similarity to obtain more than one sub-category.

[0070] In this embodiment, it is considered that the intent labels for the intent recognition task are set based on business needs and their meanings are relatively broad. The original text set under the same intent label may contain multiple original texts with different semantics. In order to ensure that the generated regular expression can accurately match different semantic texts, this step performs "semantic decoupling" on the original text set under the same intent label, breaking down the broad business intent label into specific linguistic patterns. That is, the original text set under the same intent label is clustered according to semantic similarity to obtain a subset of original texts corresponding to more than one subcategory. For example, the original text under the intent label "complaints and suggestions" is clustered into semantically clear subcategories such as "complain about logistics delays", "complain about customer service attitude", and "suggest adding functions".

[0071] In some possible implementations, a category ID can be assigned to each subcategory after clustering: category_ID. For example, the category ID value can be incremented sequentially from 1, thus obtaining structured data consisting of the original text, category ID, and intent label.

[0072] This step involves clustering the original text set based on semantic similarity, which can be achieved using a clustering algorithm. Furthermore, this embodiment also provides a method for clustering original text sets with the same intent tag by leveraging the semantic understanding capabilities of a large model. Specifically:

[0073] A first prompt is generated based on the original text set with the same intent label. The first prompt is then fed into the large model to instruct the large model to aggregate semantically similar texts in the original text set into the same sub-category, thus obtaining the clustering result output by the large model.

[0074] The following is an example of an alternative to the first prompt:

[0075] You are an algorithm expert skilled in text clustering and semantic analysis. You are now provided with several text corpora. Please cluster these texts based on semantic similarity, with the following general requirements:

[0076]

Task Requirements

[0077] 1. Clustering is performed using semantic understanding, rather than relying primarily on character similarity.

[0078] 2. The number of clusters is not preset; it is automatically generated by you based on the actual semantic situation.

[0079] 3. Texts within the same category should express roughly the same meaning.

[0080] 4. Assign a unique, incrementing value (category_ID) to each category.

[0081] The text corpus is as follows:

[0082] <Original text collection>.

[0083] The original text set with the same intent label is filled into the corresponding slots in the first prompt to obtain the edited first prompt, which is then fed into the large model to obtain the clustering results output by the large model.

[0084] This embodiment leverages the semantic understanding capabilities of a large model to perform clustering processing on the original text set, dividing the original text set into several subcategories based on semantic similarity.

[0085] Step S120: For each sub-category of original text subset, call the large model to extract common patterns from the sub-category of original text subset, generate regular expressions for the sub-category, and form the initial regular expression set for the intent label by the regular expressions of each sub-category under the same intent label.

[0086] Specifically, for each sub-category of original text obtained from clustering in the previous step, this step calls the large model to extract common patterns from the original text in the original text subset, and generates regular expressions corresponding to the sub-category based on the extracted common patterns.

[0087] After obtaining the regular expression corresponding to each subcategory, the initial set of regular expressions for the intent label can be formed by combining the regular expressions of the subcategories under the same intent label. For example, the original text of intent label X is clustered into three subcategories with category IDs ID1, ID2, and ID3. For each subcategory, the large model is called to generate the corresponding regular expression. Then, the initial set of regular expressions for intent label X can be formed by combining the regular expressions corresponding to ID1, ID2, and ID3.

[0088] It should be noted that the regular expression corresponding to each subcategory generated by the large model can be one or more, depending on the analysis results of the large model based on the original text subset of the subcategory.

[0089] In this embodiment, the process of calling the large model to extract common patterns from the original text subsets under the subcategories and generating regular expressions for the subcategories may include:

[0090] A second prompt is generated based on the original text subset under the subcategory. The second prompt is then fed into the large model to instruct the large model to extract common patterns from the original text subset under the subcategory, generate a regular expression for the subcategory, and obtain the regular expression for the subcategory output by the large model.

[0091] The following is an example of an optional second prompt:

[0092] You are a regular expression expert. Based on the text I provide, please automatically extract common patterns and generate a regular expression that can perfectly match the given text and also has generalization capabilities.

[0093] Please follow these steps to complete:

[0094] 1. Analyze the common language structures and keywords in the provided sample texts.

[0095] 2. Design a regular expression that can completely match all example texts and maintain generalization for sentences with similar semantics.

[0096] 3. Before outputting, ensure that the example text is tested with this regular expression and all verifications pass.

[0097] The following text is provided:

[0098] <Text list>.

[0099] For each subcategory, the original text subset under the subcategory is filled into the corresponding slots in the second prompt mentioned above to obtain the edited second prompt, which is then fed into the large model to obtain the regular expression for each subcategory output by the large model.

[0100] This step leverages the semantic understanding and text generation capabilities of the large model to analyze a subset of the input original text, extract its common patterns, and generate regular expressions for subcategories based on these patterns, ensuring that the generated regular expressions accurately match the subcategories.

[0101] Step S130: For the initial regular expression set of each intent tag, call the large model to deduplicate the initial regular expression set and merge similar regular expressions into more general regular expressions to obtain the regular expression set corresponding to each intent tag in the target scenario.

[0102] Specifically, the previous step yielded an initial set of regular expressions for each intent tag in the intent recognition task of the target scene. In this embodiment, to improve the simplicity and generalization of the regular expression set for each intent tag, a large model is further invoked to perform "structured deduplication" processing on the initial regular expression set. Similar regular expressions are merged into more general regular expressions, while dissimilar regular expressions are retained as independent entries, thereby improving the quality of the regular expression set for each intent tag.

[0103] In this embodiment, the process of calling a large model to deduplicate the initial set of regular expressions and merging similar regular expressions into a more general regular expression may include:

[0104] A third prompt is generated based on the initial set of regular expressions for each intent tag. The third prompt is then fed into the large model to instruct the large model to deduplicate the initial set of regular expressions and merge similar regular expressions into more general ones, resulting in the set of regular expressions for each intent tag output by the large model.

[0105] The following is an example of an optional third prompt:

[0106] You are a regular expression expert. Your task is to deduplicate, merge, and generalize a set of regular expressions.

[0107] Please handle this strictly according to the following rules:

[0108] Task objective:

[0109] Perform the following steps on the input multiple regular expressions:

[0110] 1. Deduplication: Removes identical regular expressions.

[0111] 2. Similarity merging: Merging regular expressions that are highly similar in meaning or structure into a more general and versatile regular expression.

[0112] 3. If two expressions are semantically unrelated and cannot be generalized and merged, they should be separated by a delimiter.

[0113] The provided set of regular expressions is as follows:

[0114] <Initial set of regular expressions>.

[0115] For each intent tag, the corresponding initial set of regular expressions is filled into the corresponding slots in the third prompt to obtain the edited third prompt, which is then fed into the large model to obtain the set of regular expressions for each intent tag output by the large model.

[0116] This step leverages the semantic understanding and text generation capabilities of the large model to perform "structured deduplication" on the initial set of regular expressions for the same intent tag. This ensures the simplicity of the regular expression set for each intent tag while improving the generalization of the regular expressions.

[0117] The method provided in this embodiment first performs "semantic decoupling" on the original text set under the same intent tag before generating regular expressions, breaking down the broad business intent tag into specific linguistic patterns. That is, it groups the original text under the same intent tag according to its own semantics. For example, it can automatically cluster the original text under the intent tag "complaints and suggestions" into semantically clear subcategories such as "complaining about logistics delays," "complaining about customer service attitude," and "suggesting adding features." This fundamentally solves the problem of homogeneous sets being homogenized. Subsequently, the large model generates regular expressions for each homogenous subcategory. Since the text patterns within the original text subset corresponding to the subcategory are highly consistent, the generated regular expressions can be more accurate and compact, directly improving the matching accuracy of each subcategory.

[0118] Furthermore, by performing "structured merging" (duplicate removal and similarity merging) on ​​regular expressions for each subcategory under the same intent tag, controllable generalization of regular expressions is achieved. During the merging phase, the large model can analyze the regular expressions for each subcategory under the same intent tag to determine which are essentially similar in pattern (e.g., "how to check balance" and "how to view balance"), thus merging them into a more general regular expression, achieving simplification of the regular expression; while retaining those essentially different patterns (e.g., "check balance" and "cancel account"). This achieves precise control over the regular expression generalization process. The difficult one-step generalization problem of traditional solutions is decomposed into two steps: "precise generation of subcategory regular expressions" and "structured merging," ensuring that the final set of regular expressions maintains simplicity while avoiding mismatches caused by over-generalization.

[0119] Furthermore, the method presented in this application enhances the interpretability and maintainability of the system. Traditional methods, when mismatches occur in regular expressions generated directly from broad intent tags, require debuggers to reverse-engineer the problem from massive amounts of mixed data, a highly difficult process. In contrast, the intermediate output of this method (subcategories and their corresponding regular expressions) provides a clear map for locating the problem. If a mismatch occurs, it can quickly pinpoint which subcategory's regular expression rules are too broad or conflicting, significantly improving the sustainable maintainability of the regular expressions. Maintainers can adjust the regular expressions for specific semantic subcategories without disrupting the entire intent matching logic. This allows the system to continuously evolve and maintain high accuracy over the long term.

[0120] In some embodiments, between steps S120 and S130, a process of validating and optimizing the regular expression for each subcategory generated can be added, specifically including:

[0121] The performance metrics of the regular expression for each subcategory are obtained by performing a matching test on the original text subset of the corresponding category and / or other categories.

[0122] Performance metrics can include matching accuracy and false match rate. For example, the regular expression for each subcategory is tested against a subset of the original text in the corresponding category, and the matching accuracy is calculated as (number of successfully matched text / total number of texts in the corresponding category). Furthermore, it can be verified whether the regular expression mismatches text outside the subcategory; that is, the regular expression for each subcategory is tested against subsets of the original text in other categories, and the false match rate is calculated as (number of successfully matched texts in other categories / total number of texts in other categories).

[0123] If the performance metrics of a target subcategory's regular expression do not meet the set performance requirements, then the original text that mismatches the target subcategory's regular expression is filtered out, and the mismatched original text is used to guide the large model to optimize and adjust the target subcategory's regular expression, resulting in the adjusted target subcategory's regular expression.

[0124] Among them, the performance indicators that do not meet the set performance requirements may be: the matching accuracy rate is lower than the first accuracy rate threshold (such as 95% or other values), and / or the false matching rate exceeds the first false matching rate threshold (such as 5% or other values).

[0125] When the performance metrics of the regular expression for the target subcategory do not meet the set performance requirements, the original text that is incorrectly matched by the regular expression for the target subcategory is selected. This can include original text that fails to match on a subset of the original text in the target subcategory, and original text that is mismatched on subsets of the original text in other categories. These incorrectly matched original texts are used to guide the large model to optimize and adjust the regular expression for the target subcategory, thereby improving the quality of the adjusted regular expression for the target subcategory.

[0126] In this embodiment, the process of using the original text with matching errors to guide the large model to optimize and adjust the regular expression of the target sub-category can include:

[0127] Based on the regular expression of the target subcategory and the original text of the mismatch, a fourth prompt is generated. The fourth prompt is sent to the large model to instruct the large model to optimize and adjust the regular expression of the target subcategory by referring to the original text of the mismatch, and the adjusted regular expression of the target subcategory is output by the large model.

[0128] The following is an example of an optional fourth prompt:

[0129] You are a master of regular expression optimization, skilled at extracting high-quality, generalizable regular expressions from real-world language patterns.

[0130] Your task is as follows:

[0131] I will provide a batch of texts that you need:

[0132] 1. Analyze the commonalities in the texts and uncover the categorizable language patterns;

[0133] 2. Optimize and expand my existing regular expression snippets;

[0134] 3. Ensure that the expression can fully match existing cases, while also having a certain degree of generalization ability to adapt to more variations;

[0135] The existing regular expression snippet is as follows:

[0136] <Regular expression fragment>

[0137] Next, I will provide a new batch of text samples.

[0138] Please update and expand the regular expression above based on these texts to make it more generalizable and able to cover the linguistic features contained in the new samples.

[0139] The new text sample is as follows:

[0140] <Text list>.

[0141] For the target subcategory, the regular expression of the target subcategory is filled into the <regular expression fragment> slot in the fourth prompt above. The original text that the regular expression of the target subcategory does not match is filled into the <text list> slot in the fourth prompt above. The edited fourth prompt is obtained and sent to the large model to obtain the adjusted regular expression of the target subcategory output by the large model.

[0142] This step leverages the semantic understanding and text generation capabilities of the large model to match incorrect original text using regular expressions for the target subcategories. This guides the large model to optimize and adjust the regular expressions for the target subcategories, thereby improving the quality of the adjusted regular expressions.

[0143] Optionally, the process of optimizing and adjusting the regular expression of the target sub-category can be iterated once or multiple times. The conditions for ending the iteration include, but are not limited to: the performance index of the adjusted regular expression meets the set performance requirements, and the number of iterations reaches the set number (e.g., a maximum of 3 iterations).

[0144] After the iteration ends and the final regular expression for the target subcategory is obtained, the performance metrics of the regular expression, such as the matching accuracy, can be further saved as the confidence level of the regular expression.

[0145] Further, optionally, after calling the large model to deduplicate the initial set of regular expressions and merge similar regular expressions into more general regular expressions to obtain the set of regular expressions corresponding to each intent tag in the target scenario, the matching accuracy of the regular expression corresponding to each intent tag can also be recorded.

[0146] The matching accuracy rate is obtained by performing matching tests on the corpus data using regular expressions. In some possible implementations, the matching accuracy rate of each regular expression is known before deduplication of the initial set of regular expressions. During the deduplication process, if the regular expression is not modified, its matching accuracy rate can remain unchanged. If two or more regular expressions are merged, the average matching accuracy rate of the merged regular expression can be used as the matching accuracy rate of the merged regular expression.

[0147] In some embodiments of this application, an incremental update mechanism is further provided.

[0148] In step S110, the original text sets belonging to the same intent label are clustered according to semantic similarity to obtain more than one sub-category. Then, the center vector of the sub-category can be calculated based on the original text subset under each sub-category and saved into structured data. The structured data includes the original text subset of the sub-category, the category ID, the intent label, and the center vector of the sub-category.

[0149] The process of calculating the center vector of a subclass may include:

[0150] Each original text entry under a subcategory is encoded to obtain a text vector. The arithmetic mean of all text vectors under a subcategory is calculated and used as the center vector of the subcategory.

[0151] Alternatively, all text vectors under the subcategories can also be saved to the structured data.

[0152] When incremental corpus data is received, the similarity between the vector of the original text in the incremental corpus data and the center vector of each subclass is calculated. Based on the similarity, the subclass to which the original text in the incremental corpus data belongs is determined, and the original text subset under the subclass is added.

[0153] Specifically, the subclass with the highest similarity between the center vector and the vector of the original text in the incremental corpus data is selected, and it is determined whether the highest similarity exceeds the set similarity threshold T.

[0154] If so, it can be determined that the original text in the incremental corpus data belongs to the subcategory with the highest similarity.

[0155] If not, it can be determined that the original text in the incremental corpus belongs to a new category. The largest category ID in the database can be obtained: category_ID. A new category ID is generated, which is category_ID+1. The original text in the incremental corpus is then added to the original text subset of the new category.

[0156] Alternatively, the vectors of the original text in the incremental corpus data can be used as the center vectors of the new categories and stored as structured data (category ID, center vector, intent label).

[0157] When the set update cycle is reached, the regular expression for generating the subcategory is updated based on the latest original text subset under each subcategory, and the set of regular expressions corresponding to each intent tag is also updated.

[0158] Specifically, this application can pre-set an update cycle. When the set update cycle is reached, the original text subsets under each subcategory are scanned. According to the processing method of steps S120-S130 above, the regular expression of the subcategory is updated and generated based on the latest original text subset under each subcategory, and the set of regular expressions corresponding to each intent tag is updated and generated.

[0159] Alternatively, an update log can be recorded, including a comparison of the matching accuracy of the regular expression before and after the update.

[0160] Furthermore, when the set update cycle is reached, the original text subsets of each subcategory can be scanned, and the center vector of each subcategory can be updated and calculated to eliminate numerical errors that may accumulate in online incremental updates and ensure the long-term accuracy of the center vectors of the subcategories.

[0161] In some possible implementations, when the incremental update process determines that the original text in the incremental corpus data belongs to a new category, after the center vector of the new category is stored, step S120 can be triggered immediately to generate the regular expression of the new category and add it to the initial regular expression set of the intent label to which the new category belongs. Step S130 is then triggered to remove duplicates and merge the initial regular expression set of the intent label to which the new category belongs, thus completing the update of the regular expression set of the intent label.

[0162] In this embodiment, when the original text of the incremental corpus data is determined to belong to a new category, the method can realize real-time expansion and update of the regular expression set at the intent tag level without waiting for periodic full updates.

[0163] In some possible implementations, after updating the regular expression for an intent tag, partial corpus data under that intent tag and partial corpus data under other intent tags can be extracted for matching tests. If the matching accuracy within the same intent tag is lower than a first accuracy threshold (e.g., 95%), or the mismatch rate across intent tags is higher than a first mismatch rate threshold (e.g., 5%), a rollback mechanism can be triggered to restore the regular expression to its previous version, ensuring the quality of the regular expression. Furthermore, manual intervention can be notified for further investigation.

[0164] Reference Figure 3 This example demonstrates a process for automating the generation of regular expressions during incremental update procedures.

[0165] Acquire incremental corpus data, including incremental raw text and labeled intent tags.

[0166] The incremental original text is encoded to obtain a text vector, and the similarity is calculated with the center vector of each stored sub-category.

[0167] If the highest similarity exceeds the similarity threshold T, the incremental original text is assigned to the subcategory corresponding to the highest similarity. If the highest similarity does not exceed the similarity threshold T, a new subcategory is created for the incremental original text.

[0168] Recalculate the center vector for each subcategory.

[0169] For each subcategory of original text, the large model is invoked to generate regular expressions for that subcategory. The matching accuracy and mismatch rate of these regular expressions are then tested to ensure they meet performance requirements. If not, the original text with incorrect matches is filtered out, and the large model is guided to optimize and adjust the regular expressions based on this incorrectly matched text. If yes, the regular expressions for each subcategory are saved.

[0170] Optionally, a maximum number of iterations can be set. If the matching accuracy and mismatch rate of the generated regular expressions for the subcategories still cannot meet the performance requirements after reaching the maximum number of iterations, the iteration can be stopped and the latest regular expressions for each subcategory can be saved.

[0171] The regular expressions of all subcategories are summarized according to the intent tag. That is, the initial set of regular expressions corresponding to the intent tag is composed of the regular expressions of each subcategory under the same intent tag.

[0172] The initial set of regular expressions is deduplicated and similar regular expressions are merged to obtain the processed set of regular expressions.

[0173] Determine whether the overall matching accuracy of the processed regular expression set for each intent tag reaches the first accuracy threshold (e.g., 95%) and whether the false match rate does not exceed the first false match rate (e.g., 5%). If so, save the regular expression set at the intent tag level; otherwise, notify manual inspection and adjustment of the regular expressions at the sub-category level.

[0174] The method in this embodiment can continuously acquire incremental corpus data, update the regular expressions at the sub-category level and intent tag level, and continuously improve the quality of the generated regular expressions.

[0175] In some embodiments of this application, an intent recognition method is further provided. (Refer to...) Figure 4 As shown, the intent recognition method may include:

[0176] S1. Obtain the request text for the intent recognition task of the target scene.

[0177] The intent recognition method of this application can be applied to intent recognition tasks in various scenarios, such as intent recognition of user dialogue content in intelligent customer service in the financial industry.

[0178] The request text obtained in this step is the text that needs to be identified by intent. It can be directly entered by the user or obtained by transcribing the user's speech.

[0179] S2. Call the regular expressions in the set of regular expressions corresponding to each intent tag in the target scenario, and perform full matching on the request text one by one.

[0180] The set of regular expressions corresponding to each intent tag in the target scenario is obtained through the regular expression generation method described in the previous embodiment. Each regular expression set corresponding to an intent tag is marked with its matching accuracy (as the confidence level of the regular expression). The matching accuracy is obtained by performing matching tests on the corpus data using the regular expression; detailed calculation procedures can be found in the previous descriptions.

[0181] The result of regular expression matching in S2 has two matching possibilities:

[0182] Case 1: A regular expression exists that matches successfully;

[0183] Case 2: Matching fails, meaning there is no matching regular expression.

[0184] In Case 1, based on the matching accuracy of the successfully matched regular expressions, it can be further divided into three sub-cases, defined as Cases 1.1-1.3:

[0185] Case 1.1: The accuracy of a successfully matched regular expression exceeds the first accuracy threshold P1.

[0186] In this case, the intent tag corresponding to the successfully matched regular expression can be directly used as the final intent recognition result.

[0187] Case 1.2: The matching accuracy of a successful regular expression is between the second accuracy threshold P2 and the first accuracy threshold P1, where P2 is less than P1. For example, P1 is 95% and P2 is 90%.

[0188] In this case, the intent tag corresponding to the successfully matched regular expression can be used as a candidate result for the regular expression. Then, the intent recognition model related to the target scenario is invoked to perform intent recognition on the request text, obtaining the model's candidate results.

[0189] The final intent recognition result is determined based on the regularized candidate results and the model candidate results.

[0190] Specifically, if the regular expression candidate result and the model candidate result are consistent, the consistent intent recognition result can be taken as the final intent recognition result. If the regular expression candidate result and the model candidate result are inconsistent, the credibility of the regular expression candidate result (which can be measured by the matching accuracy of the successfully matched regular expression) and the credibility of the model candidate result (which can be measured by the confidence of the intent recognition model) can be compared to decide the final intent recognition result.

[0191] In some possible implementations, when the regular expression candidate results and the model candidate results are inconsistent, this application can choose to use the model candidate results as the final intent recognition results. Simultaneously, a conflict log can be recorded for manual review. The manual review process can filter out cases of incorrect model recognition, label them, and add them to the model training set. Regular fine-tuning and updates can be performed on the intent recognition model to improve its adaptability to new intents and complex scenarios. Furthermore, cases with incorrect regular expression candidate results can be filtered out to guide the optimization and adjustment of the regular expression.

[0192] Case 1.3: The matching accuracy of a successfully matched regular expression does not exceed the second accuracy threshold P2.

[0193] When scenario 1.3 or scenario 2 occurs, the intent recognition model related to the target scenario can be invoked to perform intent recognition on the request text, and the intent recognition result output by the model can be used as the final intent recognition result.

[0194] This application proposes a hybrid inference strategy that prioritizes regularization and supplements models. While ensuring immediate response in high-confidence scenarios, it utilizes an intent recognition model to enhance intent recognition capabilities in low-confidence and matching failure scenarios.

[0195] Meanwhile, through manual review and sample augmentation, classification errors, mismatches, and new intentions are incorporated into closed-loop training, continuously improving system performance and generalization ability. This enables the system to maintain stable operation in complex real-time environments and provides low-latency, highly reliable intent recognition capabilities.

[0196] This application also provides an electronic device in its embodiments. (See reference...) Figure 5 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, tablets, large-screen teaching displays, wearable devices, etc. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0197] like Figure 5 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 1, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 2 or a program loaded from a storage device 8 into a random access memory (RAM) 3, to implement the regular expression generation method or intent recognition method of the foregoing embodiments of this application. When the electronic device is powered on, the RAM 3 also stores various programs and data required for the operation of the electronic device. The processing unit 1, ROM 2, and RAM 3 are interconnected via a bus 4. An input / output (I / O) interface 5 is also connected to the bus 4.

[0198] Typically, the following devices can be connected to I / O interface 5: input devices 6 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 7 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 8 including, for example, memory cards, hard drives, etc.; and communication devices 9. Communication device 9 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0199] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the regular expression generation methods or intent recognition methods provided in this application.

[0200] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the regular expression generation methods or intent recognition methods provided in this application.

[0201] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0202] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0203] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0204] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

[0205] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

Claims

1. A method for generating regular expressions, characterized in that, include: Acquire corpus data for the intent recognition task of the target scene, wherein the corpus data includes the original text and labeled intent tags; The original text sets belonging to the same intent tag are clustered according to semantic similarity to obtain more than one sub-category; For each subcategory of original text, a large model is invoked to extract common patterns from the subcategory of original text, generating a regular expression for the subcategory. The regular expressions of each subcategory under the same intent tag form the initial set of regular expressions for the intent tag. For each intent tag, an initial set of regular expressions is used to deduplicate the initial set of regular expressions and merge similar regular expressions into more general regular expressions, thereby obtaining a set of regular expressions corresponding to each intent tag in the target scenario.

2. The method according to claim 1, characterized in that, After calling the large model to generate regular expressions for each subcategory, the following is also included: The performance metrics of the regular expression for each subcategory are obtained by performing a matching test on the original text subset of the corresponding category and / or other categories. If the performance metrics of a target subcategory's regular expression do not meet the set performance requirements, then the original texts that mismatch the target subcategory's regular expression are filtered out, and the mismatched original texts are used to guide the large model to optimize and adjust the target subcategory's regular expression, resulting in the adjusted target subcategory's regular expression.

3. The method according to claim 1, characterized in that, Also includes: Calculate the center vector of each subcategory based on the original text subset under each subcategory; Upon receiving incremental corpus data, the similarity between the vector of the original text in the incremental corpus data and the center vector of each sub-category is calculated. Based on the similarity, the sub-category to which the original text in the incremental corpus data belongs is determined, and the original text subset under the sub-category is added. When the set update cycle is reached, the regular expression for each subcategory is updated based on the latest subset of original text under each subcategory, and the set of regular expressions corresponding to each intent tag is updated.

4. The method according to claim 3, characterized in that, After adding the original text from the incremental corpus data to the subset of original text under the corresponding subcategory, the method further includes: Update the center vector of the subcategory to which the original text belongs in the incremental corpus data.

5. The method according to any one of claims 1-4, characterized in that, Also includes: Record the matching accuracy of the regular expression corresponding to each intent tag. The matching accuracy is obtained by performing a matching test on the corpus data using the regular expression.

6. An intent recognition method, characterized in that, include: Obtain the request text for the intent recognition task in the target scene; The regular expressions in the set of regular expressions corresponding to each intent tag in the target scenario are called, and the request text is matched against the entire text one by one. The set of regular expressions corresponding to each intent tag in the target scenario is obtained by the regular expression generation method described in claim 5. If a matching regular expression exists and the matching accuracy of the matching regular expression exceeds a first accuracy threshold, then the intent label corresponding to the matching regular expression is taken as the final intent recognition result.

7. The method according to claim 6, characterized in that, Also includes: If the matching accuracy of the successfully matched regular expression is between the second accuracy threshold and the first accuracy threshold, then the intent tag corresponding to the successfully matched regular expression is taken as a regular expression candidate result, and the second accuracy threshold is less than the first accuracy threshold. The intent recognition model related to the target scene is invoked to perform intent recognition on the request text, and model candidate results are obtained; The final intent recognition result is determined based on the regularization candidate results and the model candidate results.

8. The method according to claim 6 or 7, characterized in that, Also includes: If the matching accuracy of the successfully matched regular expression does not exceed the second accuracy threshold, or if there is no successfully matched regular expression, then the intent recognition model related to the target scene is invoked to perform intent recognition on the request text, and the intent recognition result output by the model is taken as the final intent recognition result, wherein the second accuracy threshold is less than the first accuracy threshold.

9. An electronic device, characterized in that, include: Memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement the steps of the regular expression generation method as described in any one of claims 1 to 5, or to implement the steps of the intent recognition method as described in any one of claims 6 to 8.

10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the regular expression generation method as described in any one of claims 1 to 5, or implements the steps of the intent recognition method as described in any one of claims 6 to 8.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the regular expression generation method as described in any one of claims 1 to 5, or implements the steps of the intent recognition method as described in any one of claims 6 to 8.