A Finite State Machine System Design Method Driven by Natural Language Dynamic Probe
Through the limited state machine system driven by natural language dynamic probes, the problem of intended identification capabilities in existing technologies is limited and the process is unprepared in the existing technology, realizing high reliability and diversity human -computer interaction, meeting the needs of serious scenes Essence
Patent Information
- Application Number
- CN202410706576.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-06-03
AI Technical Summary
The existing natural language processing technology has limited training data quality and quantity in intention recognition, resulting in limited intention recognition ability and generalization ability. At the same time, the intention recognition process of pre-trained language models is uncontrollable and unexplainable, making it difficult to meet the high level of serious scenarios. Reliability requirements.
The design method of a limited state system driven by natural language dynamic probes is used. By obtaining the user interactive instruction status, enter the coding model for encoding, generate vectors, and transfer the state of limited state based on dynamic probes and vectors. The system uses feedback to update the data set training encoding model, continuously optimizes dynamic probes, and improves the diversity of human -computer interaction and the accuracy of intent to recognize.
Avoid the problem of the quality and quantity limit of training data of pre -training language models, to solve the uncontrollable and irreplaceableness of the intent to identify the process, improve the robustness and robustness of the system, and meet the high in the serious scene. Reliability identification needs.
Smart Images

Figure CN118626176B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a finite state machine system design method driven by a natural language dynamic probe. Background Art
[0002] In the early days, natural language processing technology was mainly based on pre-defined rules for grammatical parsing and language understanding. After that, statistical analysis methods were introduced, and models were built based on machine learning technology to learn language rules, resulting in typical methods such as N-gram models, hidden Markov models (HMMs), and conditional random fields (CRFs). Since 2010, deep learning technology has greatly promoted the development of the NLP field. Recurrent neural networks (RNNs), long short-term memory networks (LSTMs), attention mechanisms, and Transformer architectures have promoted a qualitative leap in NLP technology. These models can capture long-distance dependencies and complex patterns in language, greatly improving the performance of tasks such as machine translation, sentiment analysis, text summarization, and question-answering systems. Since 2018, pre-trained language models represented by BERT and GPT have become a research hotspot in the NLP field. These models are pre-trained on large-scale text datasets to learn general language representations, and can be fine-tuned and applied to specific NLP tasks. This method greatly improves the performance of various NLP tasks and greatly simplifies the model development process, allowing downstream tasks of natural language processing to be quickly built and applied engineering.
[0003] Finite State Machine (FSM) is a mathematical model widely used in engineering practice in various fields. It can effectively describe the state in the system and the process of transition between states, and efficiently represent and implement the control of various application systems and the logical order of their associated events. At present, finite state machines have been widely used in many fields such as embedded systems, visible light communications, and various control interaction systems. Among them, the operation of finite state machines can be triggered automatically by the system or by user interaction. Finite state machines triggered by user interaction have spawned dialogue systems such as text and voice, and realized products such as intelligent customer service and chat robots, and have been widely used in the fields of the Internet and e-commerce. The realization of the above scenarios relies on the use of pre-trained language model technology to solve the human-computer interaction problem of finite state machines. The core is to perform intent recognition based on pre-trained language models, but the input of natural language has a certain randomness and arbitrariness. Neither pre-trained models nor pre-defined finite state machines can respond to and solve the uncertainty of user intentions in a timely manner. In addition, the performance of pre-trained language models depends to a large extent on the quality and quantity of training data. If the training data for intent recognition is insufficient or of low quality, the recognition effect of the model will be greatly reduced, and the generalization ability of the model will also be limited. In particular, the model will not be able to accurately identify intents or expressions that have not appeared in the training data. In addition, intent recognition based on pre-trained language models often forcibly classifies the input text into predefined intent types. Since the result of a certain classification must be output, and its internal decision-making process is unexplainable, the uncertainty and risk of intent recognition are increased to a certain extent, resulting in reduced trust, making it difficult to meet the needs of natural language-driven finite state machine systems for high-reliability intent recognition in serious scenarios. In addition, as the state machine system runs longer, the contradiction between the fixed state machine design pattern and the high-freedom natural language trigger conditions will become more and more prominent, reducing the robustness and robustness of the system, and also restricting the user experience of related applications. Summary of the invention
[0004] The purpose of the present invention is to provide a finite state machine system design method driven by a natural language dynamic probe, introduce the dynamic probe of natural language into the finite state machine system, realize the state transfer of the semantic finite state machine system driven by natural language, and improve the dynamic probe through feedback optimization to continuously optimize the interactive capability of the system.
[0005] To achieve the above object, the present invention provides the following solutions:
[0006] A natural language dynamic probe driven finite state machine system design method, comprising:
[0007] Get the command status of user interaction;
[0008] Input the instruction state into the encoding model for encoding to generate a corresponding vector; wherein the encoding model is obtained by training with a feedback update data set, and the overall loss of the encoding model is determined, and the encoding module in the encoding model is used to encode the entire sentence text, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector;
[0009] Initialize the finite state machine, load the state corresponding to the vector based on the initialized finite state machine, obtain the corresponding dynamic probe, and perform state transfer of the finite state machine according to the dynamic probe and the vector.
[0010] Optionally, the encoding model includes:
[0011] A word embedding encoding module, used to encode the natural language text in the instruction state to obtain a high-dimensional vector;
[0012] A low-rank matrix module, used for forward propagating the high-dimensional vector to the encoding module;
[0013] The encoding module is used to encode the whole sentence text of the high-dimensional vector under forward propagation, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector.
[0014] Optionally, the encoding module includes:
[0015] The original encoder is used to provide a mapping table that maps pre-trained word units to high-dimensional vectors;
[0016] The fine-tuning expert adapter layer is used to encode the high-dimensional vector into a word vector according to the mapping table, obtain a new high-dimensional vector, encode the new high-dimensional vector into a whole sentence text, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector.
[0017] Optionally, the method for determining the overall loss of the encoding model is:
[0018]
[0019] Among them, λ cl and λ m are the weights of the word vector similarity, context discrimination, and masked word prediction loss, respectively. cl is the loss of word vector similarity, mean is the average value, L c To determine whether the context is of the same type, L p is the loss for masked word prediction.
[0020] Optionally, obtaining the loss of the word vector similarity includes:
[0021] The feedback update data set is subjected to SMOTE sample equalization and sample encoding fusion, and other state index prompt phrase samples in the feedback update data set are combined with user interaction instructions to obtain sample pairs, and the current state annotation prompt word samples are used as anchor point samples to obtain the L c :
[0022] L cl =mean(ReLU(1-similarity(t pos ,t anc h or )+similarity(t pos ,t neg ))
[0023] Among them, L cl is the loss of word vector similarity, mean is the average value, ReLU is the activation function, similarity is the similarity calculation, t pos is the user interaction instruction, t anc h or is the anchor point sample, t neg Sample phrases are suggested for other state indices.
[0024] Optionally, obtaining the finite state machine includes:
[0025] Select the corresponding business scenario as the storage form of the original finite state machine, determine all instruction states processed by the original finite state machine, and add corresponding stage annotations to all instruction states as preset prompt phrases;
[0026] Determine the conversion rules of all instruction states, and add preset prompt phrases to the conversion rules; wherein the conversion rules include: the conditions for transferring from the current instruction state to the next instruction state;
[0027] A target prefix and an execution action for each instruction state conversion are preset, and the preset target prefix and the execution action for each instruction state conversion are uniformly stored in a configuration file to obtain the finite state machine.
[0028] Optionally, obtaining the corresponding dynamic probe includes:
[0029] Load the state corresponding to the vector based on the initialized finite state machine to obtain a state transition list corresponding to the current stage;
[0030] The corresponding dynamic probe is generated through the state transition list corresponding to the current stage; the dynamic probe includes: a prompt phrase of the corresponding state.
[0031] Optionally, performing state transfer of a finite state machine according to the dynamic probe and the vector includes:
[0032] Similarity is calculated based on the dynamic probe and the vector, a similarity threshold is set, the calculated similarity is compared with the similarity threshold, vectors exceeding the similarity threshold are obtained, and the vector with the largest similarity among the vectors exceeding the similarity threshold is selected as the next state transfer stage of the finite state machine for state transfer.
[0033] Optionally, the method of selecting the vector with the largest similarity among the vectors exceeding the similarity threshold as the next state transfer stage of the finite state machine for state transfer is:
[0034] Next=Argmax(Top_K(Similarity,Threshold,K))
[0035] Among them, Next is the next state transfer stage of the finite state machine, Similarity is the vector similarity; Threshold is the adjustable similarity threshold; K is the maximum number selected, Top_K is the function of selecting the first K elements of the grouped data according to the threshold, and Argmax is the parameter corresponding to the maximum value.
[0036] Optionally, performing a state transfer of a finite state machine according to the dynamic probe and the vector includes:
[0037] The state transition of the finite state machine is scored, a scoring threshold is set, and the instruction state is compared with the scoring threshold. If the instruction state is greater than the scoring threshold, the instruction state and the prompt phrase of the instruction state are added to the feedback update data set, or a single prompt word in the prompt phrase of the instruction state is replaced and added to the feedback update data set. If the instruction state is less than the scoring threshold, the instruction state is stored in the feedback update data set.
[0038] The beneficial effects of the present invention are:
[0039] The present invention establishes a finite state machine system design method driven by a natural language dynamic probe, introduces a natural language dynamic probe to drive a semantic finite state machine to perform state transfer, avoids the problem that the intent recognition capability of the pre-trained language model is limited by the quality and quantity of training data, resulting in limited intent recognition capability and generalization capability, and solves the problem that the state driving process and results are uncontrollable and unexplainable due to the forced classification of intent by deep learning methods. In addition, by introducing a feedback learning method, the natural language dynamic probe can be continuously optimized in the interaction between the user and the state machine system, continuously improving the diversity of human-computer interaction methods and the accuracy of intent recognition, and providing a new and effective method for the design and construction of natural language-driven finite state machines in serious scenarios.
[0040] The present invention solves the problem of reducing the controllability and interpretability of the state transfer process in the intent recognition task due to forced classification of the pre-trained model, and can continuously update and optimize the probe performance during the interaction between the user and the state machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 A flow chart of a finite state machine system design method driven by a natural language dynamic probe according to an embodiment of the present invention;
[0043] Figure 2 This is a schematic diagram of the structure of a finite state machine system encoding model driven by a natural language dynamic probe according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0046] like Figure 1 As shown, this embodiment discloses a finite state machine system design method driven by a natural language dynamic probe, including: obtaining the instruction state of user interaction; inputting the instruction state into the encoding model for encoding to generate a corresponding vector; wherein the encoding model is obtained by training the feedback update data set, and the overall loss of the encoding model is determined, and the entire sentence text is encoded by the encoding module in the encoding model, whether the context is of the same type, and the dynamic masking word is randomly predicted to generate a vector; the finite state machine is initialized, and the state corresponding to the vector is loaded based on the initialized finite state machine, the corresponding dynamic probe is obtained, and the state transfer of the finite state machine is performed according to the dynamic probe and the vector, specifically:
[0047] After building a finite state machine according to the actual business scenario, a word embedding encoding model is initialized. The model uses a pre-trained model as the original encoder, such as BERT, RoBERTa, etc., and fine-tunes the same domain corpus built by the finite state machine system. In the fine-tuning process, new tasks (text encoding, determining whether the context is of the same type, and randomly predicting dynamic masking words) are added, and an adjustable fine-tuning expert adapter layer is introduced to achieve more efficient and practical encoding model training. The fine-tuned model is used as the basis for building the word vector space and applied to the finite state machine system. The prompt words corresponding to different state stages are used as probes. Dynamic probes are generated according to feedback during user use to achieve interaction with users, drive the state transition of the semantic finite state machine, and update the encoding model after the interaction, thereby continuously improving the accuracy of dynamic probes and improving the user's interactive experience. In this process, since the comparison between the probe and the user instruction is deterministic, it can be judged and controlled by the threshold, so that the recognition of user intent will not reduce the credibility of state transition due to forced classification.
[0048] like Figure 2 As shown, the encoding model includes: a word embedding encoding module, which is used to encode the natural language text input by the user, and the technology included is the word-unit division technology for converting the natural language text into word units and the mapping encoding technology for mapping word units into high-dimensional vectors. The output of the encoding model composed of the low-rank matrix is then used as the input of the fine-tuning expert adapter layer for vector encoding again, and all vectors are encoded to obtain word vector encoding, and the feature learning of new tasks such as context judgment and masked word prediction is realized by combining the Decoder block and the linear prediction layer; a low-rank matrix module is used to forward propagate the instruction state to the encoding module; the encoding module is used to encode the entire sentence of the instruction state under forward propagation, judge whether the context is of the same type, and randomly predict dynamic masked words to generate a vector.
[0049] The encoding module includes: the original encoder and the fine-tuning expert adapter layer. The original encoder provides a mapping table for the word embedding encoding model to map pre-trained word units into high-dimensional vectors. The use of this table combined with the low-rank matrix model can reduce the retraining time and achieve better encoding for word unit feature extraction. The fine-tuning expert adapter layer consists of a word embedding encoder, multiple Decoder blocks and a linear layer. The word embedding encoder is used to re-encode the vector to form a new word vector, and use the new word vector in combination with the user interaction instruction state to obtain the requirements of this new scenario. The Decoder block and the linear layer group are used to extract features from the output vector of the word embedding encoding module again, re-encode the vector and combine it with judging whether the context is of the same type and randomly predicting the new task of dynamic masking words to achieve more task-oriented feature learning, specifically:
[0050] Determination of the word embedding encoding model. In the dynamic probe task scenario, a word embedding encoding model is initialized. The word embedding encoding model uses BERT or RoBERTa (encode-only model) as the original encoder H, and adds an additional parameter variable learnable parameter matrix to the original encoder H, and adds a learnable low-rank matrix to the internal linear layer of the original encoder H, which transforms the forward propagation of the linear layer into:
[0051] forward=W0x+ΔW r x
[0052] Among them, forward represents the result of forward propagation; x represents the input vector of the current layer; W0 is the original weight parameter of the current layer, which can be frozen during training; ΔW r is a low-rank matrix of order r.
[0053] Determine the dynamic probe task. To improve the accuracy of the system in understanding the user's interaction intention, add a fine-tuning expert adapter layer P to the original encoder H to form an encoding model M to complete the encoding of the entire sentence text, the judgment of whether the context is similar, and the output of random dynamic masking word prediction. The fine-tuning expert adapter layer P consists of multiple Decoder blocks and linear layers. At this time, the output of the model M can be expressed as follows:
[0054] output=zip(H(x),P(H(x)) emb ,P(P(H(x)) emb ) cla ,P(P(H(x)) emb ) pred )
[0055] Where x={[CLS],w1,…w n ,[SEP]} represents the input sample, which is the context of the unified preprocessing adding [CLS] and [SEP] special words; H(x) represents the output of the input sample after passing through the original encoder H; P(H(x)) emb is the re-encoding result of the original encoder H output by the encoding model M, and does not participate in the calculation of Loss loss, and P(H(x)) cla The encoding model M determines whether the context of the original encoder H output is of the same type and participates in calculating the Loss loss. The corresponding value is L c represents; P(H(x)) pred It is the output of the random dynamic masking word prediction of the original encoder H output by the encoding model M, which participates in the calculation of Loss loss, and the corresponding value is L prepresents, zip(·) is to pack all the results into a group and return the output, P(P(H(x)) emb ) cla The encoding model M determines whether the context of the re-encoded result output by the original encoder H is of the same type, P(P(H(x)) emb ) pred The output of random dynamic masking word prediction for the re-encoding result of the original encoder H output by the encoding model M.
[0056] Therefore, the overall loss in the back propagation of the current encoding model M is defined as follows:
[0057]
[0058] where λ c and λ p They are the loss weight values for context discrimination and masked word prediction, respectively. In each iterative step, both weight values need to be determined by dynamically changing the form of solving the Pareto optimal solution.
[0059] When using the feedback update dataset for training, the feedback update dataset will be subjected to SMOTE sample equalization and sample encoding fusion, and the context used will be a sample t neg Interact with user instructions pos The sample pair is composed of a sample with a current state annotation word as the anchor sample t anc h or . Therefore, during the back propagation, P(H(x)) emb Will be involved in calculating Loss, the formula is as follows:
[0060]
[0061] Among them, similarity(*) represents the similarity calculation formula.
[0062] The other tasks will remain as they are, so the overall loss in back-propagation of the encoding model M at this stage is defined as follows:
[0063]
[0064] where λ cl and λ m They are the weight values of word vector similarity and the mean loss of context discrimination and masked word prediction. In each iterative step, both weight values need to be determined by dynamically changing the form of solving the Pareto optimal solution.
[0065] Training of the encoding model M. The encoding model M is constructed through the above steps. The corpus to be used in the current business scenario and the annotation prompt phrases A and {B} in each state will be used as training data. The created encoding model M will start learning and adapt to the current scenario to obtain the encoding model M′.
[0066] Encoding model-dynamic probe construction. The encoding model M will be embedded in the word vector encoding layer of the dynamic probe, re-encoding the transmitted text information and taking P(H(x)) emb The vector corresponding to the word position in [CLS] is used as the word vector encoding of the entire text The annotations and prompt phrases for each stage state will be pre-encoded to form a buffer vector probe set It can be loaded quickly during the interactive use with the user. The buffer vector of each stage It is composed of the word vector encoding emb of the annotation prompt phrase A and {B} of the corresponding stage after being encoded by the encoding model M, as shown in the following formula:
[0067] in is the word vector encoding emb of the current stage annotation after being encoded by the encoding model M, It is the word vector encoding emb of each prompt word after being encoded by the encoding model M in the current stage.
[0068] Acquiring a finite state machine includes: selecting a corresponding business scenario as the storage form of the original finite state machine, determining all instruction states processed by the original finite state machine, adding corresponding stage annotations to all instruction states as preset prompt phrases; determining the conversion rules of all instruction states, and adding preset prompt phrases to the conversion rules; wherein the conversion rules include: the conditions for transferring from the current instruction state to the next instruction state; presetting the target prefix and execution action for each instruction state conversion, and uniformly storing the preset target prefix and execution action for each instruction state conversion in the configuration file, and acquiring a finite state machine, specifically:
[0069] Construct a finite state machine based on specific business scenarios.
[0070] Define the storage format of the finite state machine, comprehensively consider factors such as the scale, complexity, performance requirements of the system, and the skills and experience of the development team, and choose the storage format that best suits the business scenario, which can ensure flexibility and scalability while providing a more intuitive view;
[0071] Define the state and determine all possible states St = {St0, St1, ... St n}, with clear identifiers or names as labels. These states represent different stages of the system at a specific point in time. And add corresponding stage annotations to these states as preset prompt phrases A = {a1, a2, ...a n}, where a n Represents each token in the state annotation of each stage;
[0072] Define transitions and determine the transition rules between states. These rules describe the conditions for moving from the current state to the next state. Each transition is usually associated with one or more input events or conditions. If the transition rule is triggered by user interaction, you also need to add some preset prompt phrases {B} = {B1, B2, ... B M}, where B M Represents a prompt word consisting of several word units B M ={b1,b2,…b n};
[0073] Define actions. For each state transition, define the actions or behaviors that should be executed. These actions can be output, internal processing, or state updates. By default, the method with the same name as the state and prefixed with "func_" is executed. These methods are stored in the configuration file and are mapped, read, and called by the system.
[0074] Initialization state, determines the initial state of the finite state machine.
[0075] Obtaining the corresponding dynamic probe includes: loading the state corresponding to the vector based on the initialized finite state machine to obtain the corresponding state transition list of the current stage; generating the corresponding dynamic probe through the corresponding state transition list of the current stage; the dynamic probe includes: prompt phrases of the corresponding state.
[0076] The state transfer of the finite state machine according to the dynamic probe and the vector includes: calculating similarity according to the dynamic probe and the vector, setting a similarity threshold, comparing the calculated similarity with the similarity threshold, obtaining vectors exceeding the similarity threshold, and selecting the vector with the largest similarity among the vectors exceeding the similarity threshold as the next state transfer stage of the finite state machine for state transfer, specifically:
[0077] The startup of the semantic finite state machine initializes the finite state machine defined by step S1 and an empty dynamic probe PROBE={}.
[0078] Similarity calculation, when the user interacts with the system to read the command state of the user input, the current input command is encoded using the encoding model M to generate the corresponding vector t = {t0, ...t n}, and load the state transition list corresponding to the current stage List = {Sti ,…St j}, use this list to update and generate the corresponding dynamic probe St i ∈St. Then, the similarity is calculated based on the vector input by the user and all buffered vectors loaded in the dynamic probe according to the following formula:
[0079] Similarity={y0,…y m}=Similarity(t,{PROBE})
[0080] Among them, y m Represents the similarity between each user input vector and all buffered vectors loaded in the dynamic probe; Similarity(t,{PROBE}) represents the set of similarities calculated between vector t and each vector in the dynamic probe PROBE. The calculation formula for a single similarity calculation is preconfigurable, including the following formula:
[0081]
[0082] Among them, t represents the vector encoded by the instruction input by the user, T is the vector encoded by a prompt word in PROBE, n is the total number of dimensions of the encoded vector, and i is each corresponding dimension of the encoded vector.
[0083] After obtaining the similarity in state transition calculation, we take K vectors that exceed the threshold Threshold and take the stage corresponding to the vector with the greatest similarity as the stage that is most likely to be transferred in the current stage:
[0084] Next=Argmax(Top_K(Similarity,Threshold,K))
[0085] Among them, Next is the next state transfer stage of the finite state machine, Similarity is the vector similarity; Threshold is the adjustable similarity threshold; K is the maximum number selected, Top_K is the function that selects the first K elements of the grouped data according to the threshold, and Argmax is the parameter corresponding to the maximum value. When the vector set obtained by Top-K is empty, the output of this interaction is judged to be "None" and the user is alerted.
[0086] State transfer, complete the state transfer update of the finite state machine according to the obtained state, and wait for the next interaction with the user.
[0087] After the state transition of the finite state machine according to the dynamic probe and the vector is performed, the following steps are included: scoring the state transition of the finite state machine, setting a scoring threshold, comparing the instruction state with the scoring threshold, and if the instruction state is greater than the scoring threshold, adding the instruction state and the prompt phrase of the instruction state to the feedback update data set, or replacing a single prompt word in the prompt phrase of the instruction state to add to the feedback update data set; if the instruction state is less than the scoring threshold, storing the instruction state in the feedback update data set, specifically:
[0088] Feedback update system, during the process of interaction between the system and the user, the user can score the accuracy of the interaction. The system will classify the instruction t of the interaction according to the scoring result. After adding the feedback update data set, the referee system X will decide whether to directly add the prompt phrase of the current state or replace a prompt word in the prompt phrase of the current state according to the strategy. The poor effect will be stored in the feedback update data set. The feedback update data set will repeatedly retrain the encoding model. Considering that the negative feedback samples received by the interactive system will be far more than the positive samples, this patent will not only count the unscored interactions as positive samples and add them to the feedback update data set, but also optimize the encoding model by fusion of SMOTE sample balancing and sample encoding.
[0089] The judgment result of the referee system X on a single instruction is determined by the following formula:
[0090]
[0091] Wherein, t represents the vector encoded by the current scored instruction; {PROBE} is the dynamic probe of the prompt phrase of the current stage state; a is the judgment parameter preset by the system. When it is less than 0, it means that the referee system will replace the prompt phrase with the greatest similarity with the current instruction. When it is equal to 0, the instruction will be directly added to the prompt phrase of the current stage state. When it is greater than 0, it means that the referee system will replace the prompt phrase with the least similarity with the current instruction. Instead(·) is a substitution function that replaces the former with the latter. Argmax is the parameter corresponding to the maximum value, Argmin is the parameter corresponding to the minimum value, Similarity is the similarity calculation, and Add(t) is to add the vector encoded by the current scored instruction to the prompt phrase.
[0092] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A finite state machine system design method driven by a natural language dynamic probe, characterized in that: include: Get the command status of user interaction; Input the instruction state into the encoding model for encoding to generate a corresponding vector; wherein the encoding model is obtained by training with a feedback update data set, and the overall loss of the encoding model is determined, and the encoding module in the encoding model is used to encode the entire sentence text, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector; Initialize the finite state machine, load the state corresponding to the vector based on the initialized finite state machine, and obtain the corresponding dynamic probe: The encoding model is embedded into the word vector encoding layer of the dynamic probe, the transmitted text information is re-encoded, and the re-encoding result P(H(x)) of the encoding model outputted by the original encoder is obtained. emb The vector corresponding to the word position in the text is used as the word vector encoding of the entire text, and the annotations and prompt phrases of each stage state are pre-encoded to form a buffer vector probe group The encoding model is used to encode the annotation prompt phrases of the corresponding stage to obtain the word vector encoding, and based on the word vector encoding, the buffer vector probe group of each stage is constructed: in, The word vector encoding of the current stage annotation after being encoded by the encoding model M, The word vector encoding of each prompt word in the current stage after being encoded by the encoding model M; Based on the initialized finite state machine, the state corresponding to the vector is loaded to obtain a state transition list corresponding to the current stage; through the state transition list corresponding to the current stage, a corresponding dynamic probe is generated; the dynamic probe includes: a prompt phrase of the corresponding state; Performing state transfer of a finite state machine according to the dynamic probe and the vector: performing similarity calculation according to the dynamic probe and the vector, setting a similarity threshold, comparing the calculated similarity with the similarity threshold, obtaining vectors exceeding the similarity threshold, and selecting the vector with the largest similarity among the vectors exceeding the similarity threshold as the next state transfer stage of the finite state machine for state transfer: Next=Argmax(Top-K(Similarity, Threshold, K)) Among them, Next is the next state transfer stage of the finite state machine, Similarity is the vector similarity; Threshold is the adjustable similarity threshold; K is the maximum number selected, Top-K is a function that selects the first K elements of the grouped data according to the threshold, and Argmax is the parameter corresponding to the maximum value.
2. The finite state machine system design method driven by a natural language dynamic probe according to claim 1, characterized in that: The coding model includes: A word embedding encoding module, used to encode the natural language text in the instruction state to obtain a high-dimensional vector; A low-rank matrix module, used for forward propagating the high-dimensional vector to the encoding module; The encoding module is used to encode the whole sentence text of the high-dimensional vector under forward propagation, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector.
3. The finite state machine system design method driven by a natural language dynamic probe according to claim 2, characterized in that: The encoding module comprises: The original encoder is used to provide a mapping table that maps pre-trained word units to high-dimensional vectors; The fine-tuning expert adapter layer is used to encode the high-dimensional vector into a word vector according to the mapping table, obtain a new high-dimensional vector, encode the new high-dimensional vector into a whole sentence text, determine whether the context is of the same type, and randomly predict dynamic masking words to generate the vector.
4. The method for designing a finite state machine system driven by a natural language dynamic probe according to claim 1, characterized in that: The method for determining the overall loss of the encoding model is: Among them, λ cl and λ m are the weights of the word vector similarity, context discrimination, and masked word prediction losses, respectively. cl is the loss of word vector similarity, mean is the average value, L c To determine whether the context is of the same type, L p is the loss for masked word prediction.
5. The method for designing a finite state machine system driven by a natural language dynamic probe according to claim 4, characterized in that: The loss of obtaining the similarity of the word vector includes: The feedback update data set is subjected to SMOTE sample equalization and sample encoding fusion, and other state index prompt phrase samples in the feedback update data set are combined with user interaction instructions to obtain sample pairs, and the current state annotation prompt word samples are used as anchor point samples to obtain the L c : L cl =mean(ReLU(1-similarity(t pos , t anchor )+similarity(t pos , t neg )) Among them, L cl is the loss of word vector similarity, mean is the average value, ReLU is the activation function, similarity is the similarity calculation, t pos is the user interaction instruction, t anchor is the anchor point sample, t neg Sample phrases are suggested for other state indices.
6. The method for designing a finite state machine system driven by a natural language dynamic probe according to claim 1, characterized in that: Acquiring the finite state machine includes: Select the corresponding business scenario as the storage form of the original finite state machine, determine all instruction states processed by the original finite state machine, and add corresponding stage annotations to all instruction states as preset prompt phrases; Determine the conversion rules of all instruction states, and add preset prompt phrases to the conversion rules; wherein the conversion rules include: the conditions for transferring from the current instruction state to the next instruction state; A target prefix and an execution action for each instruction state conversion are preset, and the preset target prefix and the execution action for each instruction state conversion are uniformly stored in a configuration file to obtain the finite state machine.
7. The method for designing a finite state machine system driven by a natural language dynamic probe according to claim 1, characterized in that: After the state transfer of the finite state machine according to the dynamic probe and the vector, the following steps are included: The state transition of the finite state machine is scored, a scoring threshold is set, and the instruction state is compared with the scoring threshold. If the instruction state is greater than the scoring threshold, the instruction state and the prompt phrase of the instruction state are added to the feedback update data set, or a single prompt word in the prompt phrase of the instruction state is replaced and added to the feedback update data set. If the instruction state is less than the scoring threshold, the instruction state is stored in the feedback update data set.
Citation Information
Patent Citations
Multi-round dialogue intelligent voice interaction system and device
CN110209791A
Student model training method based on pre-training language model and text classification system
CN115526332A