Semantic generation method and device, equipment, medium and product
By using sequence labeling models and edit distance to merge sentence tree structures, the semantic generation process of in-vehicle speech recognition is automated, solving the problems of manual labeling and manual merging in semantic understanding, improving the accuracy and efficiency of semantic generation, and reducing crosstalk after the system is deployed.
Patent Information
- Application Number
- CN202511177455.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-12-12
AI Technical Summary
Existing technologies often produce errors in the semantic text generated after speech recognition and transcription in an in-vehicle environment, resulting in poor semantic generation quality. Furthermore, they require a large amount of manual annotation and operation, which affects the system's real-time performance and user experience.
A set of labeled sentence patterns is generated by using a sequence labeling model, a tree structure of sentence patterns is constructed, and the tree structure is merged using edit distance. The semantic correction of the corpus is performed in combination with a predefined prototype vector library, and the labeling and merging process is automated, reducing manual intervention.
It improves the accuracy and efficiency of semantic generation, reduces manual annotation time, reduces development time for the process of quantifying and merging sentence differences, and reduces crosstalk problems after the system is deployed.
Smart Images

Figure CN121118901A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a semantic generation method, apparatus, device, medium, and product. Background Technology
[0002] In an in-vehicle environment, user voice input is transcribed into text via speech recognition and then used to generate corresponding semantic text through semantic understanding. Within the semantic understanding module, dictionary matching and sentence structure matching are used to quickly extract semantic slots from the user's spoken text.
[0003] Currently, semantic understanding mainly includes two steps: dictionary annotation and sentence structure organization. Dictionary annotation refers to language experts annotating the corpus, marking words with similar semantic meanings as the same variable, and storing this information in a dictionary. Dictionary annotation can reduce the size of the corpus. Because the corpus is very large, the number of sentence structures generated after annotation is also excessive; sentence structure organization can be performed to reduce the number of sentence structures.
[0004] However, the semantic text generated through the above semantic understanding often contains errors, resulting in poor semantic generation performance. Summary of the Invention
[0005] The main objective of this application is to provide a semantic generation method, apparatus, device, medium, and product that can improve the accuracy and efficiency of semantic generation.
[0006] To achieve the above objectives, firstly, this application provides a semantic generation method, comprising:
[0007] A set of annotated sentence patterns corresponding to the text corpus of in-vehicle services is generated by using a sequence labeling model; a tree structure of all sentences in the annotated sentence pattern set is constructed to obtain all tree structures corresponding to the annotated sentence pattern set;
[0008] All tree structures are merged based on edit distance to obtain the semantics of the text corpus;
[0009] If the semantics of the corpus do not meet the preset conditions, the semantics of the corpus are modified to obtain the modified semantics of the corpus.
[0010] In one embodiment, a set of annotated sentence patterns corresponding to the text corpus of in-vehicle services is generated using a sequence annotation model, including:
[0011] Receive text corpus from vehicle-mounted services, where sentences in the text corpus are associated with service category tags;
[0012] Encode the text corpus to obtain the corresponding corpus vector;
[0013] By mapping corpus vectors to semantic space through a pre-trained language model, the target sentence vectors corresponding to the corpus vectors are obtained.
[0014] By learning from prototypes, corresponding slot labels are configured for the target statement vectors, generating a set of annotated sentence patterns.
[0015] In one implementation, a pre-trained language model is used to map corpus vectors to a semantic space to obtain target sentence vectors corresponding to the corpus vectors, including:
[0016] The corpus vectors are processed to generate candidate sentence vectors;
[0017] The semantic information of the sub-word vectors in the candidate sentence vectors is fused by the weighted average method to obtain the representation vector of the candidate sentence vector, and the representation vector of the candidate sentence vector is used as the target sentence vector.
[0018] In one implementation, prototype learning is used to configure corresponding slot labels for target statement vectors, generating a set of annotated sentence patterns, including:
[0019] Obtain a predefined prototype vector library, wherein the predefined prototype vector library configures at least one prototype vector for each semantic slot value;
[0020] Perform similarity matching between the target statement vector and the prototype vectors in the predefined prototype vector library;
[0021] Assign slot labels to the prototype vectors with the highest similarity to the target sentence vectors to form a set of labeled sentence patterns.
[0022] In one implementation, obtaining a predefined prototype vector library includes:
[0023] Segment sentences in the text corpus to generate all vectors corresponding to the text corpus;
[0024] Configure a corresponding prototype vector for each of all vectors to obtain all prototype vectors;
[0025] Cluster all prototype vectors to obtain at least one prototype vector corresponding to the same semantic slot value;
[0026] A predefined prototype vector library is constructed based on at least one prototype vector corresponding to the same semantic slot value.
[0027] In one implementation, a tree structure is constructed for all sentences in the annotated sentence set, resulting in all tree structures corresponding to the annotated sentence set, including:
[0028] All sentence patterns in the labeled sentence pattern set are segmented to obtain all tree structures of all sentence patterns. The nodes in the tree structure contain slot value labels and attribute sets. The attribute sets include deletability, multiple choice, and repetition.
[0029] In one implementation, all tree structures are merged based on edit distance to obtain the semantics of the text corpus, including:
[0030] Calculate the edit distance between any two tree structures in all tree structures, where the edit distance is used to define node deletion, node insertion, and node replacement operations in the tree structure;
[0031] If the edit distance between any two tree structures in all tree structures is less than the first preset threshold, the two tree structures are merged using the preset merging rules to obtain the merged tree structure corresponding to the two tree structures.
[0032] By statistically analyzing the merged tree structures corresponding to any two tree structures, a set of merged sentence patterns is obtained, and this set of merged sentence patterns is used as the semantic data of the text corpus.
[0033] In one embodiment, any two tree structures include a first tree structure and a second tree structure;
[0034] Calculate the edit distance between any two tree structures in all tree structures, including:
[0035] Based on the node attributes of any two tree structures, the operation costs are dynamically allocated to obtain the operation costs of the first tree structure and the second tree structure:
[0036] When transforming the first tree structure into the second tree structure, the minimum total operation cost required for the transformation is calculated based on the operation cost of the first tree structure and the operation cost of the second tree structure, and the minimum total operation cost required for the transformation is used as the edit distance between any two tree structures.
[0037] In one embodiment, any two tree structures are merged using a preset merging rule to obtain a merged tree structure corresponding to the two tree structures, including:
[0038] Get the difference type between any two tree structures;
[0039] Based on the difference type, update the attributes of the difference nodes to obtain the merged tree structure corresponding to any two tree structures.
[0040] In one implementation, updating the attributes of the difference node based on the difference type includes:
[0041] If the difference between any two tree structures is node replacement, then the difference nodes are merged into a multi-select attribute node;
[0042] If the difference between any two tree structures is node insertion / deletion, then the difference node is marked as a node with deletable attributes.
[0043] In one embodiment, it further includes:
[0044] Receive a new set of sentence patterns and retrieve the target sentence pattern from the new set of sentence patterns;
[0045] Traverse the merged sentence set, calculate the distance between the sentence in the merged sentence set and the target sentence, and obtain the distance set;
[0046] Select the minimum distance from the set of distances;
[0047] If the minimum distance meets the second preset threshold, the target sentence is merged into the sentence in the merged sentence set corresponding to the minimum distance according to the preset merging rules;
[0048] If the minimum distance does not meet the second preset threshold, the target sentence will be merged into the merged sentence set.
[0049] In one embodiment, if the semantics of the corpus do not meet preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus, including:
[0050] If the semantics of the corpus are erroneous text corpus, the similarity between the vectors in the erroneous text corpus and the prototype vectors in the predefined prototype vector library is calculated using an adaptive distance metric to obtain the similarity result;
[0051] Based on the similarity results, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus.
[0052] In one implementation, the semantics of the corpus are corrected based on the similarity results to obtain the corrected semantics of the corpus, including:
[0053] If the erroneous text corpus includes new text corpus, the semantics of the corpus are corrected by matching it against a predefined prototype vector library to obtain the corrected semantics of the corpus;
[0054] If the erroneous text corpus includes new sentence structures, the semantics of the corpus are corrected by matching it against a pre-defined sentence structure library to obtain the corrected semantics of the corpus.
[0055] Secondly, embodiments of this application provide a semantic generation apparatus, including:
[0056] The annotation module is used to generate a set of annotated sentence patterns corresponding to the text corpus of in-vehicle services through a sequence annotation model;
[0057] The construction module is used to build the tree structure of all sentences in the annotated sentence set, and obtain all the tree structures corresponding to the annotated sentence set;
[0058] The merging module is used to merge all tree structures based on edit distance to obtain the semantics of the text corpus;
[0059] The correction module is used to correct the semantics of the corpus if the semantics of the corpus do not meet the preset conditions, so as to obtain the corrected semantics of the corpus.
[0060] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any of the methods described above.
[0061] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0062] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0063] This application provides a semantic generation method, apparatus, device, medium, and product, comprising: firstly generating a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model; then constructing a tree structure of all sentence patterns in the annotated sentence pattern set to obtain all tree structures corresponding to the annotated sentence pattern set; and then merging all tree structures based on edit distance to obtain the semantics of the text corpus. If the semantics of the corpus do not meet preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus. This application generates a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model, improving annotation efficiency. Furthermore, by constructing a tree structure of all sentence patterns in the annotated sentence pattern set, the sentence patterns are clearly presented, facilitating the merging of all tree structures based on edit distance, making the merged tree structure more accurate, thereby improving the accuracy of the obtained semantics of the corpus. Attached Figure Description
[0064] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application. In the drawings:
[0065] Figure 1 This is a schematic diagram of a semantic generation method provided in an embodiment of this application;
[0066] Figure 2 This is a flowchart illustrating a semantic mapping method provided in an embodiment of this application;
[0067] Figure 3 This is a schematic diagram of a node attribute provided in an embodiment of this application;
[0068] Figure 4 This is a schematic diagram of a tree structure merging provided in an embodiment of this application;
[0069] Figure 5 This is a flowchart illustrating a sentence structure updating method provided in an embodiment of this application;
[0070] Figure 6 This is a flowchart illustrating a corpus correction method provided in an embodiment of this application;
[0071] Figure 7 This is a schematic diagram of the structure of a semantic generation device provided in an embodiment of this application;
[0072] Figure 8 This is a schematic diagram of the computer device provided in the embodiments of this application. Detailed Implementation
[0073] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0074] The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein.
[0075] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0076] It should be understood that in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0077] It should be understood that in this application, "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product or device.
[0078] It should be understood that in this application, "multiple" refers to two or more. "And / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, "and / or B" can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "Contains A, B, and C", "Contains A, B, and C" means that all three A, B, and C are contained; "Contains A, B, or C" means that one of A, B, and C is contained; "Contains A, B, and / or C" means that any one, two, or three of A, B, and C are contained.
[0079] It should be understood that in this application, "B corresponding to A", "B corresponding to A", "A corresponds to B", or "B corresponds to A" means that B is associated with A, and B can be determined based on A. Determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information. Matching A and B is defined as a similarity between A and B that is greater than or equal to a preset threshold.
[0080] Depending on the context, "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection."
[0081] The data involved in this application may be data authorized by the tester or fully authorized by all parties. The collection, dissemination, and use of the data shall comply with the relevant laws, regulations and standards of the relevant countries and regions. The implementation methods / executives of this application may be combined with each other.
[0082] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0083] The present application will now be described in conjunction with the accompanying drawings and specific embodiments.
[0084] In an in-vehicle environment, user voice input is transcribed into text via speech recognition and then processed by a semantic understanding module. The client responds based on the results of this module. The semantic understanding module uses dictionary matching and sentence pattern matching to quickly extract semantic slots from the user's text. In in-vehicle scenarios, high real-time performance is required, and the system needs to respond quickly. However, due to the diversity of user expressions, on the one hand, extensive annotation work by language experts is needed to label similar sentence fragments with the same slot value; on the other hand, the system needs to pre-store a large number of sentence patterns for matching, leading to significant semantic crosstalk issues that require manual analysis.
[0085] Currently, the semantic understanding module is in the development stage, which is divided into dictionary annotation and sentence structure organization.
[0086] First, there is dictionary annotation. Language experts annotate the corpus, marking words with similar semantic meanings as the same variable and storing them in a dictionary. Dictionary annotation can reduce the size of the corpus. For example, language experts can annotate similar corpus segments such as "turn on" and "open" as "action_open", thereby reducing the variable dimension of the sequence.
[0087] The second step is sentence structure organization. Due to the large size of the corpus and the excessive number of sentences generated after tagging the segments, "optional nodes" and "selection nodes" are used to reduce the number of sentences. "Optional nodes" can be used to handle deletable parts that do not affect the semantics. For example, the sentences "turn on the air conditioner" and "turn on the air conditioner in the car" can be merged into "turn on [the air conditioner in the car]". "Selection nodes" can be used to handle sentences with different semantic slots under the same business. For example, "turn on the front air conditioner" and "turn on the rear air conditioner" can be merged into "turn on (front|rear) air conditioner".
[0088] The third step is semantic optimization. After the system is deployed, semantic developers need to optimize the annotation dictionary and sentence structures for semantically erroneous corpora to achieve the desired semantic results. This process is divided into in-set test set optimization and out-of-set generalization optimization. Semantic errors in the in-set test set are often due to ambiguity in the annotation stage, sentence structure errors, or sentence structure crosstalk, requiring operations such as splitting and merging existing dictionaries. Semantic errors in the out-of-set test set are often due to unmatched dictionary entries or unmatched pre-stored sentence structures, requiring the addition of new dictionaries or sentence structures.
[0089] The existing technical solutions have the following disadvantages:
[0090] First, it requires a large amount of manual segment annotation. Traditional annotation methods require language specialists to spend a significant amount of time annotating massive test sets. The quality of slot annotation in this step heavily relies on the subjective judgment of language specialists, leading to inconsistencies and affecting the dimensionality reduction effect. In contrast, annotation methods based on sequence labeling models can automate the annotation process based on classification information and achieve maximum efficiency in variable dimensionality reduction.
[0091] Second, sentence structure differences are difficult to quantify. Traditional regular expression methods can only determine whether sentence structures match, but cannot define the magnitude of differences between them. These differences often require manual verification by technical personnel and language specialists. This invention uses a tree structure to model sentence structures, and tree edit distance can be used to easily quantify the magnitude of differences between sentence structures.
[0092] Third, the merging process requires manual operation. Traditional sentence merging requires manual intervention from developers. After finding sentences with similar structures, developers compare the differences and manually merge these sentences using "optional nodes" and "selected nodes," which is time-consuming and labor-intensive. This invention utilizes edit distance to automatically merge similar sentences, significantly reducing development time.
[0093] Fourth, the system faces significant crosstalk issues after deployment. Traditional annotation methods rely on manual judgment, often resulting in identical sentence structures across multiple business categories. This leads to substantial crosstalk after system deployment, severely impacting user experience. The slot value annotation method used in this invention ensures that the mapped sentence structures do not cause category confusion, reducing subsequent crosstalk optimization issues.
[0094] Fifth, after the system is deployed, there will be a need to optimize sentences outside the set. Traditional optimization methods heavily rely on developers' understanding of the semantic system and language features, and the workload increases exponentially with the amount of data to be optimized. The sequence labeling model used in this invention constructs a learnable prototype vector library and, based on the most recent sentence pattern matching method, can automatically analyze and statistically analyze semantically erroneous sentences, and provide developers with suggestions for correction.
[0095] To address the aforementioned issues, this application proposes a semantic generation method.
[0096] Please see Figure 1 , Figure 1 This is a flowchart illustrating a semantic generation method provided in an embodiment of this application. Figure 1 As shown, it includes the following steps:
[0097] Step S101: Generate a set of labeled sentences corresponding to the text corpus of vehicle services through a sequence labeling model.
[0098] To generate a set of annotated sentences corresponding to the text corpus of vehicle services through a sequence labeling model, it is necessary to first receive the text corpus of vehicle services, in which sentences in the text corpus are associated with business classification labels. Then, the text corpus is encoded to obtain the corresponding corpus vector. Then, the corpus vector is mapped to the semantic space through a pre-trained language model to obtain the target sentence vector corresponding to the corpus vector. Finally, the target sentence vector is configured with corresponding slot value labels through prototype learning to generate a set of annotated sentences.
[0099] The process involves mapping corpus vectors to a semantic space using a pre-trained language model to obtain the target sentence vectors corresponding to the corpus vectors. This includes: processing the corpus vectors to generate candidate sentence vectors; using a weighted average method to fuse the semantic information of the sub-word vectors in the candidate sentence vectors to obtain the representation vectors of the candidate sentence vectors; and using the representation vectors of the candidate sentence vectors as the target sentence vectors.
[0100] Specifically, in the in-vehicle voice interaction system, for the "window control" function, a set of labeled sentences is generated using a sequence labeling model. The specific process is as follows:
[0101] like Figure 2 As shown, voice-to-text transcripts related to window control in in-vehicle scenarios were collected, and these transcripts were all associated with the "window control" business tag. For example, the collected corpus included phrases such as "turn on the window," "open the window," and "close the window," which covered different expressions of user window operations and all pointed to the "window control" business.
[0102] The collected text corpus is processed. First, for text like "turn on the window," "open the window," and "close the window," word decomposition techniques (such as BPE) are used to break down "turn on," "open," and "close" into basic semantic units. Then, these decomposed words are converted into initial vectors, with each word corresponding to a low-dimensional numerical vector, thus forming the corpus vector for the entire sentence. For example, "turn on the window" is converted into a corpus vector containing the word vectors of "turn," "on," "the," and "window"; "open the window" is converted into a corpus vector containing the word vectors of "open," "the," and "window"; and "close the window" is converted into a corpus vector containing the word vectors of "close," "the," and "window," respectively corresponding to... Figure 2 Vector 1, Vector 2, and Vector 3 in the vector.
[0103] Then, a pre-trained language model (such as BERT) is called to process the corpus vectors. The model first performs deep semantic encoding on the corpus vector sequence to capture the association between words, such as the action-object association between "turn on" and "open" and "window", and the action-object association between "close" and "window".
[0104] When generating candidate sentence vectors, the model focuses on the core semantic segments of the sentence. Taking "turn on the window" as an example, it generates candidate segment vectors such as "turn on" and "window"; "open the window" generates candidate segment vectors such as "open" and "window"; and "close the window" generates candidate segment vectors such as "close" and "window".
[0105] Next, semantic fusion of sub-words is performed to analyze the semantic importance of sub-words in the candidate segments. In "turn on the window" and "open the window," "turn on" and "open" are the core action words, while "window" is the core object word and is more important than "the." In "close the window," "close" is the core action word, "window" is the core object word, and "the" is secondary. Based on this, weights are assigned to different sub-words, and a weighted average fusion is performed on the sub-word vectors within the candidate segments. Core sub-word vectors have higher weights, and secondary sub-word vectors have lower weights, resulting in the representation vector of the candidate segments, which is the target sentence vector.
[0106] Specifically, the process of configuring corresponding slot value labels for target statement vectors through prototype learning and generating a set of labeled sentence patterns includes: obtaining a predefined prototype vector library, wherein the predefined prototype vector library configures at least one prototype vector for each semantic slot value; performing similarity matching between the target statement vector and the prototype vectors in the predefined prototype vector library; and assigning the slot value label corresponding to the prototype vector with the highest similarity to the target statement vector to form a set of labeled sentence patterns.
[0107] Specifically, this application pre-defines a prototype vector library for the "window control" service, containing prototype vectors for semantic slots such as "action class" and "object class". The prototype vectors for "action class" cover typical semantic features of actions such as "turn on" and "open" that represent "opening", and typical semantic features of actions such as "close" that represent "closing". The prototype vectors for "object class" contain typical semantic features of "window".
[0108] Match the target statement vector with the prototype vector library: the fragment vectors such as "turn on" and "open" have high similarity to the "action class" prototype vector of "open window" and are assigned the slot value label "action_open"; the fragment vector of "close" matches the "action class" prototype vector of "close window" and is assigned the slot value label "action_close"; the fragment vector of "window" matches the "object class" prototype vector and is assigned the slot value label "obj_window".
[0109] The final set of annotation phrases includes: "[action_open:turn on][obj_window:window]", "[action_open:open][obj_window:window]", "[action_close:close][obj_window:window]", etc., completing the generation of the "window control" business annotation phrase set.
[0110] The process of obtaining a predefined prototype vector library includes: segmenting sentences in a text corpus to generate all vectors corresponding to the text corpus; configuring a corresponding prototype vector for each vector in all vectors to obtain all prototype vectors; clustering all prototype vectors to obtain at least one prototype vector corresponding to the same semantic slot value; and constructing a predefined prototype vector library based on at least one prototype vector corresponding to the same semantic slot value.
[0111] Specifically, taking in-vehicle window control as an example, a predefined prototype vector library is built. The specific process is as follows:
[0112] First, prepare a text corpus related to vehicle window control, containing a large amount of voice-transcribed text of user operations on the windows, such as: "Open the driver's side window", "Open the passenger side window", "Close the rear left window", "Open the driver's side window", "Please close the passenger side window", etc.
[0113] Then, these sentences are segmented. A rule-based method is used to break the sentences into semantic segments according to semantic natural breaks. For example, "open the driver's side window" can be segmented into two semantic segments: "open" and "driver's side window"; "open the passenger side window" can be segmented into "open" and "passenger side window"; "close the rear left window" can be segmented into "close" and "rear left window"; "open the driver's side window" can be segmented into "open" and "driver's side window"; and "please close the passenger side window" can be segmented into "close" and "passenger side window".
[0114] Next, a pre-trained language model (such as BERT) is used to encode each semantic segment, generating a corresponding vector. For example, "open" generates one vector, "driver's side window" generates another vector; "open" generates one vector, "passenger's side window" generates another vector, and so on, to obtain all the vectors corresponding to the text corpus.
[0115] Based on business experience and semantic analysis, a corresponding prototype vector is configured for each generated vector. For vectors expressing the "open" action, such as those corresponding to "open," "on," or "start," the prototype vector "action_open" is configured; for vectors expressing the "close" action, such as those corresponding to "close" or "close," the prototype vector "action_close" is configured; and for vectors expressing window positions, such as those corresponding to "driver's side window," "passenger's side window," "rear left window," or "driver's side window," the prototype vector "pos_window_position" is configured. This results in all prototype vectors, including multiple "action_open," "action_close," and "pos_window_position" prototype vectors.
[0116] Clustering algorithms (such as K-Means) are used to cluster all prototype vectors. Prototype vectors related to "action_open" are clustered into one group, prototype vectors related to "action_close" are clustered into another group, and prototype vectors related to "pos_window_position" are clustered into yet another group. Through clustering, at least one prototype vector corresponding to the same semantic slot value is obtained. For example, multiple "action_open" prototype vectors correspond to the "action_open" semantic slot value, multiple "action_close" prototype vectors correspond to the "action_close" semantic slot value, and multiple "pos_window_position" prototype vectors correspond to the "pos_window_position" semantic slot value.
[0117] A predefined prototype vector library is constructed based on at least one prototype vector corresponding to the same semantic slot value. This library contains several semantic slot value categories: "action_open", "action_close", and "pos_window_position". Each category stores the corresponding prototype vector. For example, the "action_open" category stores prototype vectors for "open", "on", and "on"; the "action_close" category stores prototype vectors for "close" and "close"; and the "pos_window_position" category stores prototype vectors for "driver's side window", "passenger's side window", "rear left window", and "driver's side window".
[0118] Step S102: Construct a tree structure for all sentences in the annotated sentence set to obtain all tree structures corresponding to the annotated sentence set.
[0119] To construct the tree structure of all sentences in the labeled sentence set, and to obtain all the tree structures corresponding to the labeled sentence set, it is necessary to divide all sentences in the labeled sentence set to obtain all the tree structures of all sentences.
[0120] like Figure 3 As shown, nodes in the tree structure contain slot labels and attribute sets. The attribute sets include deletability, multiple-choice, and repetition (such as the number of repetitions).
[0121] Specifically, taking "[action_open: open][obj_window: window]" from the set of annotations for vehicle window control services as an example, its tree structure is constructed as follows:
[0122] The sentence structure "[action_open:open][obj_window:window]" can be divided into two parts: "action_open:open" and "obj_window:window".
[0123] The constructed tree structure includes:
[0124] First-level child node 1: The slot value tag is "action_open", the attribute set is {deletability: no (the window opening action is the core and cannot be deleted), multiple selection: yes (multiple action tags such as "action_open" and "action_close" can be selected), repeatability: no (the same action tag cannot be repeated)}, and the child node is "open" (no attribute set, it is a leaf node).
[0125] First-level child node 2: The slot value tag is "obj_window", the attribute set is {deletability: no ("window" is the core object and cannot be deleted), multiple selection: no (the object is fixed as "window", there is no multiple selection case), repeatability: no (the object tag cannot be repeated)}, and the child node is "window" (leaf node).
[0126] In this way, all the sentence patterns in the annotated sentence pattern set are divided to obtain all the corresponding tree structures. Each node of the tree structure contains slot value labels and a set of attributes that specify deletability, multiple choice, and repetition.
[0127] Step S103: Merge all tree structures based on edit distance to obtain the semantics of the text corpus.
[0128] To obtain the semantics of the text corpus by merging all tree structures based on edit distance, it is necessary to first calculate the edit distance between any two tree structures in all tree structures. The edit distance is used to define node deletion, node insertion, and node replacement operations in the tree structure. If the edit distance between any two tree structures is less than a first preset threshold, the two tree structures are merged using preset merging rules to obtain the merged tree structure corresponding to the two tree structures. Then, the merged tree structure corresponding to the two tree structures is counted to obtain the merged sentence set, and the merged sentence set is used as the semantics of the text corpus.
[0129] The first preset threshold can be set according to specific circumstances, and no specific limitation is made here.
[0130] Wherein, any two tree structures include a first tree structure and a second tree structure; calculate the edit distance between any two tree structures in all tree structures, including: dynamically allocating operation costs based on the node attributes of any two tree structures to obtain the operation costs of the first tree structure and the second tree structure; when transforming the first tree structure into the second tree structure, calculate the minimum total operation cost required for the transformation based on the operation costs of the first tree structure and the second tree structure, and use the minimum total operation cost required for the transformation as the edit distance between any two tree structures.
[0131] Specifically, the first tree structure (corresponding to the sentence structure "[action_open:open][obj_window:window]") has the following root node: no slot value tag, serving as the root node for the entire sentence structure. First-level child node 1: slot value tag "action_open", attribute set {deletability: no (core action cannot be deleted), multiple selection: yes (action tags can be selected multiple times), repeatability: no}; child node (leaf node): "open". First-level child node 2: slot value tag "obj_window", attribute set {deletability: no (core object cannot be deleted), multiple selection: no (object is fixed as window), repeatability: no}; child node (leaf node): "window".
[0132] The second tree structure (corresponding to the sentence structure "[action_open:open][obj_window:window]") has the following root node: no slot value tag, serving as the root node for the entire sentence structure. First-level child node 1: slot value tag "action_open", attribute set {deletability: no, multiple choice: yes, repetition: no}; child node (leaf node): "open". First-level child node 2: slot value tag "obj_window", attribute set {deletability: no, multiple choice: no, repetition: no}; child node (leaf node): "window".
[0133] Then, the operation cost is defined according to the node attributes. For example, the cost of replacing leaf nodes under the same slot value label is 0.3, the cost of replacing nodes with different slot value labels is 1, the cost of replacing nodes with "yes" deletability is 0.2, and the cost of replacing nodes with "no" deletability is 1.5.
[0134] Next, we analyze the necessary operations for transforming the first tree structure into the second tree structure:
[0135] Replace the leaf node of "action_open": In the first tree structure, the leaf node of "action_open" is "open", and in the second tree structure, it is "open". Both have the same slot value label "action_open" (same slot value label), which belongs to "replacement of leaf node under the same slot value label", with an operation cost of 0.3.
[0136] Comparison of other nodes: The root node is identical and requires no action. The slot labels, attributes, and leaf node "window" of the "obj_window" node are completely identical and require no action.
[0137] The conversion process only requires performing the first operation mentioned above, with a total cost of: 0.3 (replacement cost) = 0.3
[0138] Therefore, the edit distance between the first tree structure and the second tree structure is 0.3.
[0139] To merge any two tree structures using preset merging rules to obtain the merged tree structure, it is necessary to first obtain the difference type of the two tree structures, and then update the attributes of the difference nodes according to the difference type to obtain the merged tree structure.
[0140] Specifically, based on the difference type, the attributes of the difference nodes are updated, including: if the difference between any two tree structures is node replacement, the difference nodes are merged into a selectable attribute node; if the difference between any two tree structures is node insertion / deletion, the difference nodes are marked as deletable attribute nodes.
[0141] Specifically, such as Figure 4 As shown, taking two tree structures in the vehicle window control business as examples, and combining the node attributes in the figure (can be deleted, multiple selection, number of repetitions, etc.), the process of merging tree structures is explained.
[0142] The first tree structure (corresponding to the sentence structure "(action_open)[the][pos_left](obj_window)") has four child nodes under the root node: $action_open (can be deleted = false, multiple selection = [action_open], number of repetitions = 1), the (can be deleted = false, multiple selection = [the], number of repetitions = 1), $pos_left (can be deleted = true, multiple selection = [pos_left], number of repetitions = 1), and $obj_window (can be deleted = false, multiple selection = [obj_window], number of repetitions = 1).
[0143] The second tree structure (corresponding to the sentence "(action_open)[obj_window]") has two child nodes under the root node: $action_open (can be deleted = false, multiple selection = [action_open], number of repetitions = 1) and $obj_window (can be deleted = false, multiple selection = [obj_window], number of repetitions = 1).
[0144] Comparing the two tree structures, the differences are as follows: the second tree structure lacks the nodes `the` and `$pos_left` from the first tree structure (this is a "node deletion" difference). The nodes `the` and `$pos_left` from the first tree structure are absent from the second tree structure (this is a "node insertion" difference, which appears as insertion from the perspective of the second tree structure).
[0145] Then, update the attribute of the difference node according to the difference type. The difference type is node insertion / deletion. According to the rule "if the difference is node insertion / deletion, then mark the difference node as a node with a deletable attribute"; for the node "the" in the first tree structure (this node does not exist in the second tree structure, so it belongs to the "deletable" difference node): update its "deletable" attribute from false to true; for the node "$pos_left" in the first tree structure (this node does not exist in the second tree structure, so it belongs to the "deletable" difference node): its "deletable" attribute was originally true, so it remains unchanged.
[0146] The merged tree structure retains all nodes from the first tree structure and updates the attributes of the differing nodes:
[0147] Node $action_open: Can be deleted = false, Multiple selection = [action_open], Number of repetitions = 1.
[0148] Node the: Can be deleted = true (after update), Multiple selection = [the], Number of repetitions = 1.
[0149] Node $pos_left: Can be deleted = true, Multiple selection = [pos_left], Number of repetitions = 1.
[0150] Node $obj_window: Can be deleted = false, Select one = [obj_window], Number of repetitions = 1.
[0151] After merging, the "select one" attribute of $action_open is updated to [action_open: open, action_open: start], while other attributes (deleteable = false, repeat count = 1) remain unchanged; the $obj_window node is unchanged, and its attributes remain the same.
[0152] Through the above process, the attributes of the differing nodes are updated according to the difference type (node insertion / deletion or node replacement), and finally the merged tree structure is obtained, realizing the unification and expansion of multi-sentence semantic structure.
[0153] Collect all the sentence patterns corresponding to the merged tree structure to obtain the merged sentence pattern set:
[0154] The merged result of the first tree structure and the second tree structure is: "(action_open)[the][pos_left](obj_window)" "(action_open)[the](obj_window)" "(action_open)[pos_left](obj_window)" "(action_open)(obj_window)" "(action_open)[pos_right](obj_window)" "(action_close)[pos_right](obj_window)" "(action_open)(obj_window)" "(action_close)(obj_window)".
[0155] After removing duplicate sentence structures, the final merged sentence structure set is: "(action_open)[the][pos_left](obj_window)" "(action_open)[the](obj_window)" "(action_open)[pos_left](obj_window)" "(action_open)(obj_window)" "(action_open)[pos_right](obj_window)" "(action_close)[pos_right](obj_window)" "(action_close)(obj_window)".
[0156] In one embodiment, the method further includes: receiving a new set of sentence patterns and obtaining a target sentence pattern from the new set of sentence patterns; traversing the merged set of sentence patterns, calculating the distance between the sentence patterns in the merged set of sentence patterns and the target sentence pattern, and obtaining a distance set; selecting the minimum distance from the distance set; if the minimum distance meets a second preset threshold, merging the target sentence pattern into the sentence pattern in the merged set of sentence patterns corresponding to the minimum distance according to a preset merging rule; if the minimum distance does not meet the second preset threshold, merging the target sentence pattern into the merged set of sentence patterns.
[0157] The second preset threshold can be set according to specific circumstances, and no specific limitation is made here.
[0158] Specifically, such as Figure 5 As shown, the system first receives a new set of sentence patterns and obtains the target sentence pattern. The new set of sentence patterns includes: "(action_open)[pos_middle](obj_window)" and "(action_close)[pos_middle](obj_window)".
[0159] Then, the target sentence pattern is obtained from the new sentence pattern set. First, “(action_open)[pos_middle](obj_window)” is taken as the first target sentence pattern.
[0160] Suppose that the initial set of phrases after merging contains: "(action_open)[the][pos_left](obj_window)", "(action_open)(obj_window)", and "(action_close)(obj_window)".
[0161] Traverse the merged sentence set and calculate the distance between the target sentence "(action_open)[pos_middle](obj_window)" and each sentence in the set (here, a tree structure is used to edit the distance, as calculated in the previous method. Assume the distance calculation results are: the distance with "(action_open)[the][pos_left](obj_window)" is 1.2; the distance with "(action_open)(obj_window)" is 0.8; and the distance with "(action_close)(obj_window)" is 1.5), resulting in the distance set {1.2, 0.8, 1.5}.
[0162] Select the minimum distance of 0.8 from the distance set. Assuming the second preset threshold is 1.0, 0.8 is less than 1.0, thus satisfying the second preset threshold.
[0163] According to the preset merging rules (if the difference is node replacement, merge into a selectable attribute node; if the difference is node insertion / deletion, mark it as a deletable attribute node), the target sentence "(action_open)[pos_middle](obj_window)" is merged into the sentence "(action_open)(obj_window)" corresponding to the minimum distance. After merging, in the tree structure corresponding to "(action_open)(obj_window)", the "selectable" attribute of the position node is updated to include "pos_left" and "pos_middle", and the deletable attribute of "pos_left" and "pos_middle" is "true". The merged sentence can be represented as "(action_open)[pos_left / pos_middle](obj_window)" (while implicitly including variations such as "(action_open)(obj_window)"). The merged sentence is then updated in the merged sentence set.
[0164] Next, retrieve the second target sentence pattern "(action_close)[pos_middle](obj_window)" from the new sentence pattern set. Iterate through the current merged sentence pattern set (which already contains the updated "(action_open)[pos_left / pos_middle](obj_window)", etc.), calculate the distance between the target sentence pattern and each sentence pattern in the set (assuming the distance to "(action_close)(obj_window)" is 0.7, and the distance to other sentence patterns is greater than 0.7), and obtain the distance set, with the minimum distance being 0.7.
[0165] If the second preset threshold is still 1.0, and 0.7 satisfies the threshold, merge “(action_close)[pos_middle](obj_window)” into “(action_close)(obj_window)”. After merging, the position node in the tree structure corresponding to “(action_close)(obj_window)” will have “pos_middle” in its “multiple selection” attribute, and the deletable attribute will be “true”. The merged sentence will be “(action_close)[pos_middle](obj_window)” (implying a variant of “(action_close)(obj_window)”), and the merged sentence set will be updated.
[0166] If the new target sentence is “(action_open)[pos_rear](obj_window)”, traverse the merged sentence set and calculate the minimum distance as 1.2. If the second preset threshold is 1.0 and 1.2 does not meet the threshold, then “(action_open)[pos_rear](obj_window)” will be directly added to the merged sentence set.
[0167] Through the above process, sentences from new sentence sets are continuously merged into existing merged sentence sets, achieving dynamic updates and optimization of sentence sets. This allows the merged sentence sets to more comprehensively and accurately represent the semantics of the vehicle window control business.
[0168] Step S104: If the semantics of the corpus do not meet the preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus.
[0169] In one embodiment, if the semantics of the corpus do not meet the preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus. This includes: if the semantics of the corpus is erroneous text corpus, calculating the similarity between the vectors in the erroneous text corpus and the prototype vectors in the predefined prototype vector library through an adaptive distance metric, obtaining the similarity result, and correcting the semantics of the corpus based on the similarity result to obtain the corrected semantics of the corpus.
[0170] Specifically, based on the similarity results, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus. This includes: if the erroneous text corpus includes new text corpus, the semantics of the corpus are corrected by matching a predefined prototype vector library to obtain the corrected semantics of the corpus; if the erroneous text corpus includes new sentence patterns, the semantics of the corpus are corrected by matching a preset sentence pattern library to obtain the corrected semantics of the corpus.
[0171] Specifically, such as Figure 6 As shown, assuming there are erroneous text corpora, the semantics of the corpora that do not meet the preset conditions need to be corrected.
[0172] The erroneous text corpus is "open the passenger side window". The semantics of this corpus do not meet the default specification of the semantics related to "window" in the vehicle window control business (the default is to use "window" instead of "glass" to describe the core object).
[0173] The predefined prototype vector library includes prototype vectors such as "action_open" (corresponding to actions such as "open" and "start"), "pos_co_driver" (corresponding to the "passenger seat"), and "obj_window" (corresponding to the "window"); the preset sentence library includes sentences such as "(action_open)[pos_co_driver](obj_window)".
[0174] The erroneous text corpus "Open the passenger side window" is encoded into a vector. An adaptive distance metric (such as a hybrid metric combining semantic similarity and edit distance) is used to calculate the similarity between this vector and each prototype vector in a predefined prototype vector library: the similarity with the "action_open" prototype vector is 0.9 ("open" and "open" are semantically similar); the similarity with the "pos_co_driver" prototype vector is 0.85 ("passenger side" is consistent with the expression "passenger side" in the prototype library); and the similarity with the "obj_window" prototype vector is 0.3 ("glass" and "window" have semantic differences but are related).
[0175] Then, the semantics of the corpus are corrected based on the similarity results.
[0176] Scenario 1: The erroneous text corpus contains new text corpus (“glass” is a new expression). By matching the predefined prototype vector library, a certain similarity (0.3) was found between the prototype vectors of “glass” and “obj_window”, indicating that the two are semantically related. Therefore, “glass” in the erroneous text corpus was corrected to “window”, resulting in the corrected corpus “open the passenger window”, whose corresponding semantics are consistent with the combined semantics of “action_open”, “pos_co_driver”, and “obj_window” in the prototype vector library.
[0177] Scenario 2: The erroneous text corpus contains a new sentence structure (assuming the erroneous sentence structure is "passenger side window open", which differs from the preset sentence structure "(action_open)[pos_co_driver](obj_window)"). By matching the preset sentence structure library, the structure of "passenger side window open" differs from "(action_open)[pos_co_driver](obj_window)", but the core semantic elements (action, location, object) correspond. The new sentence structure is adjusted to match the preset sentence structure library, i.e., "(action_open)[pos_co_driver](obj_window)", and combined with text correction, the corrected corpus is obtained as "open passenger side window", making its sentence structure and text conform to the preset specifications, and the corresponding corpus semantics are also consistent with the preset vehicle window control business semantics.
[0178] In this way, whether the erroneous text corpus contains new text or new sentence structures, the semantics of the corpus can be corrected based on the similarity results, using prototype vector libraries or sentence structure libraries, to obtain corrected semantics that meet business needs.
[0179] This application provides a semantic generation method, comprising: first, generating a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model; then, constructing a tree structure of all sentence patterns in the annotated sentence pattern set to obtain all tree structures corresponding to the annotated sentence pattern set; and finally, merging all tree structures based on edit distance to obtain the semantics of the text corpus. If the semantics of the corpus do not meet preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus. This application generates a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model, improving annotation efficiency. Furthermore, by constructing a tree structure of all sentence patterns in the annotated sentence pattern set, the sentence patterns are clearly presented, facilitating the merging of all tree structures based on edit distance, making the merged tree structure more accurate, thereby improving the accuracy of the obtained semantics of the corpus.
[0180] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0181] The following are device embodiments of this application. For details not described in detail, please refer to the corresponding method embodiments described above.
[0182] Figure 7 This diagram illustrates a semantic generation apparatus according to an embodiment of this application. For ease of explanation, only the parts relevant to the embodiment of this application are shown. The semantic generation apparatus includes:
[0183] The annotation module 701 is used to generate a set of annotated sentence patterns corresponding to the text corpus of vehicle services through a sequence annotation model;
[0184] Module 702 is used to construct the tree structure of all sentences in the annotated sentence set, and obtain all tree structures corresponding to the annotated sentence set;
[0185] The merging module 703 is used to merge all tree structures based on edit distance to obtain the semantics of the text corpus;
[0186] The correction module 704 is used to correct the semantics of the corpus if the semantics of the corpus does not meet the preset conditions, so as to obtain the corrected semantics of the corpus.
[0187] In one embodiment, the annotation module 701 is further configured to receive text corpus of in-vehicle services, wherein sentences in the text corpus are associated with service classification tags;
[0188] Encode the text corpus to obtain the corresponding corpus vector;
[0189] By mapping corpus vectors to semantic space through a pre-trained language model, the target sentence vectors corresponding to the corpus vectors are obtained.
[0190] By learning from prototypes, corresponding slot labels are configured for the target statement vectors, generating a set of annotated sentence patterns.
[0191] In one embodiment, the annotation module 701 is further configured to process the corpus vectors to generate candidate sentence vectors;
[0192] The semantic information of the sub-word vectors in the candidate sentence vectors is fused by the weighted average method to obtain the representation vector of the candidate sentence vector, and the representation vector of the candidate sentence vector is used as the target sentence vector.
[0193] In one embodiment, the annotation module 701 is further configured to obtain a predefined prototype vector library, wherein the predefined prototype vector library configures at least one prototype vector for each semantic slot value;
[0194] Perform similarity matching between the target statement vector and the prototype vectors in the predefined prototype vector library;
[0195] Assign slot labels to the prototype vectors with the highest similarity to the target sentence vectors to form a set of labeled sentence patterns.
[0196] In one embodiment, the annotation module 701 is further used to segment sentences in the text corpus and generate all vectors corresponding to the text corpus;
[0197] Configure a corresponding prototype vector for each of all vectors to obtain all prototype vectors;
[0198] Cluster all prototype vectors to obtain at least one prototype vector corresponding to the same semantic slot value;
[0199] A predefined prototype vector library is constructed based on at least one prototype vector corresponding to the same semantic slot value.
[0200] In one embodiment, the construction module 702 is further configured to segment all sentences in the labeled sentence set to obtain all tree structures of all sentences, wherein the nodes in the tree structure contain slot value labels and attribute sets, and the attribute sets include deletability, multiple-choice, and repetition.
[0201] In one embodiment, the merging module 703 is further configured to calculate the edit distance between any two tree structures in all tree structures, wherein the edit distance is used to define node deletion operations, node insertion operations, and node replacement operations in the tree structure;
[0202] If the edit distance between any two tree structures in all tree structures is less than the first preset threshold, the two tree structures are merged using the preset merging rules to obtain the merged tree structure corresponding to the two tree structures.
[0203] By statistically analyzing the merged tree structures corresponding to any two tree structures, a set of merged sentence patterns is obtained, and this set of merged sentence patterns is used as the semantic data of the text corpus.
[0204] In one embodiment, any two tree structures include a first tree structure and a second tree structure;
[0205] The merging module 703 is also used to dynamically allocate operation costs based on the node attributes of any two tree structures, to obtain the operation costs of the first tree structure and the second tree structure:
[0206] When transforming the first tree structure into the second tree structure, the minimum total operation cost required for the transformation is calculated based on the operation cost of the first tree structure and the operation cost of the second tree structure, and the minimum total operation cost required for the transformation is used as the edit distance between any two tree structures.
[0207] In one embodiment, the merging module 703 is further configured to obtain the difference type between any two tree structures;
[0208] Based on the difference type, update the attributes of the difference nodes to obtain the merged tree structure corresponding to any two tree structures.
[0209] In one embodiment, the merging module 703 is further configured to merge the differing nodes into a multi-select attribute node if the difference between any two tree structures is a node replacement.
[0210] If the difference between any two tree structures is node insertion / deletion, then the difference node is marked as a node with deletable attributes.
[0211] In one embodiment, it further includes: a traversal module, which is used to receive a new set of sentence patterns and obtain the target sentence pattern from the new set of sentence patterns;
[0212] Traverse the merged sentence set, calculate the distance between the sentence in the merged sentence set and the target sentence, and obtain the distance set;
[0213] Select the minimum distance from the set of distances;
[0214] If the minimum distance meets the second preset threshold, the target sentence is merged into the sentence in the merged sentence set corresponding to the minimum distance according to the preset merging rules;
[0215] If the minimum distance does not meet the second preset threshold, the target sentence will be merged into the merged sentence set.
[0216] In one embodiment, the correction module 704 is further configured to, if the semantics of the corpus are erroneous text corpus, calculate the similarity between the vectors in the erroneous text corpus and the prototype vectors in the predefined prototype vector library through an adaptive distance metric, and obtain the similarity result;
[0217] Based on the similarity results, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus.
[0218] In one embodiment, the correction module 704 is further configured to, if the erroneous text corpus includes new text corpus, correct the semantics of the corpus by matching it with a predefined prototype vector library to obtain the corrected semantics of the corpus;
[0219] If the erroneous text corpus includes new sentence structures, the semantics of the corpus are corrected by matching it against a pre-defined sentence structure library to obtain the corrected semantics of the corpus.
[0220] This application provides a semantic generation apparatus, specifically used for: firstly generating a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model; then constructing a tree structure of all sentence patterns in the annotated sentence pattern set to obtain all tree structures corresponding to the annotated sentence pattern set; and finally merging all tree structures based on edit distance to obtain the semantics of the text corpus. If the semantics of the corpus do not meet preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus. This application generates a set of annotated sentence patterns corresponding to the text corpus of vehicle-mounted services using a sequence annotation model, improving annotation efficiency. Furthermore, by constructing a tree structure of all sentence patterns in the annotated sentence pattern set, the sentence patterns are clearly presented, facilitating the merging of all tree structures based on edit distance, making the merged tree structure more accurate, thereby improving the accuracy of the obtained semantics of the corpus.
[0221] This application Figure 8 A schematic diagram of a computer device is provided. (Example) Figure 8 As shown, the computer device 8 in this embodiment includes a processor 801, a memory 802, and a computer program 803 stored in the memory 802 and executable on the processor 801. When the processor 801 executes the computer program 803, it implements the steps in the various semantic generation method embodiments described above, for example... Figure 1 Steps 101 to 104 are shown. Alternatively, when processor 801 executes computer program 803, it implements the functions of each module / unit in the above-described semantic generation device embodiments, for example... Figure 7 The functions of modules / units 701 to 704 shown.
[0222] This application also provides a readable storage medium storing a computer program, which, when executed by a processor, is used to implement the semantic generation methods provided in the various embodiments described above.
[0223] The readable storage medium can be a computer storage medium or a communication medium. A communication medium includes any medium that facilitates the transfer of computer programs from one location to another. A computer storage medium can be any available medium accessible to a general-purpose or special-purpose computer. For example, a readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application-Specific Integrated Circuit (ASIC). Alternatively, the ASIC can be located in a user device. Of course, the processor and the readable storage medium can also exist as discrete components in a communication device. The readable storage medium can be a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0224] This application also provides a program product including executable instructions stored in a readable storage medium. At least one processor of the device can read the executable instructions from the readable storage medium, and executing the executable instructions causes the device to implement the semantic generation methods provided in the various embodiments described above.
[0225] In the embodiments of the above-described device, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0226] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A semantic generation method, characterized in that, include: A set of annotated sentence patterns corresponding to the text corpus of in-vehicle services is generated through a sequence annotation model; Construct a tree structure for all sentences in the labeled sentence set to obtain all tree structures corresponding to the labeled sentence set; The semantics of the text corpus are obtained by merging all the tree structures based on the edit distance; If the semantics of the corpus do not meet the preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus.
2. The semantic generation method as described in claim 1, characterized in that, The set of annotated sentence patterns corresponding to the text corpus of in-vehicle services generated by the sequence annotation model includes: Receive the text corpus of the in-vehicle service, wherein the sentences in the text corpus are associated with service classification tags; The text corpus is encoded to obtain the corpus vector corresponding to the text corpus; The corpus vectors are mapped to the semantic space by a pre-trained language model to obtain the target sentence vectors corresponding to the corpus vectors; By using prototype learning, corresponding slot value labels are configured for the target statement vector, and the annotated statement set is generated.
3. The semantic generation method as described in claim 2, characterized in that, The step of mapping the corpus vectors to the semantic space through a pre-trained language model to obtain the target sentence vectors corresponding to the corpus vectors includes: The corpus vectors are processed to generate candidate sentence vectors; The semantic information of the sub-word vectors in the candidate sentence vector is fused using a weighted average method to obtain the representation vector of the candidate sentence vector, and the representation vector of the candidate sentence vector is used as the target sentence vector.
4. The semantic generation method as described in claim 2, characterized in that, The step of configuring corresponding slot value labels for the target statement vector through prototype learning and generating the labeled sentence set includes: Obtain a predefined prototype vector library, wherein the predefined prototype vector library configures at least one prototype vector for each semantic slot value; The target statement vector is matched with the prototype vectors in the predefined prototype vector library based on similarity. Assign slot labels to the prototype vectors with the highest similarity to the target sentence vectors to form the annotated sentence set.
5. The semantic generation method as described in claim 4, characterized in that, The process of obtaining a predefined prototype vector library includes: Segment the sentences in the text corpus to generate all vectors corresponding to the text corpus; Configure a corresponding prototype vector for each of the vectors to obtain all prototype vectors; Cluster all the prototype vectors to obtain at least one prototype vector corresponding to the same semantic slot value; The predefined prototype vector library is constructed based on at least one prototype vector corresponding to the same semantic slot value.
6. The semantic generation method as described in claim 1, characterized in that, The construction of a tree structure for all sentences in the labeled sentence set yields all tree structures corresponding to the labeled sentence set, including: All sentence patterns in the labeled sentence pattern set are segmented to obtain all tree structures of all sentence patterns. The nodes in the tree structure contain slot value labels and attribute sets, and the attribute sets include deletability, multiple-choice, and repetition.
7. The semantic generation method as described in claim 1, characterized in that, The merging of all tree structures based on edit distance to obtain the semantics of the text corpus includes: Calculate the edit distance between any two tree structures in all the tree structures, wherein the edit distance is used to define node deletion operation, node insertion operation, and node replacement operation in the tree structure; If the edit distance between any two tree structures in all the tree structures is less than a first preset threshold, the two tree structures are merged using a preset merging rule to obtain the merged tree structure corresponding to the two tree structures. By statistically analyzing the merged tree structures corresponding to any two tree structures, a merged sentence structure set is obtained, and this merged sentence structure set is used as the semantic data of the text corpus.
8. The semantic generation method as described in claim 7, characterized in that, The two tree structures include the first tree structure and the second tree structure; The calculation of the edit distance between any two tree structures in all the tree structures includes: Based on the node attributes of any two tree structures, the operation cost is dynamically allocated to obtain the operation cost of the first tree structure and the operation cost of the second tree structure: When transforming the first tree structure into the second tree structure, the minimum total operation cost required for the transformation is calculated based on the operation cost of the first tree structure and the operation cost of the second tree structure, and the minimum total operation cost required for the transformation is used as the edit distance between any two tree structures.
9. The semantic generation method as described in claim 7, characterized in that, The step of merging any two tree structures using preset merging rules to obtain the merged tree structure corresponding to the two tree structures includes: Obtain the difference type between any two tree structures; Based on the difference type, update the attributes of the difference nodes to obtain the merged tree structure corresponding to any two tree structures.
10. The semantic generation method as described in claim 9, characterized in that, The step of updating the attributes of the difference node according to the difference type includes: If the difference between any two tree structures is node replacement, then the difference nodes are merged into a multi-select attribute node; If the difference between any two tree structures is node insertion / deletion, then the difference node is marked as a node with deletable attributes.
11. The semantic generation method as described in claim 7, characterized in that, Also includes: Receive a new set of sentence patterns and obtain the target sentence pattern from the new set of sentence patterns; Traverse the merged sentence set, calculate the distance between the sentence in the merged sentence set and the target sentence, and obtain the distance set; Select the minimum distance from the set of distances; If the minimum distance meets the second preset threshold, the target sentence pattern is merged into the sentence pattern in the merged sentence pattern set corresponding to the minimum distance according to the preset merging rule; If the minimum distance does not meet the second preset threshold, the target sentence pattern is merged into the merged sentence pattern set.
12. The semantic generation method as described in claim 1, characterized in that, If the semantics of the corpus do not meet the preset conditions, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus, including: If the semantics of the corpus are erroneous text corpus, the similarity between the vectors in the erroneous text corpus and the prototype vectors in the predefined prototype vector library is calculated using an adaptive distance metric to obtain the similarity result; Based on the similarity results, the semantics of the corpus are corrected to obtain the corrected semantics of the corpus.
13. The semantic generation method as described in claim 12, characterized in that, The step of correcting the semantics of the corpus based on the similarity results to obtain the corrected semantics of the corpus includes: If the erroneous text corpus includes new text corpus, the semantics of the corpus are corrected by matching it against a predefined prototype vector library to obtain the corrected semantics of the corpus. If the erroneous text corpus includes new sentence structures, the semantics of the corpus are corrected by matching a preset sentence structure library to obtain the corrected semantics of the corpus.
14. A semantic generation device, characterized in that, include: The annotation module is used to generate a set of annotated sentence patterns corresponding to the text corpus of in-vehicle services through a sequence annotation model; The construction module is used to construct the tree structure of all sentences in the labeled sentence set, thereby obtaining all tree structures corresponding to the labeled sentence set; The merging module is used to merge all the tree structures based on the edit distance to obtain the semantics of the text corpus; The correction module is used to correct the semantics of the corpus if the semantics of the corpus does not meet the preset conditions, so as to obtain the corrected semantics of the corpus.
15. A computer device, characterized in that, Includes a memory, and one or more processors communicatively connected to the memory; The memory stores instructions that can be executed by the one or more processors to cause the one or more processors to implement the semantic generation method as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that, Includes a program or instructions that, when run on a computer, implement the semantic generation method of any one of claims 1 to 13.
17. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the semantic generation method according to any one of claims 1 to 13.