Intention recognition response method and system based on forest farmer question and answer data
By semantic normalization and feature extraction of forestry farmers' question-and-answer data, combined with dynamic intent mapping processing, target intent recognition results were generated. This solved the problem that existing systems could not accurately understand the intent of forestry farmers, achieving more accurate and personalized responses and improving user satisfaction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-15
- Publication Date
- 2026-03-27
AI Technical Summary
Existing intelligent question-and-answer systems for forestry farmers are unable to accurately understand the true intentions of users when processing their questions, and lack precise grasp and dynamic adjustment of these intentions, resulting in poor accuracy and relevance of responses, and failing to meet the actual needs of forestry farmers.
By acquiring initial question-and-answer data from forestry and agriculture users, semantic normalization is performed to generate structured data. Semantic association features and interaction temporal features are extracted, dynamic intent mapping is performed, target intent recognition results are generated, and optimized response data is generated by matching the response knowledge base based on the intent recognition results.
This improves the accuracy and reliability of intent recognition, ensuring that forestry and agricultural users receive accurate responses that closely match their questioning intent, thereby enhancing user satisfaction and experience.
Smart Images

Figure CN121542442B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, in particular to an intent recognition response method and system based on forest and agricultural question and answer data. BACKGROUND
[0002] In the field of forestry and agriculture, forest and agricultural workers will encounter various problems in the process of production and operation. In order to meet the needs of forest and agricultural workers to obtain information and solve problems, intelligent question and answer systems have emerged. The traditional forest and agricultural intelligent question and answer system often uses a simple keyword matching method to identify user intent and generate responses when processing forest and agricultural user questions. This method has great limitations. Since forest and agricultural workers' question statements are diverse and highly colloquial, relying solely on keyword matching cannot accurately understand the user's true intent, and often results in answering the wrong question.
[0003] Some improved systems have introduced some semantic analysis techniques, but only perform isolated semantic analysis on individual question statements, ignoring the contextual association between question and answer interaction records. In actual question and answer scenarios, forest and agricultural workers' questions often have certain coherence and contextual dependence. For example, in a continuous question and answer about tree disease and pest control, the follow-up question may be further in-depth inquiry based on the existing information. However, existing systems cannot capture this association, resulting in inaccurate intent recognition.
[0004] In addition, existing systems usually only randomly select some seemingly relevant content from a pre-set knowledge base to reply, lacking precise grasp and dynamic adjustment of user intent. Moreover, the system cannot accurately determine the reliability of the intent classification it provides, making it difficult to adopt different processing strategies according to different reliabilities, resulting in poor accuracy and relevance of the reply, and failing to meet the actual needs of forest and agricultural users. SUMMARY
[0005] In view of the above-mentioned problems, in combination with the first aspect of the present application, the embodiments of the present application provide an intent recognition response method based on forest and agricultural question and answer data, which comprises:
[0006] Obtaining an initial question and answer data set of forest and agricultural users, the initial question and answer data set comprising a plurality of question and answer interaction records, each question and answer interaction record consisting of at least one user question statement and a corresponding system initial response statement;
[0007] Performing semantic normalization processing on the initial question and answer data set to generate a structured question and answer data set, each question and answer interaction record in the structured question and answer data set containing a standardized user question statement and a standardized system response statement;
[0008] extract semantic correlation features and interaction time sequence features from the structured question and answer data set, the semantic correlation features are used to represent the semantic matching degree between the user question sentence and the system response sentence, and the interaction time sequence features are used to represent the context dependence relationship between adjacent question and answer interaction records;
[0009] Based on the semantic correlation features and the interaction time sequence features, a dynamic intention mapping process is performed to generate a target intention recognition result, the target intention recognition result includes an intention classification label of a user question sentence and a corresponding intention confidence score;
[0010] According to the target intention recognition result, a preset response knowledge base is matched to generate optimized response data, and the optimized response data is sent to a forest farmer user terminal to trigger a response updating operation.
[0011] In a possible implementation of the first aspect, the semantic normalization processing of the initial question and answer data set to generate a structured question and answer data set comprises:
[0012] The user question sentence in the initial question and answer data set is subjected to text cleaning processing to remove non-text symbols, repeated characters and irrelevant stop words in the user question sentence, and a purified user question sentence is generated;
[0013] The purified user question sentence is subjected to word segmentation processing to obtain a user question word unit set, and the user question word unit set is subjected to part-of-speech tagging and term replacement processing according to a preset forest farmer field word library, and a standardized user question sentence is generated;
[0014] The system initial response sentence in the initial question and answer data set is subjected to response integrity verification processing, if it is detected that the system initial response sentence contains missing fields or incorrect logical correlations, a response completion strategy based on a forest farmer field knowledge graph is called, relevant entity attributes or associated solutions are retrieved from the knowledge graph according to the context semantics of the missing fields, and supplementary response content is generated;
[0015] The supplementary response content and the original system initial response sentence are spliced to generate a standardized system response sentence;
[0016] The standardized user question sentence and the corresponding standardized system response sentence are associated and stored to generate the structured question and answer data set.
[0017] In a possible implementation of the first aspect, the semantic correlation features and the interaction time sequence features are extracted from the structured question and answer data set, comprising:
[0018] calling a pre-trained semantic encoding model to perform vector conversion processing on the standardized user query sentence to generate a user query semantic vector, and performing vector conversion processing on the standardized system response sentence to generate a system response semantic vector;
[0019] calculating semantic similarity between the user query semantic vector and the system response semantic vector to obtain the semantic correlation feature, a value of the semantic correlation feature being positively correlated with the semantic similarity;
[0020] traversing the question and answer interaction records in the structured question and answer data set, grouping the question and answer interaction records according to the session identifier, extracting a time interval between two adjacent question and answer interaction records in a time sequence in the same session group, and performing logarithmic scaling and normalization processing on the time interval to generate a standardized time interval;
[0021] in the same session group, calculating a topic continuity index by comparing the theme keyword coincidence degree and the entity correlation between the user query sentence of the previous question and answer interaction record and the standardized user query sentence of the subsequent question and answer interaction record;
[0022] constructing a time series feature vector based on the standardized time interval and the topic continuity index, and taking the time series feature vector as the interaction time sequence feature.
[0023] In a possible implementation of the first aspect, the dynamic intent mapping processing based on the semantic correlation feature and the interaction time sequence feature to generate a target intent recognition result includes:
[0024] constructing a dynamic intent mapping network, the dynamic intent mapping network including a feature fusion layer, an attention calculation layer, and an intent classification layer;
[0025] inputting the semantic correlation feature and the interaction time sequence feature into the feature fusion layer to perform feature normalization splicing and dimension reduction processing, and generating a fusion feature vector;
[0026] calling the attention calculation layer to perform weight allocation processing on the fusion feature vector, determining a contribution weight of the semantic correlation feature and the interaction time sequence feature to intent classification, and performing weighted correction on the fusion feature vector according to the contribution weight to generate an attention corrected feature;
[0027] inputting the attention corrected feature into the intent classification layer to perform full connection calculation and normalization processing, and generating an intent classification label of the user query sentence and a corresponding intent confidence score, the intent confidence score being used to quantify a reliability degree of the intent classification label.
[0028] In a possible implementation of the first aspect, the generating an optimized response data according to the target intent recognition result matching a preset response knowledge base comprises:
[0029] filtering a candidate response template set matching the intent classification label from the response knowledge base, each candidate response template being associated with a preset applicable scenario condition and a priority score;
[0030] performing filtering processing on the candidate response template set according to the intent confidence score and the applicable scenario condition, and retaining a candidate response template satisfying a scenario matching threshold and having a priority score higher than a preset threshold;
[0031] performing content adaptability adjustment processing on the retained candidate response template, replacing a key entity word in the standardized user question sentence into a placeholder in the candidate response template to generate a preliminary optimized response result;
[0032] performing logical coherence verification processing on the preliminary optimized response result, and if detecting that the response content has a contradiction or information missing, invoking a preset response iteration strategy to supplement missing information and correct logical errors to generate a final optimized response data.
[0033] In a possible implementation of the first aspect, the invoking a preset response iteration strategy to supplement missing information and correct logical errors to generate a final optimized response data comprises:
[0034] extracting a core information field in the preliminary optimized response result, and comparing the core information field with a key entity word in the user question sentence to determine a missing information field and a contradictory information field;
[0035] retrieving a supplementary knowledge item associated with the missing information field from the response knowledge base, and inserting the supplementary knowledge item into a specified position of the preliminary optimized response;
[0036] performing logical conflict detection processing on the contradictory information field based on a knowledge graph, determining whether the contradictory information field violates a domain common sense or has a logical inconsistency by traversing an entity attribute and a relationship constraint in a pre-constructed forestry domain knowledge graph, and if detecting a conflict, retrieving a replacement field matching the intent classification label and the key entity word from the response knowledge base, and reconstructing content of the preliminary optimized response based on a rule engine, so that the updated response content satisfies the domain knowledge and the logical consistency;
[0037] performing syntax verification and semantic integrity evaluation on the updated response content, and if an evaluation result does not reach a preset quality standard, repeatedly performing the supplementing and correcting operations until a final optimized response data meeting a quality requirement is generated.
[0038] In a possible implementation of the first aspect, the calling of the pre-trained semantic encoding model to perform vector conversion processing on the standardized user query sentence to generate a user query semantic vector includes:
[0039] performing word vector conversion processing on the standardized user query sentence to obtain an initial word vector sequence;
[0040] calling a bidirectional long short-term memory network in the semantic encoding model to perform context encoding processing on the initial word vector sequence to generate a context-aware word vector;
[0041] performing maximum pooling processing on the context-aware word vector to extract a global semantic feature, and inputting the global semantic feature into a fully connected layer for dimension reduction to generate the user query semantic vector.
[0042] In a possible implementation of the first aspect, the performing maximum pooling processing on the context-aware word vector to extract a global semantic feature includes:
[0043] segmenting the context-aware word vector by time steps to obtain a plurality of context feature slices;
[0044] performing maximum value sampling on each context feature slice to obtain a set of local maximum feature values;
[0045] performing weighted fusion on the set of local maximum feature values to generate the global semantic feature, wherein a weight coefficient is dynamically adjusted according to a semantic density of the context feature slice.
[0046] In a possible implementation of the first aspect, the screening of a set of candidate response templates matching the intent classification label from the response knowledge base includes:
[0047] constructing an inverted index structure of the response knowledge base, the inverted index structure recording an intent label and a set of keywords associated with each candidate response template;
[0048] retrieving a set of primary candidate templates from the inverted index structure according to the intent classification label;
[0049] calculating a coincidence degree score between a key entity word in the user query sentence and a set of keywords of each candidate response template in the set of primary candidate templates;
[0050] sorting the set of primary candidate templates according to the coincidence degree score, and selecting candidate response templates with a ranking higher than a preset threshold to form the set of candidate response templates;
[0051] The computing the coincidence degree score between the key entity word in the user question sentence and the key word set of each candidate response template in the primary candidate template set comprises:
[0052] Extracting the named entity word and the domain term word in the user question sentence to form a key entity word set;
[0053] Traversing each candidate response template in the primary candidate template set to extract its associated key word set;
[0054] Computing the Jaccard similarity between the key entity word set and each key word set to obtain a basic coincidence degree score;
[0055] Based on the frequency of the key word set in the response knowledge base, the basic coincidence degree score is weighted and corrected to generate a final coincidence degree score, wherein the weight coefficient of a high-frequency key word is lower than that of a low-frequency key word.
[0056] For example, in a possible implementation of the first aspect, the training method of the dynamic intent mapping network comprises:
[0057] Obtaining a structured question and answer data set in the forestry field as a training sample set, each sample in the training sample set comprising a standardized user question sentence, a corresponding standardized system response sentence and an artificially labeled intent classification label;
[0058] Building an initial model architecture of the dynamic intent mapping network, the initial model architecture comprising sequentially connected feature fusion layers, multi-head self-attention layers, gated recurrent unit layers and intent classification layers, wherein the input dimension of the feature fusion layer is consistent with the concatenation dimension of semantic association features and interaction timing features, and the gated recurrent unit layer contains hidden units and the time step matches the maximum round of the dialogue interaction;
[0059] Feature pre-processing is performed on the training sample set to extract the semantic association features and the interaction timing features of each sample, and the semantic association features and the interaction timing features are arranged in the order of sample timestamps to form a feature sequence;
[0060] The feature sequence is input into the initial model architecture for forward propagation calculation, wherein the feature fusion layer adopts batch normalization operation to scale the concatenated features, the multi-head self-attention layer calculates the global dependence weight of the feature sequence through multiple parallel attention heads, and the gated recurrent unit layer iteratively updates the hidden state according to the time step to capture the long-distance context mode;
[0061] calculating a cross-entropy loss value between a predicted intent classification result of the forward propagation output and a manually labeled intent classification label, and updating trainable parameters of the initial model architecture using an adaptive optimizer;
[0062] monitoring a decreasing trend of the cross-entropy loss value on the validation set, and triggering an early stopping mechanism to freeze model parameters when a fluctuation amplitude of loss values of consecutive multiple training rounds is lower than a preset threshold, to generate a trained dynamic intent mapping network, wherein the dynamic intent mapping network after the parameters are frozen is deployed to an online inference environment to receive a question and answer interaction data stream from a forest farmer user terminal in real time and output a target intent recognition result, and wherein hidden states of the gated recurrent unit layers in the inference process are stored in isolation based on a session identifier to maintain dialog context independence.
[0063] For example, in a possible implementation of the first aspect, the training method of the semantic encoding model comprises:
[0064] collecting an unannotated text corpus in the forest farming field, the unannotated text corpus including forestry technical manuals, pest control reports, and historical question and answer records, and performing word segmentation processing and stop word filtering on the unannotated text corpus to generate a set of purified word sequences;
[0065] pre-training a word vector matrix based on a word embedding algorithm on the set of purified word sequences, wherein a word vector dimension is set to a predefined value and a context window size is adapted to an average length of domain-specific terms, to generate an initial word vector including forest farming field-specific terms;
[0066] constructing a double-tower neural network structure of the semantic encoding model, the double-tower neural network including parallel user question encoding towers and system response encoding towers, each encoding tower being sequentially connected by a bidirectional long short-term memory network layer, a locally sensitive hashing attention layer, and a deformable convolution layer, wherein the deformable convolution layer dynamically adjusts a convolution kernel shape to adapt to variable context modes of forest farming field-specific terms, and the locally sensitive hashing attention layer uses Hamming distance-based similarity calculation to filter key semantic units;
[0067] sampling positive sample pairs and negative sample pairs from the structured question and answer data set, wherein a positive sample pair is a standardized user question statement and a corresponding system response statement combined with a semantic correlation feature higher than a preset threshold, and a negative sample pair is generated by randomly replacing a system response statement;
[0068] The user question sentence and the system response sentence in the positive and negative sample pair are input into the corresponding encoding tower for vectorization processing, wherein the bidirectional long short-term memory network layer takes the pre-trained initialization word vector as the input, and outputs the timing perception feature, the local sensitive hash attention layer filters the key semantic unit by calculating the word-level similarity, and the deformable convolution layer extracts the local context mode by using the deformable convolution kernel;
[0069] The semantic similarity of the user question vector and the system response vector in the positive sample pair is calculated, and the similarity difference of the negative sample pair is calculated, and the encoding tower parameters are optimized based on the interval loss function with a predefined interval threshold, so that the positive sample similarity is higher than the negative sample by at least the interval threshold;
[0070] The gradient clipping strategy is used to limit the gradient norm in the back propagation process, and the momentum optimizer is used to update the model parameters, and the nearest neighbor retrieval accuracy is evaluated on the validation set after each round of training;
[0071] When the average retrieval accuracy on the validation set remains above the preset threshold for multiple rounds, the training process is terminated and the parameter weight of the user question encoding tower is exported, and the parameter weight is deployed to the online semantic matching service to convert the forest farmer user question into a standardized semantic vector in real time to support intent recognition.
[0072] In still another aspect, the embodiments of the present application also provide an intent recognition response system based on forest farmer question and answer data, comprising a processor, a machine readable storage medium, the machine readable storage medium and the processor are connected, the machine readable storage medium is used to store programs, instructions or codes, and the processor is used to execute the programs, instructions or codes in the machine readable storage medium to realize the above-mentioned method.
[0073] Based on the above aspects, the embodiments of the present application convert the initial messy question and answer data into structured data by using semantic standardization processing, avoiding recognition errors caused by inconsistent data formats and ambiguous semantics. By extracting semantic correlation features and interactive timing features, the semantic matching information and context dependency in the question and answer data are fully mined, which can more comprehensively and deeply understand the question intention of the forest farmer user. Compared with the traditional method which only considers single dimension information, the accuracy and reliability of intent recognition are greatly improved. Dynamic intent mapping processing generates target intent recognition results combined with the above features, not only gives the intent classification label, but also provides the corresponding confidence score, so as to match the pre-set response knowledge base to generate optimized response data and send it to the forest farmer user terminal, ensuring that the forest farmer user can obtain accurate response highly consistent with their own question intention, effectively improving the satisfaction and experience of the forest farmer user in the question and answer interaction. BRIEF DESCRIPTION OF DRAWINGS
[0074] Figure 1is a flowchart of an embodiment of the method for identifying and responding to an intent based on forest farmer Q&A data.
[0075] Figure 2 is a schematic diagram of exemplary hardware and software components of an embodiment of the system for identifying and responding to an intent based on forest farmer Q&A data. DETAILED DESCRIPTION
[0076] The present application will be described in detail below with reference to the accompanying drawings, Figure 1 is a flowchart of an embodiment of the method for identifying and responding to an intent based on forest farmer Q&A data, which will be described in detail below.
[0077] Step S110: Obtain an initial Q&A data set of forest farmer users, which includes a plurality of Q&A interaction records, each of which is composed of at least one user query sentence and a corresponding system initial response sentence.
[0078] In this embodiment, the initial Q&A data set of forest farmer users can be obtained in various ways, for example, from forest farmer professional online consultation platforms, forest farmer related social media group discussion records, text transcription content of telephone consultations between forest farmers and experts, etc. After these data are collected and aggregated, an initial Q&A data set containing a plurality of Q&A interaction records is formed.
[0079] Each Q&A interaction record is composed of at least one query sentence raised by a forest farmer user and a corresponding initial response sentence given by the system. Assuming that the user query sentence is represented by A and the system initial response sentence is represented by B. For example, in an online consultation scenario for forest farmers, the user query sentence A can be "Under the current seasonal climate conditions, what comprehensive prevention and control measures and subsequent maintenance and management methods should be taken for different pine species planted at different altitudes in mountainous areas, which exhibit symptoms of yellowing leaves accompanied by white powdery substances, slight cracks in the trunk, and transparent gum-like liquid oozing out?" The corresponding system initial response sentence B can be "For different pine species at different altitudes, first, the symptoms need to be diagnosed in detail to determine whether they are caused by a disease, insect, or environmental factor. For yellowing leaves and white powdery substances, it can be a fungal disease such as white powdery mildew, and antifungal agents can be considered for spraying prevention and control. For the cracks in the trunk and the oozing of gum-like liquid, it can be physical damage to the trunk or infection with gum flow disease, which requires cleaning and disinfection of the wound and application of appropriate healing agents. For subsequent maintenance and management, the watering and fertilization plan should be adjusted according to the climate conditions at different altitudes to ensure the nutrition supply and water balance of the trees." A plurality of such Q&A interaction records are combined to form the initial Q&A data set.
[0080] Step S120: performing semantic normalization processing on the initial question and answer data set to generate a structured question and answer data set, each question and answer interaction record in the structured question and answer data set containing a standardized user question sentence and a standardized system response sentence.
[0081] In this embodiment, after obtaining the initial question and answer data set, since the user question sentences and the system initial response sentences therein can have problems such as inconsistent formats and non-standard semantics, it is necessary to perform semantic normalization processing thereon to generate a structured question and answer data set, so that the question and answer data can be more regular, facilitating subsequent analysis and processing.
[0082] Step S121: performing text cleaning processing on the user question sentences in the initial question and answer data set to remove non-text symbols, repeated characters and irrelevant stop words in the user question sentences, and generating purified user question sentences.
[0083] In the semantic normalization processing, the user question sentences in the initial question and answer data set are first subjected to text cleaning. The user question sentences can contain various non-text symbols such as punctuation marks, special characters, etc., and can also have repeated characters and irrelevant stop words, which will affect the subsequent semantic analysis. For example, for the user question sentence A in the above example, it can contain unnecessary exclamation marks, parentheses and other non-text symbols, and also have stop words such as "de", "ah" and the like. After text cleaning operation, the non-text symbols, repeated characters and irrelevant stop words are removed, and the purified user question sentence A' is generated. The specific cleaning process can be realized by writing corresponding program code, for example, using regular expression to match non-text symbols and repeated characters, and using a stop word list to remove irrelevant stop words.
[0084] Step S122: performing word segmentation processing on the purified user question sentences to obtain a user question word unit set, and performing part-of-speech tagging and term replacement processing on the user question word unit set according to a pre-set forestry field lexicon to generate a standardized user question sentence.
[0085] Next, the purified user question sentence A' is subjected to word segmentation processing. Word segmentation is a process of dividing a sentence into independent word units, and the word units obtained constitute a user question word unit set. For example, for the purified user question sentence A', after word segmentation processing, the word units "current season", "mountainous area", "different altitudes", "planting", "multiple pine species", "yellowing of tree leaves", "adhesion of white powdery substance", "tree trunk", "slight cracks", "exudation of transparent gelatinous liquid", "overall prevention and control measures", "follow-up maintenance and management methods" and the like can be obtained.
[0086] Then, according to the preset forest and farming field vocabulary, the user question word unit set is processed by part-of-speech tagging and term replacement. The forest and farming field vocabulary contains professional terms and vocabulary in the forest and farming field. By comparing the vocabulary in the user question word unit set with the vocabulary, the part-of-speech of each word unit can be tagged, and some colloquial or inaccurate expressions can be replaced by standard forest and farming field terms. For example, "tree leaves are yellow" is replaced by "leaf yellowing", and "white powder-like substance is attached" is replaced by "white powder is attached". After such processing, the standardized user question sentence A'' is generated.
[0087] Step S123: The system initial response sentence in the initial question and answer data set is subjected to response integrity checking processing. If it is detected that the system initial response sentence contains missing fields or incorrect logical associations, a response completion strategy based on the forest and farming field knowledge graph is called, relevant entity attributes or associated solutions are retrieved from the knowledge graph according to the context semantics of the missing fields, and supplementary response content is generated.
[0088] After processing the user question sentence, the system initial response sentence in the initial question and answer data set needs to be subjected to response integrity checking. The system initial response sentence may have missing fields or incorrect logical associations. For example, for the system initial response sentence B in the above example, when it is mentioned that the antifungal agent is used for spraying prevention, the specific type and use concentration of the agent are not specified, which belongs to missing fields. Or when describing the treatment method of the sap flow gum disease, there may be a logical inconsistency.
[0089] When it is detected that the system initial response sentence contains missing fields or incorrect logical associations, a response completion strategy based on the forest and farming field knowledge graph is called. The forest and farming field knowledge graph is a knowledge base containing various entities and their relationships in the forest and farming field. By analyzing the context semantics of the missing fields, relevant entity attributes or associated solutions are retrieved from the knowledge graph. For example, if the specific type and use concentration of the antifungal agent are missing, the types of agents related to the prevention of pine white rust and the corresponding use concentration range can be found in the forest and farming field knowledge graph, so as to generate supplementary response content C.
[0090] Step S124: The supplementary response content is spliced with the original system initial response sentence to generate a standardized system response sentence.
[0091] After obtaining the supplementary response content C, it is spliced with the original system initial response sentence B. The splicing method can be directly inserting the supplementary response content into the corresponding position of the original system initial response sentence, or adding it to the end of the sentence. For example, if the supplementary response content C is information about the specific type and use concentration of antifungal agents, it is inserted after the position mentioned in the system initial response sentence B that uses antifungal agents, to generate the standardized system response sentence B'.
[0092] Step S125: The standardized user question sentence and the corresponding standardized system response sentence are stored in association, and the structured question and answer data set is generated.
[0093] Finally, the standardized user question sentence A'' and the corresponding standardized system response sentence B' are stored in association. The association storage method can be storing them in a database table, and each row record represents a question and answer interaction record, which contains two fields of standardized user question sentence and standardized system response sentence. In this way, a structured question and answer data set is generated, and each question and answer interaction record in the structured question and answer data set contains standardized user question sentence and system response sentence, which is convenient for subsequent feature extraction and analysis.
[0094] Step S130: Extracting semantic association features and interaction timing features from the structured question and answer data set, the semantic association features are used to represent the semantic matching degree between the user question sentence and the system response sentence, and the interaction timing features are used to represent the context dependence relationship between adjacent question and answer interaction records.
[0095] In this embodiment, after obtaining the structured question and answer data set, in order to better understand the relationship between the question and answer and the context information of the question and answer record, it is necessary to extract semantic association features and interaction timing features from the structured question and answer data set.
[0096] Step S131: Calling a pre-trained semantic encoding model to perform vector conversion processing on the standardized user question sentence to generate a user question semantic vector, and performing vector conversion processing on the standardized system response sentence to generate a system response semantic vector.
[0097] Firstly, a pre-trained semantic encoding model is called to perform vector conversion processing on the standardized user question sentence A'' and the standardized system response sentence B'. The semantic encoding model is a model trained by a large amount of text data, which can convert text into vector representation for computer processing and analysis.
[0098] For the standardized user question sentence A'', it is input into the semantic encoding model, which will perform a series of processing on it, and finally output the user question semantic vector V_A. The specific processing process may include word vector conversion for each word in the standardized user question sentence, and then combining and transforming the word vectors through the neural network layer of the model to obtain a vector that can represent the semantic of the whole sentence.
[0099] Similarly, the standardized system response sentence B' is input into the semantic encoding model to obtain the system response semantic vector V_B. In this way, the standardized user question sentence and the standardized system response sentence in text form are converted into vector form, which is convenient for subsequent similarity calculation.
[0100] Step S1311: performing word vector conversion processing on the standardized user question sentence to obtain an initial word vector sequence.
[0101] When calling the semantic encoding model to convert the standardized user question sentence A'' into a vector, first, word vector conversion processing is performed on it. This step is to convert each word in the standardized user question sentence A'' into a corresponding word vector. For example, for each word unit in the standardized user question sentence A'', such as "current season" and "mountainous area", it is converted into a corresponding word vector through a pre-trained word vector model. These word vectors are arranged in order to form an initial word vector sequence.
[0102] Step S1312: calling the bidirectional long short-term memory network in the semantic encoding model to perform context encoding processing on the initial word vector sequence to generate context-aware word vectors.
[0103] Next, the bidirectional long short-term memory network (BiLSTM) in the semantic encoding model is called to perform context encoding processing on the initial word vector sequence. The bidirectional long short-term memory network is a neural network model that can process sequence data, which can consider the forward and backward information of the sequence at the same time, so as to better capture the context information in the sentence.
[0104] The initial word vector sequence is input into the bidirectional long short-term memory network, which will process each word vector in combination with the information of the word vectors before and after it to generate context-aware word vectors. These context-aware word vectors not only contain the semantic information of each word itself, but also contain the context information of the word in the sentence.
[0105] Step S1313: performing maximum pooling processing on the context-aware word vectors to extract global semantic features, and inputting the global semantic features into a fully connected layer for dimension reduction to generate the user question semantic vector.
[0106] Then, the context-aware word vector is subjected to maximum pooling processing. Maximum pooling processing is a feature extraction method that selects the maximum value in each dimension to extract global semantic features. Specifically, the context-aware word vector is divided by time step to obtain multiple context feature slices, and the maximum value of each context feature slice is sampled to obtain a set of local maximum feature values. Then, the set of local maximum feature values is weighted and fused to generate a global semantic feature. The weight coefficient is dynamically adjusted according to the semantic density of the context feature slice.
[0107] Finally, the global semantic feature is input into a fully connected layer for dimension reduction processing. The fully connected layer is a neural network layer that can map high-dimensional global semantic features to a low-dimensional space to generate a user question semantic vector V_A.
[0108] Step S132: Calculate the semantic similarity between the user question semantic vector and the system response semantic vector to obtain the semantic association feature, the value of which is positively correlated with the semantic similarity.
[0109] After obtaining the user question semantic vector V_A and the system response semantic vector V_B, the semantic similarity between them is calculated. For example, cosine similarity is a commonly used method to measure the similarity between two vectors, which represents the similarity between two vectors by calculating the cosine of the included angle between them.
[0110] In specific calculation, the dot product of the user question semantic vector V_A and the system response semantic vector V_B is first calculated (feature dimension expansion is required before calculation to make the feature dimensions of the user question semantic vector V_A and the system response semantic vector V_B consistent), and then the dot product is divided by the product of the lengths of the two vectors to obtain the semantic similarity value. The semantic similarity value is the semantic association feature, and the value of the semantic association feature is positively correlated with the semantic similarity, that is, the higher the semantic similarity, the larger the value of the semantic association feature, indicating that the semantic matching degree between the user question and the system response is higher.
[0111] Step S133: Traverse the question and answer interaction records in the structured question and answer data set, group the question and answer interaction records according to the session identifier, extract the time interval between the adjacent two question and answer interaction records in the same session group in chronological order, and perform logarithmic scaling standardization processing on the time interval to generate a standardized time interval.
[0112] In extracting the interaction timing feature, the question and answer interaction records in the structured question and answer data set are first traversed. Each question and answer interaction record may have a session identifier to identify the session to which the question and answer interaction record belongs. The question and answer interaction records are grouped according to the session identifier, and the records belonging to the same session are grouped together.
[0113] In the same conversation group, the time interval between the adjacent two question-answer interaction records is extracted in chronological order. For example, assuming that there are three question-answer interaction records R1, R2 and R3 in a conversation group, which record the question-answer information at three different time points respectively. Then the time interval T1 between R1 and R2 and the time interval T2 between R2 and R3 can be calculated.
[0114] Then, the time intervals are subjected to logarithmic scaling normalization processing. Logarithmic scaling normalization is a commonly used data preprocessing method, which can scale the data to make it more uniform. Specifically, the logarithm of each time interval is taken, and then normalized to obtain a standardized time interval. The purpose of this is to eliminate outliers and scale differences in the time interval data, making the data more suitable for subsequent analysis and processing.
[0115] Step S134: In the same conversation group, the topic continuity index is calculated by comparing the theme keyword coincidence and entity association between the user question statement of the previous question-answer interaction record and the standardized user question statement of the next question-answer interaction record.
[0116] In the same conversation group, the topic continuity index also needs to be calculated. This is achieved by comparing the theme keyword coincidence and entity association between the user question statement of the previous question-answer interaction record and the standardized user question statement of the next question-answer interaction record.
[0117] First, the theme keywords and entity information in the user question statement of the previous question-answer interaction record and the standardized user question statement of the next question-answer interaction record are extracted. For example, the user question statement of the previous question-answer interaction record mentions theme keywords such as "pine tree powdery mildew" and "prevention and control measures", and an entity "pine tree", and the standardized user question statement of the next question-answer interaction record also mentions related content such as "pine tree" and "powdery mildew".
[0118] Then, the coincidence of theme keywords is calculated, i.e. the proportion of the number of the same theme keywords in the two statements to the total number of keywords. At the same time, the association between entities is analyzed, for example, whether the entities mentioned in the two statements are of the same category or have some kind of association. Considering the theme keyword coincidence and entity association, the topic continuity index is calculated. The higher the topic continuity index, the stronger the topic continuity between the adjacent two question-answer interaction records.
[0119] Step S135: Construct a time series feature vector based on the standardized time interval and the topic continuity index, and use the time series feature vector as the interaction time sequence feature.
[0120] Finally, the time series feature vector is constructed based on the normalized time interval and topic continuity indicator. The normalized time interval and topic continuity indicator are combined in a set order to form a vector, which is the time series feature vector. The time series feature vector is used as the interaction time sequence feature to represent the context dependency between adjacent question and answer interaction records.
[0121] Step S140: performing dynamic intent mapping processing based on the semantic association feature and the interaction time sequence feature to generate a target intent recognition result, the target intent recognition result including an intent classification label of the user query sentence and a corresponding intent confidence score.
[0122] In this embodiment, after the semantic association feature and the interaction time sequence feature are extracted, dynamic intent mapping processing is needed based on these features to generate a target intent recognition result.
[0123] Step S141: constructing a dynamic intent mapping network, the dynamic intent mapping network including a feature fusion layer, an attention calculation layer, and an intent classification layer.
[0124] First, a dynamic intent mapping network is constructed. The dynamic intent mapping network is composed of a feature fusion layer, an attention calculation layer, and an intent classification layer. The feature fusion layer is used to fuse the semantic association feature and the interaction time sequence feature, the attention calculation layer is used to allocate weights to the fused features, and the intent classification layer is used to classify the intent of the user query sentence.
[0125] Step S142: inputting the semantic association feature and the interaction time sequence feature into the feature fusion layer for feature normalization splicing and dimension reduction processing to generate a fused feature vector.
[0126] The semantic association feature and the interaction time sequence feature are input into the feature fusion layer. In the feature fusion layer, first, the two features are normalized to make their scales consistent. Normalization processing can use common normalization methods such as min-max normalization or z-score normalization.
[0127] Then, the normalized semantic association feature and the interaction time sequence feature are spliced. The splicing method can be to connect the two feature vectors in order. Next, the spliced feature vector is subjected to dimension reduction processing. Dimension reduction processing can use methods such as principal component analysis (PCA) to map the high-dimensional feature vector to a low-dimensional space to generate a fused feature vector.
[0128] Step S143: calling the attention calculation layer to perform weight allocation processing on the fusion feature vector, determining the contribution weights of the semantic association feature and the interaction timing feature to the intent classification, and weighting and correcting the fusion feature vector according to the contribution weights to generate attention-corrected features.
[0129] The fusion feature vector is input into the attention calculation layer. The attention calculation layer performs weight allocation processing on the fusion feature vector to determine the contribution weights of the semantic association feature and the interaction timing feature to the intent classification. Specifically, the attention calculation layer assigns different weights to the semantic association feature and the interaction timing feature through a series of calculations such as matrix multiplication, nonlinear transformation, etc.
[0130] Then, the fusion feature vector is weighted and corrected according to the contribution weights. The weighted and corrected way is to multiply each element in the fusion feature vector by the corresponding weight to obtain attention-corrected features, so as to highlight the more important features to the intent classification and improve the accuracy of intent recognition.
[0131] Step S144: inputting the attention-corrected features into the intent classification layer for full connection calculation and normalization processing to generate the intent classification label of the user question sentence and the corresponding intent confidence score, which is used to quantify the reliability degree of the intent classification label.
[0132] Finally, the attention-corrected features are input into the intent classification layer. The intent classification layer performs full connection calculation on the attention-corrected features, and maps the features to different intent classification categories through a series of neuron and weight matrix operations.
[0133] Then, the results of the full connection calculation are normalized, for example, using the softmax function to convert the results into a probability distribution. According to the probability distribution, the class with the maximum probability is selected as the intent classification label of the user question sentence. At the same time, the probability value corresponding to this class is the intent confidence score, which is used to quantify the reliability degree of the intent classification label. The higher the intent confidence score, the higher the reliability of the intent classification label.
[0134] Step S150: matching the preset response knowledge base according to the target intent recognition result to generate optimized response data, and sending the optimized response data to the forest farmer user terminal to trigger a response update operation.
[0135] In this embodiment, after obtaining the target intent recognition result, the preset response knowledge base needs to be matched according to the target intent recognition result to generate optimized response data, and the optimized response data is sent to the forest farmer user terminal.
[0136] Step S151: filtering a candidate response template set matching the intent classification label from the response knowledge base, each candidate response template being associated with a preset applicable scenario condition and a priority score.
[0137] First, a candidate response template set matching the intent classification label is filtered from the response knowledge base. The response knowledge base is a pre-constructed database storing a large number of response templates related to the forestry field, each template being associated with a preset applicable scenario condition and a priority score. In order to efficiently filter suitable templates from the knowledge base, an inverted index structure of the response knowledge base is first constructed. The inverted index structure records the intent label and the keyword set associated with each candidate response template. Through the inverted index structure, the primary candidate template set can be quickly retrieved according to the intent classification label.
[0138] Then, the primary candidate template set is further filtered. The overlap degree score between the key entity words in the user query sentence and the keyword set of each candidate response template in the primary candidate template set is calculated. Specifically, the named entity words and domain term words in the user query sentence are extracted to form a key entity word set. Then, each candidate response template in the primary candidate template set is traversed, and its associated keyword set is extracted. The Jaccard similarity between the key entity word set and each keyword set is calculated to obtain a basic overlap degree score. In order to make the score more reasonable, the basic overlap degree score also needs to be weighted and corrected based on the frequency of the keyword set in the response knowledge base. The weight coefficient of high-frequency keywords is lower than that of low-frequency keywords, which can highlight the role of low-frequency but important keywords to generate the final overlap degree score.
[0139] According to the final overlap degree score, the primary candidate template set is sorted, and the candidate response templates ranked higher than a preset threshold are selected, which constitute the candidate response template set. For example, the user query sentence is about pine tree disease and pest control, the intent classification label is "pine tree disease and pest control consultation", the primary candidate template set is retrieved from the inverted index, and after the overlap degree score calculation and sorting, templates such as "comprehensive prevention and control measures for common pine tree diseases and pests" and "pine tree powdery mildew special prevention and control template" are selected as the candidate response template set.
[0140] Step S152: filtering the candidate response template set according to the intent confidence score and the applicable scenario condition, and retaining the candidate response templates satisfying the scenario matching threshold and having a priority score higher than a preset threshold.
[0141] After obtaining the candidate response template set, it is necessary to filter it according to the intent confidence score and the applicable scene condition. The intent confidence score reflects the reliability of the intent classification label, and the applicable scene condition specifies the applicable range of each candidate response template. First, for each candidate response template, check whether its applicable scene condition matches the scene of the user's question. This can be determined by comparing the key information in the user's question statement with the key words or rules in the applicable scene condition. For example, if the user's question is about the prevention and treatment of pests and diseases of pine trees in mountainous areas, and the applicable scene condition of a certain candidate response template is clearly for trees in plain areas, then the template does not meet the scene matching requirement.
[0142] At the same time, reference is made to the intent confidence score. If the intent confidence score is low, it means that the reliability of the intent classification is not high, and at this time the candidate response template needs to be more strictly screened. Keep those candidate response templates that not only meet the scene matching threshold, that is, their applicable scene is highly matched with the user's question scene, but also have a priority score higher than a preset threshold. The priority score reflects the importance and applicability of the template in the knowledge base. For example, some templates are reviewed and verified by experts several times, so their priority score will be relatively high. Through such filtering processing, templates that do not meet the requirements are removed, and only candidate response templates that best meet the user's needs are left.
[0143] Step S153: Perform content adaptability adjustment processing on the retained candidate response templates, replace the key entity words in the standardized user question statement into the placeholders in the candidate response template, and generate a preliminary optimized response result.
[0144] For the candidate response templates retained after filtering, content adaptability adjustment is needed. Candidate response templates usually have placeholders that are used to replace specific information in actual application. Extract key entity words from the standardized user question statement, for example, in a question about the prevention and treatment of pests and diseases of pine trees, the key entity words may include "pine trees" and "powdery mildew". Replace these key entity words into the corresponding placeholders in the candidate response template.
[0145] For example, the candidate response template is "For [tree species] [pest and disease name], [prevention and treatment method] can be used for prevention and treatment", and the "pine trees" and "powdery mildew" in the standardized user question statement are replaced into the placeholders of "[tree species]" and "[pest and disease name]", respectively, to obtain "For pine trees, powdery mildew, [prevention and treatment method] can be used for prevention and treatment". Through such replacement operation, the content of the candidate response template is more consistent with the actual question of the user, and a preliminary optimized response result is generated.
[0146] Step S154: Perform logical coherence verification on the preliminary optimization response result. If contradictions or information omissions are detected in the response content, invoke the preset response iteration strategy to supplement missing information and correct logical errors, and generate the final optimized response data.
[0147] After obtaining the preliminary optimization response result, it needs to be verified for logical coherence. Logical coherence verification mainly checks whether there are contradictions or information omissions in the response content. It can be verified by analyzing the logical relationship of sentences in the response content, consistency of information before and after, etc. For example, in the preliminary optimization response result, it is mentioned that "for pine white powdery mildew, fungicide A needs to be used for prevention and control, and at the same time it is said that no fungicide needs to be used", which has obvious logical contradiction. Or when mentioning the control method, only the use of a certain pesticide is mentioned, but the dosage and frequency of the pesticide are not mentioned, which belongs to information omission.
[0148] If contradictions or information omissions are detected in the response content, the preset response iteration strategy is invoked. The strategy mainly includes the following steps:
[0149] Step S1541: Extract the core information field in the preliminary optimization response result, and compare it with the key entity words in the user question sentence to determine the missing information field and the contradictory information field.
[0150] First, extract the core information field from the preliminary optimization response result. These fields are usually the most important information in the response content. Then compare these core information fields with the key entity words in the user question sentence. For example, the user question mentions "the prevention and control measures and subsequent maintenance methods of pine white powdery mildew", but the preliminary optimization response result only mentions the prevention and control measures and does not mention the subsequent maintenance methods, so "subsequent maintenance methods" is the missing information field. If the description of the prevention and control measures in the response result conflicts with the scene of the user question, then this part of the content is the contradictory information field.
[0151] Step S1542: Retrieve the supplementary knowledge items associated with the missing information field from the response knowledge base, and insert the supplementary knowledge items into the specified position of the preliminary optimization response.
[0152] After determining the missing information fields, retrieve supplementary knowledge items associated with these fields from the response knowledge base. The response knowledge base stores a wealth of forestry field knowledge, and by matching the keywords or topics of the missing information fields, relevant supplementary knowledge items can be found. For example, if the missing information is the follow-up maintenance method for pine white powdery mildew, supplementary knowledge items such as "regularly pruning diseased leaves, and reasonably fertilizing to enhance tree resistance" can be retrieved from the knowledge base. Then these supplementary knowledge items are inserted into the designated positions of the preliminary optimized response results, usually the context positions related to the missing information.
[0153] Step S1543: Perform knowledge graph-based logical conflict detection processing on the contradictory information fields. By traversing the entity attributes and relationship constraints in the pre-constructed forestry field knowledge graph, determine whether the contradictory information fields violate field common sense or have logical inconsistencies. If a conflict is detected, retrieve replacement fields from the response knowledge base that match the intent classification label and key entity words, and perform content reconstruction on the preliminary optimized response based on the rule engine, so that the updated response content meets the consistency of field knowledge and logic.
[0154] For contradictory information fields, knowledge graph-based logical conflict detection processing is used. The forestry field knowledge graph is a knowledge base that contains various entities and their relationships in the forestry field, which defines the attributes and relationship constraints of entities. By traversing the knowledge graph, check whether the contradictory information fields violate these attributes and relationship constraints, and whether they are inconsistent with field common sense or have logical inconsistencies.
[0155] For example, if the preliminary optimized response result mentions that "pine white powdery mildew can be prevented with acid agents, but acid agents will exacerbate the condition of pine white powdery mildew", there is a logical conflict. If a conflict is detected, retrieve replacement fields from the response knowledge base that match the intent classification label and key entity words. According to the intent classification label and key entity words, find appropriate replacement content in the knowledge base. Then, based on the rule engine, reconstruct the content of the preliminary optimized response result. The rule engine is a rule-based reasoning system that can adjust and optimize the response content according to pre-set rules, so that the updated response content meets the consistency of field knowledge and logic.
[0156] Step S1544: Perform syntax checking and semantic integrity evaluation on the updated response content. If the evaluation result does not meet the pre-set quality standard, repeat the supplement and correction operations until the final optimized response data that meets the quality requirements is generated.
[0157] After the supplement and revision operations are completed, the updated response content is subjected to syntax checking and semantic integrity evaluation. Syntax checking mainly checks whether the syntax of the response content is correct, whether there are errors, grammatical errors, etc. Semantic integrity evaluation checks whether the response content completely answers the user's question and whether it contains necessary information.
[0158] If the evaluation result does not meet the preset quality standard, for example, there is a syntax error or the information is still incomplete, the supplement and revision operations are repeated. Further checking is performed to determine whether there is missing information or logical contradiction, more supplementary knowledge items or replacement fields are obtained from the knowledge base, and the response content is further optimized until the final optimized response data meeting the quality requirement is generated.
[0159] Step S155: sending the final optimized response data to the forest farmer user terminal to trigger a response updating operation.
[0160] After the final optimized response data is generated, it is sent to the forest farmer user terminal. The sending can be performed in various ways, such as sending the response data to the user through the message push function of the online consultation platform, email, etc. When the user receives the response data, the forest farmer user terminal triggers the response updating operation to display the latest and optimized response content, providing more accurate and detailed answers to the forest farmer user.
[0161] Further, the method can further include a training method of the dynamic intent mapping network, comprising:
[0162] Step S210: obtaining a structured question and answer data set in the forest farmer field as a training sample set, each sample in the training sample set including a standardized user question sentence, a corresponding standardized system response sentence, and a manually labeled intent classification label.
[0163] In order to enable the dynamic intent mapping network to accurately perform intent recognition, it needs to be trained. First, a structured question and answer data set in the forest farmer field is obtained as a training sample set. The data in the training sample set has been subjected to semantic standardization, and each sample includes a standardized user question sentence, a corresponding standardized system response sentence, and a manually labeled intent classification label. The manually labeled intent classification label is labeled by a professional according to the question and answer content and the knowledge in the forest farmer field, and is used to provide an accurate training target for the model. For example, for a question and answer about pine tree pest control, the manually labeled intent classification label can be "pine tree pest control consultation".
[0164] Step S211: constructing an initial model architecture of the dynamic intent mapping network, the initial model architecture comprising sequentially connected feature fusion layers, a multi-head self-attention layer, a gated recurrent unit layer, and an intent classification layer, wherein an input dimension of the feature fusion layer is consistent with a concatenation dimension of the semantic association feature and the interaction time sequence feature, and the gated recurrent unit layer contains hidden units and a time step matching a maximum round of the dialogue interaction.
[0165] An initial model architecture of the dynamic intent mapping network is constructed. The initial model architecture is sequentially connected by a feature fusion layer, a multi-head self-attention layer, a gated recurrent unit layer, and an intent classification layer. The feature fusion layer is used to fuse the semantic association feature and the interaction time sequence feature, and the input dimension thereof needs to be consistent with the concatenation dimension of the two features to ensure that the input data can be correctly processed.
[0166] The multi-head self-attention layer can perform multi-dimensional attention calculation on the input features to capture the global dependency relationship between the features. The gated recurrent unit layer contains hidden units, which can transmit and update information at time steps. The time step matches the maximum round of the dialogue interaction, so that the model can process long-sequence dialogue data and capture the context information of the dialogue. The intent classification layer is used to classify the intent of the user question sentence and output the intent classification label.
[0167] Step S212: performing feature preprocessing on the training sample set, extracting the semantic association feature and the interaction time sequence feature of each sample, and arranging the semantic association feature and the interaction time sequence feature into a feature sequence in the order of sample timestamps.
[0168] The training sample set is subjected to feature preprocessing. For each sample, its semantic association feature and interaction time sequence feature are extracted. The extraction method of the semantic association feature is the same as described in the previous step, that is, the semantic similarity between the standardized user question sentence and the standardized system response sentence is calculated to obtain the semantic association feature. The interaction time sequence feature is constructed by calculating the time interval and topic continuity index between adjacent question and answer interaction records.
[0169] The extracted semantic association feature and interaction time sequence feature are arranged into a feature sequence in the order of sample timestamps. The timestamp records the generation time of each sample, and the arrangement in the time sequence can make the model learn the time sequence and context information of the dialogue, thereby improving the intent recognition ability of the model.
[0170] Step S213: input the feature sequence into the initial model architecture for forward propagation calculation, wherein the feature fusion layer adopts a batch normalization operation to scale the spliced features, and the multi-head self-attention layer calculates the global dependency weight of the feature sequence through multiple parallel attention heads, and the gated recurrent unit layer iteratively updates the hidden state according to the time step to capture long-distance context patterns.
[0171] The feature sequence is input into the initial model architecture for forward propagation calculation. In the feature fusion layer, a batch normalization operation is used to scale the spliced features. Batch normalization can make the distribution of input data more stable, accelerate the training speed of the model and improve the convergence.
[0172] The multi-head self-attention layer calculates the global dependency weight of the feature sequence through multiple parallel attention heads. Each attention head can focus on different parts of the feature sequence from different angles, and obtain the global dependency weight through weighted summation, so as to better capture the relationship between features.
[0173] The gated recurrent unit layer iteratively updates the hidden state according to the time step. At each time step, the gated recurrent unit updates the current hidden state according to the current input and the hidden state of the previous time step, thereby capturing long-distance context patterns and enabling the model to understand the context information of the dialogue.
[0174] Step S214: calculate the cross-entropy loss value between the predicted intent classification result of the forward propagation output and the manually labeled intent classification label, and update the trainable parameters of the initial model architecture using an adaptive optimizer.
[0175] After completing the forward propagation calculation, the predicted intent classification result is obtained. The cross-entropy loss value between the predicted intent classification result and the manually labeled intent classification label is calculated. The cross-entropy loss value is used to measure the difference between the predicted result and the true label, and the smaller the loss value, the more accurate the prediction of the model.
[0176] The adaptive optimizer is used to update the trainable parameters of the initial model architecture. The adaptive optimizer can automatically adjust the learning rate according to the gradient information of the parameters, so that the model can converge to the optimal solution faster. For example, the commonly used adaptive optimizer such as Adam optimizer combines the advantages of momentum and adaptive learning rate, and can effectively update the model parameters.
[0177] Step S215: Monitor the decrease trend of the cross-entropy loss value on the validation set. When the fluctuation amplitude of the loss value of consecutive multiple training rounds is lower than a preset threshold, trigger the early stopping mechanism to freeze the model parameters, and generate a trained dynamic intent mapping network. The dynamic intent mapping network after freezing the parameters is deployed to an online inference environment, which receives real-time question and answer interaction data streams from the forest farmer user terminal and outputs target intent recognition results. During the inference process, the hidden state of the gated recurrent unit layer is stored separately based on the session identifier to maintain the independence of the dialogue context.
[0178] During the training process, the validation set is used to monitor the decrease trend of the cross-entropy loss value. The validation set is a part of data divided from the training data, which is used to evaluate the performance of the model on unseen data. When the fluctuation amplitude of the loss value of consecutive multiple training rounds is lower than a preset threshold, it means that the performance of the model has tended to be stable, at which time the early stopping mechanism is triggered to freeze the model parameters.
[0179] The dynamic intent mapping network after freezing the parameters is the trained dynamic intent mapping model. This dynamic intent mapping model is deployed to an online inference environment, in which the dynamic intent mapping model can receive real-time question and answer interaction data streams from the forest farmer user terminal. For each input question and answer interaction data, the model outputs the target intent recognition result. During the inference process, the hidden state of the gated recurrent unit layer is stored separately based on the session identifier. The session identifier is used to distinguish different dialogue sessions, and by storing the hidden state separately, the independence of the dialogue context can be maintained, so that the model can accurately process the context information of different sessions.
[0180] Further, the method can further include a training method of the semantic encoding model, comprising:
[0181] Step S310: Collect an unannotated text corpus in the forest farmer field, which contains forestry technical manuals, pest control reports, and historical question and answer records, and perform word segmentation processing and stop word filtering on the unannotated text corpus to generate a set of purified word sequences.
[0182] In order to train the semantic encoding model, first, an unannotated text corpus in the forest farmer field is collected. This corpus contains various text data such as forestry technical manuals, pest control reports, and historical question and answer records. These data cover various aspects of the forest farmer field and can provide rich semantic information for the model.
[0183] The collected unlabeled text corpus is preprocessed. First, word segmentation is performed to divide the text into individual word units. Then, stop word filtering is performed to remove stop words that have no substantive meaning for semantic expression, such as "of", "ah", etc. After such processing, a set of purified word sequences is generated, which will serve as the basis data for model training.
[0184] Step S311: Pre-training a word vector matrix on the set of purified word sequences based on a word embedding algorithm, wherein the word vector dimension is set to a predefined value and the context window size is adapted to the average length of domain terms, to generate initialized word vectors containing forest farming domain terms.
[0185] The word vector matrix is pre-trained on the set of purified word sequences based on a word embedding algorithm. The word embedding algorithm can map each word to a low-dimensional vector space, allowing semantic information of the word to be represented in the form of a vector. In the pre-training process, the word vector dimension is set to a predefined value, which needs to be adjusted according to the specific task and data situation.
[0186] The context window size is adapted to the average length of domain terms. The context window is used to determine the context range of the words considered in the training process, and a suitable context window size can enable the model to better learn the semantic information of the words. Through pre-training, initialized word vectors containing forest farming domain terms are generated, which will serve as input for the semantic encoding model.
[0187] Step S312: Constructing a double-tower neural network structure for the semantic encoding model, the double-tower neural network including parallel user question encoding towers and system response encoding towers, each encoding tower being composed of a sequence connection of a bidirectional long short-term memory network layer, a local sensitive hashing attention layer, and a deformable convolution layer, wherein the deformable convolution layer adjusts the shape of the convolution kernel dynamically to adapt to the variable context mode of forest farming domain terms; the local sensitive hashing attention layer uses Hamming distance-based similarity calculation to filter key semantic units.
[0188] A double-tower neural network structure for the semantic encoding model is constructed. The structure includes parallel user question encoding towers and system response encoding towers, which can respectively encode user question sentences and system response sentences.
[0189] Each encoding tower is composed of a sequence connection of a bidirectional long short-term memory network layer, a local sensitive hashing attention layer, and a deformable convolution layer. The bidirectional long short-term memory network layer can capture context information in the sentence, improving the model's understanding of semantics by considering both forward and backward information of the sequence.
[0190] The local sensitive hashing attention layer adopts Hamming distance-based similarity calculation to filter key semantic units. Hamming distance can measure the difference between two vectors. By calculating the Hamming distance between word vectors, key units related to the current word semantics are filtered out.
[0191] The deformable convolution layer can dynamically adjust the shape of the convolution kernel to adapt to the variable context mode of forest field terms. The context of forest field terms may change due to different scenarios and description methods. The deformable convolution layer can automatically adjust the shape of the convolution kernel according to the input data, thereby better extracting local context patterns.
[0192] Step S313: Sampling positive sample pairs and negative sample pairs from the structured question and answer data set, wherein the positive sample pair is a combination of a standardized user question statement and a corresponding system response statement with a semantic correlation feature higher than a preset threshold, and the negative sample pair is generated by randomly replacing the system response statement.
[0193] In order to train the semantic encoding model, it is necessary to sample positive sample pairs and negative sample pairs from the structured question and answer data set. The positive sample pair refers to the combination of a standardized user question statement and a corresponding system response statement with a semantic correlation feature higher than a preset threshold. The semantic correlation feature reflects the degree of semantic matching between the user question statement and the system response statement. Only when the matching degree is higher than the preset threshold, it is considered as a positive sample pair. For example, when the user asks "how to prevent white powdery disease of pine trees", the system response is "you can use a specific fungicide for spraying prevention, and pay attention to environmental ventilation". If their semantic correlation feature is higher than the preset threshold, it is a positive sample pair.
[0194] The negative sample pair is generated by randomly replacing the system response statement. That is, the user question statement remains unchanged, and a random unrelated system response statement is selected to combine with it. For example, the user question is still "how to prevent white powdery disease of pine trees", and a system response about tree fertilization is randomly selected "fertilize in spring and autumn to promote tree growth", which constitutes a negative sample pair.
[0195] Step S314: Input the user question statement and the system response statement in the positive and negative sample pairs into the corresponding encoding tower for vectorization processing, wherein the bidirectional long short-term memory network layer takes the pre-trained initialization word vector as input and outputs the time sequence perception feature, the local sensitive hashing attention layer filters key semantic units by calculating word-level similarity, and the deformable convolution layer extracts local context patterns using deformable convolution kernels.
[0196] The user question sentence and the system response sentence in the positive and negative sample pairs obtained by sampling are respectively input into the corresponding encoding tower for vectorization processing. In the encoding tower, the bidirectional long short-term memory network layer receives the pre-trained initialized word vector as the input. These initialized word vectors contain semantic information of the forest farming domain terminology, and the bidirectional long short-term memory network layer outputs time sequence perception features by processing the word vector sequence, considering the front and back information of the sequence. These features can reflect the time sequence and context relationship between the words in the sentence.
[0197] The local sensitive hashing attention layer processes the time sequence perception features output by the bidirectional long short-term memory network layer. It filters the key semantic units by calculating the word-level similarity. Specifically, the similarity between different words is calculated based on the Hamming distance, and the key units related to the current word semantics are found out, so as to highlight the important semantic information.
[0198] The deformable convolution layer processes the features output by the local sensitive hashing attention layer using a deformable convolution kernel. The deformable convolution kernel can dynamically adjust the shape according to the input data to adapt to the variable context mode of the forest farming domain terminology. In this way, the deformable convolution layer extracts the local context mode, further enriching the feature representation.
[0199] Step S315: Calculate the semantic similarity of the user question vector and the system response vector in the positive sample pair, and calculate the similarity difference of the negative sample pair. Based on the margin loss function, the encoding tower parameters are optimized with a predefined margin threshold, so that the similarity of the positive sample is at least the margin threshold higher than that of the negative sample.
[0200] After completing the vectorization processing, the user question vector and the system response vector in the positive sample pair, and the corresponding vectors in the negative sample pair are obtained. The semantic similarity of the user question vector and the system response vector in the positive sample pair is calculated, which reflects the degree of similarity between the two vectors, and also reflects the degree of semantic matching between the user question sentence and the system response sentence.
[0201] At the same time, the similarity difference of the negative sample pair is calculated. The similarity difference here can measure the degree of mismatch between the user question vector and the system response vector in the negative sample pair. The parameters of the encoding tower are optimized based on the margin loss function. The purpose of the margin loss function is to make the similarity of the positive sample at least the predefined margin threshold higher than that of the negative sample. That is, the model needs to learn the feature representation that can distinguish between positive samples and negative samples, so that the semantic matching degree of the positive sample pair is significantly higher than that of the negative sample pair. By continuously adjusting the parameters of the encoding tower, the value of the loss function is continuously reduced, thereby optimizing the performance of the model.
[0202] Step S316: Adopt gradient clipping strategy to limit the gradient norm in the back propagation process, and use momentum optimizer to update the model parameters. After each round of training, the nearest neighbor retrieval accuracy of the validation set is evaluated.
[0203] During the training process, the gradient clipping strategy is adopted to limit the gradient norm in the back propagation process. In the training of neural networks, the gradient represents the rate of change of the loss function with respect to the model parameters, which is used to guide the update of the parameters. However, sometimes the gradient may become very large, causing the parameter update step to be too large, making the model unable to converge or causing the problem of gradient explosion. The gradient clipping strategy sets an upper limit for the gradient norm, and when the norm of the gradient exceeds the upper limit, the gradient is scaled to keep the norm within a reasonable range.
[0204] The momentum optimizer is used to update the model parameters. The momentum optimizer combines the historical information of the gradient, considering not only the current gradient but also the direction of the previous gradient when updating the parameters. This makes the parameter update more stable, avoids falling into local optimal solution, and speeds up the convergence of the model.
[0205] After each round of training, the nearest neighbor retrieval accuracy of the validation set is evaluated. The validation set is a part of data divided from the training data, used to evaluate the performance of the model on unseen data. The process of nearest neighbor retrieval accuracy evaluation is as follows: for each user query vector in the validation set, find the most similar vector in the system response vector set, and then judge whether the system response statement corresponding to the most similar vector is semantically matched with the user query statement. If matched, it is considered correct retrieval. By calculating the proportion of correct retrieval, the nearest neighbor retrieval accuracy is obtained. This nearest neighbor retrieval accuracy can reflect the performance of the model in semantic matching.
[0206] Step S317: When the average retrieval accuracy on the validation set remains above the preset threshold for multiple rounds in a row, terminate the training process and export the parameter weights of the user query encoding tower, and deploy the parameter weights to the online semantic matching service to convert forest farmer user queries into standardized semantic vectors in real time to support intent recognition.
[0207] During the training process, the average retrieval accuracy on the validation set is continuously monitored. When the average retrieval accuracy remains above the preset threshold for multiple rounds in a row, it means that the performance of the model has reached a relatively stable and satisfactory level, and the training process is terminated at this time.
[0208] The parameter weights of the user question encoding tower are derived. These parameter weights record the feature representations and semantic information learned by the model during training. These parameter weights are deployed to the online semantic matching service. In the online semantic matching service, when a question from a forestry user is received, the parameter weights are used to convert the user question into a standardized semantic vector. This standardized semantic vector can accurately represent the semantic information of the user question, thereby supporting subsequent intent recognition tasks. For example, when a forestry user inputs a question about tree maintenance, the online semantic matching service converts it into a standardized semantic vector, providing a basis for subsequent intent classification and response generation.
[0209] It is worth noting that throughout the data processing and model training process, special attention needs to be paid to the protection of privacy-sensitive data. For privacy-sensitive data that may be involved, such as the personal information of forestry users, the specific location of plantations, etc., encryption technology is used for privacy protection. In the data collection stage, sensitive data is desensitized to remove information that can directly identify the identity of the user. In the data storage and transmission process, secure encryption algorithms are used to encrypt the data to prevent data leakage. At the same time, a strict access control mechanism is established, only authorized personnel can access and process these data, to ensure the security and privacy of the data.
[0210] Based on the above steps, starting from obtaining the initial question and answer data set of forestry users, through semantic normalization processing, feature extraction, dynamic intent mapping processing, and finally generating optimized response data according to the intent recognition results matching the response knowledge base, and through training the dynamic intent mapping network and the semantic encoding model, the intent recognition response method based on forestry question and answer data is realized, which can provide more accurate and efficient problem solving and services for forestry users.
[0211] Figure 2 A schematic diagram of exemplary hardware and software components of the intent recognition response system based on forestry question and answer data 100 that can implement the idea of the present application provided by some embodiments of the present application is shown. For example, the processor 120 can be used in the intent recognition response system based on forestry question and answer data 100 and used to perform the functions in the present application.
[0212] The intent recognition response system based on forestry question and answer data 100 can be a general server or a special-purpose server, both of which can be used to implement the intent recognition response method based on forestry question and answer data of the present application. Although the present application only shows one server, for the sake of convenience, the functions described in the present application can be implemented in a distributed manner on multiple similar platforms to balance the processing load.
[0213] For example, the forest farmer question and answer data based intent recognition response system 100 can include a network port 110 connected to a network, one or more processors 120 for executing program instructions, a communication bus 130, and different forms of storage media 140, such as a disk, a ROM, or a RAM, or any combination thereof. Illustratively, the forest farmer question and answer data based intent recognition response system 100 can also include program instructions stored in a ROM, a RAM, or other types of non-transitory storage media, or any combination thereof. The methods of the present application can be implemented according to these program instructions. The forest farmer question and answer data based intent recognition response system 100 also includes an I / O interface 150 between the computer and other input and output devices.
[0214] For ease of illustration, only one processor is described in the forest farmer question and answer data based intent recognition response system 100. However, it should be noted that the forest farmer question and answer data based intent recognition response system 100 in the present application can also include multiple processors, and thus the steps performed by one processor described in the present application can also be jointly performed by multiple processors or individually performed by multiple processors. For example, if the processor of the forest farmer question and answer data based intent recognition response system 100 performs steps A and B, it should be understood that steps A and B can also be jointly performed by two different processors or individually performed in one processor. For example, a first processor performs step A, a second processor performs step B, or the first processor and the second processor jointly perform steps A and B.
[0215] In addition, the present application also provides a readable storage medium, in which computer executable instructions are pre-set, and when the processor executes the computer executable instructions, the forest farmer question and answer data based intent recognition response method is realized.
[0216] It should be noted that, in order to simplify the expression of the present application and to help the understanding of one or more embodiments of the present application, in the foregoing description of the embodiments of the present application, various features are sometimes combined into one embodiment, figure or description thereof.
Claims
1. An intent recognition response method based on forestry farmer question-and-answer data, characterized in that, The method includes: Obtain the initial question and answer data set of forestry and agriculture users. The initial question and answer data set includes multiple question and answer interaction records. Each question and answer interaction record consists of at least one user question statement and a corresponding system initial response statement. The initial question-and-answer data set is semantically normalized to generate a structured question-and-answer data set. Each question-and-answer interaction record in the structured question-and-answer data set contains standardized user question statements and standardized system response statements. Semantic association features and interaction timing features are extracted from the structured question-and-answer data set. The semantic association features are used to characterize the semantic matching degree between the user's question statement and the system's response statement, and the interaction timing features are used to characterize the contextual dependency relationship between adjacent question-and-answer interaction records. Dynamic intent mapping is performed based on the semantic association features and the interaction timing features to generate target intent recognition results. The target intent recognition results include the intent classification label of the user's question and the corresponding intent confidence score. Based on the target intent recognition result, a preset response knowledge base is matched to generate optimized response data, and the optimized response data is sent to the forestry and agriculture user terminal to trigger the response update operation; The extraction of semantic association features and interaction temporal features from the structured question-and-answer data set includes: The standardized user question statement is vectorized by a pre-trained semantic coding model to generate a user question semantic vector, and the standardized system response statement is vectorized to generate a system response semantic vector. Calculate the semantic similarity between the semantic vector of the user's question and the semantic vector of the system response to obtain the semantic association feature. The value of the semantic association feature is positively correlated with the semantic similarity. Traverse the question-and-answer interaction records in the structured question-and-answer data set, group the question-and-answer interaction records according to the session identifier, extract the time interval between two adjacent question-and-answer interaction records in the same session group in chronological order, and perform logarithmic scaling and standardization processing on the time interval to generate a standardized time interval. Within the same conversation group, the topic continuity index is calculated by comparing the overlap of topic keywords and entity relevance between the user's question statement in the previous Q&A interaction record and the standardized user's question statement in the next Q&A interaction record. A time series feature vector is constructed based on the standardized time interval and the topic continuity index, and the time series feature vector is used as the interaction time series feature.
2. The intent recognition response method based on forestry farmer question-and-answer data according to claim 1, characterized in that, The step of semantically normalizing the initial question-and-answer data set to generate a structured question-and-answer data set includes: The user questions in the initial question and answer data set are cleaned by removing non-text symbols, repeated characters and irrelevant stop words to generate cleaned user questions. The purified user question statement is segmented to obtain a set of user question word units. Then, according to a preset forestry and agriculture domain thesaurus, the user question word unit set is tagged with part of speech and replaced with terms to generate a standardized user question statement. The initial system response statements in the initial question and answer data set are subjected to response integrity verification. If the initial system response statement is found to contain missing fields or incorrect logical associations, a response completion strategy based on the forestry and agriculture domain knowledge graph is invoked. Based on the contextual semantics of the missing fields, relevant entity attributes or association solutions are retrieved from the knowledge graph to generate supplementary response content. The supplementary response content is concatenated with the original system initial response statement to generate a standardized system response statement; The standardized user question statements are associated and stored with the corresponding standardized system response statements to generate the structured question and answer data set.
3. The intent recognition response method based on forestry farmer question-and-answer data according to claim 1, characterized in that, The dynamic intent mapping process based on the semantic association features and the interaction timing features to generate the target intent recognition result includes: A dynamic intent mapping network is constructed, which includes a feature fusion layer, an attention calculation layer, and an intent classification layer. The semantic association features and the interaction temporal features are input into the feature fusion layer for feature normalization, concatenation, and dimensionality reduction to generate a fused feature vector. The attention calculation layer is invoked to perform weight allocation processing on the fused feature vector, determine the contribution weights of the semantic association features and the interaction temporal features to the intent classification, and perform weighted correction on the fused feature vector according to the contribution weights to generate attention-corrected features; The attention correction features are input into the intent classification layer for fully connected computation and normalization to generate intent classification labels and corresponding intent confidence scores for the user's question. The intent confidence scores are used to quantify the reliability of the intent classification labels.
4. The intent recognition response method based on forestry farmer question-and-answer data according to claim 1, characterized in that, The step of matching the target intent recognition result with a preset response knowledge base to generate optimized response data includes: The response knowledge base is used to select a set of candidate response templates that match the intent classification tags, and each candidate response template is associated with preset applicable scenario conditions and priority scores; The candidate response template set is filtered based on the intent confidence score and the applicable scenario conditions, and candidate response templates that meet the scenario matching threshold and have a priority score higher than a preset threshold are retained. The retained candidate response templates are adjusted for content adaptation by replacing the key entities in the standardized user question with placeholders in the candidate response templates, thereby generating preliminary optimized response results. The preliminary optimized response results are subjected to logical coherence verification. If contradictions or missing information are detected in the response content, a preset response iteration strategy is invoked to supplement the missing information and correct logical errors, thereby generating the final optimized response data.
5. The intent recognition response method based on forestry farmer question-and-answer data according to claim 4, characterized in that, The process of invoking a preset response iteration strategy to supplement missing information and correct logical errors, generating final optimized response data, includes: Extract the core information fields from the preliminary optimized response results and compare them with the key entity words in the user's question to determine the missing information fields and contradictory information fields; Retrieve supplementary knowledge entries associated with the missing information field from the response knowledge base, and insert the supplementary knowledge entries into the specified positions of the preliminary optimized response; The contradictory information fields are subjected to logical conflict detection processing based on knowledge graphs. By traversing the entity attributes and relational constraints in the pre-constructed forestry and agriculture domain knowledge graph, it is determined whether the contradictory information fields violate domain common sense or have logical inconsistencies. If a conflict is detected, a replacement field matching the intent classification tag and key entity words is retrieved from the response knowledge base, and the content of the preliminary optimized response is reconstructed based on the rule engine so that the updated response content satisfies domain knowledge and logical consistency. The updated response content undergoes syntax validation and semantic integrity assessment. If the assessment results do not meet the preset quality standards, the supplementation and correction operations are repeated until the final optimized response data that meets the quality requirements is generated.
6. The intent recognition response method based on forestry farmer question-and-answer data according to claim 1, characterized in that, The step of calling a pre-trained semantic encoding model to perform vector transformation processing on the standardized user question statement to generate a user question semantic vector includes: The standardized user query statement is processed by word vector transformation to obtain an initial word vector sequence; The initial word vector sequence is context-encoded by calling the bidirectional long short-term memory network in the semantic coding model to generate context-aware word vectors. The context-aware word vectors are subjected to max pooling to extract global semantic features, and the global semantic features are input into a fully connected layer for dimensionality reduction to generate the user question semantic vector.
7. The intent recognition response method based on forestry farmer question-and-answer data according to claim 6, characterized in that, The step of performing max pooling on the context-aware word vectors to extract global semantic features includes: The context-aware word vectors are segmented according to time steps to obtain multiple context feature slices; For each context feature slice, maximum value sampling is performed to obtain the set of local maximum feature values; The set of local maximum feature values is weighted and fused to generate the global semantic feature, wherein the weight coefficients are dynamically adjusted according to the semantic density of the context feature slices.
8. The intent recognition response method based on forestry farmer question-and-answer data according to claim 4, characterized in that, The step of filtering a set of candidate response templates from the response knowledge base that match the intent classification label includes: Construct an inverted index structure for the response knowledge base, wherein the inverted index structure records the intent tags and keyword set associated with each candidate response template; A primary candidate template set is retrieved from the inverted index structure based on the intent classification labels; Calculate the overlap score between the key entity words in the user's question and the keyword set of each candidate response template in the primary candidate template set; The primary candidate template set is sorted according to the overlap score, and candidate response templates with a ranking higher than a preset threshold are selected to form the candidate response template set. The calculation of the overlap score between the key entity words in the user's question and the keyword set of each candidate response template in the primary candidate template set includes: Extract named entity words and domain terminology from the user's query to form a key entity word set; Iterate through each candidate response template in the primary candidate template set and extract its associated keyword set; Calculate the Jaccard similarity between the set of key entity words and each set of keywords to obtain a basic overlap score; The basic overlap score is weighted and corrected based on the frequency of occurrence of the keyword set in the response knowledge base to generate the final overlap score, wherein the weight coefficient of high-frequency keywords is lower than that of low-frequency keywords.
9. An intent recognition and response system based on forestry farmer question-and-answer data, characterized in that, The device includes a processor and a memory, the memory being connected to the processor. The memory is used to store programs, instructions, or code, and the processor is used to execute the programs, instructions, or code in the memory to implement the intent recognition and response method based on forestry and agriculture question-and-answer data as described in any one of claims 1-8.