Chinese fluency detection method and device, electronic equipment and readable medium
By combining the two-way representation model and the expert model, the combination method of dealing with the two-way representation model and the expert model of Chinese text is solved, and a more accurate Chinese smoothness detection is achieved.
Patent Information
- Application Number
- CN202411814934.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-10
AI Technical Summary
The existing Chinese smoothness detection technology has low accuracy and is difficult to effectively detect the ambiguity, ambiguity, diversity and complexity of grammatical errors, as well as the diversity and uncertainty of grammatical rules.
Using a combination of a two-way representation model and an expert model, the text to be detected is processed sequentially through at least two layers of encoders, vector information is extracted, and these vector information is processed through an expert model to obtain Chinese smoothness detection results.
The accuracy of Chinese smoothness detection is improved, and the Chinese smoothness of text can be analyzed based on the characteristics output by encoders at different levels at the same time, thereby more accurately detecting the syntax and semantic structure of text.
Smart Images

Figure CN119830898A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a Chinese fluency detection method, a Chinese fluency detection device, an electronic device and a computer-readable medium. Background Art
[0002] Chinese fluency testing is mainly used in academic reports, emails, speeches and various Internet writing scenarios. It evaluates the fluency of texts through multiple aspects such as grammar and semantics. It helps authors to locate grammatical errors and inaccurate expressions in a timely and accurate manner, and improve the fluency and readability of texts.
[0003] In the prior art, traditional Chinese fluency detection mainly involves the detection of Chinese grammatical rules. It is difficult to detect correct results due to the polysemy and ambiguity of the language, the diversity and complexity of grammatical errors, and the diversity and uncertainty of grammatical rules. Summary of the invention
[0004] The embodiment of the present invention provides a Chinese fluency detection method, device, electronic device and computer-readable storage medium to solve the problem of low accuracy in Chinese fluency detection.
[0005] The embodiment of the present invention discloses a method for detecting fluency of Chinese, comprising:
[0006] Get the text to be detected;
[0007] Inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0008] Processing the to-be-detected text in sequence through at least two layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least two layers of encoders;
[0009] The vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0010] Optionally, the step of sequentially processing the text to be detected by at least two layers of encoders in the bidirectional representation model and extracting vector information respectively output by the at least two layers of encoders includes:
[0011] Dividing at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder;
[0012] Processing the to-be-detected text in sequence by at least three layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least three layers of encoders;
[0013] Merging at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0014] Merging at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar;
[0015] At least one vector information corresponding to the output of the underlying encoder is merged to obtain underlying vector information representing the text structure.
[0016] Optionally, the method further comprises:
[0017] Inputting the text to be detected into a preset gate control system, and obtaining weight information output by the gate control system;
[0018] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0019] Based on the weight information, the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0020] Optionally, the step of inputting the to-be-detected text into a preset gate control system and acquiring weight information output by the gate control system includes:
[0021] After performing word segmentation processing on the text to be detected, a word segmentation sequence is obtained; the word segmentation sequence includes at least one word segmentation;
[0022] Performing part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence;
[0023] Performing dependency syntactic analysis on the text to be detected to obtain syntactic analysis structure information;
[0024] Identify whether there is a grammatical problem in the text to be detected, and determine a grammatical score corresponding to the text to be detected;
[0025] At least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score is input into a preset gating system to obtain weight information output by the gating system.
[0026] Optionally, the expert model includes at least two,
[0027] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0028] For any of the expert models, determining at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders;
[0029] Based on the weight information and the target vector information corresponding to the expert model, respectively determine the weights corresponding to the expert models;
[0030] Processing the target vector information through the expert model to obtain expert model output features;
[0031] Based on the weights corresponding to the expert models, the expert model output features output by at least two of the expert models are combined to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0032] Optionally, the method further comprises:
[0033] Acquire a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts;
[0034] The training sample set is used to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0035] Optionally, the method further comprises:
[0036] Get fluent text;
[0037] The fluent text is adjusted in character granularity and / or word granularity to obtain a grammatically incorrect text;
[0038] Determine Chinese fluency detection information corresponding to the grammatically incorrect text;
[0039] The grammatically incorrect text and Chinese fluency detection information corresponding to the grammatically incorrect text are used to generate negative training samples.
[0040] The embodiment of the present invention further provides a Chinese fluency detection device, comprising:
[0041] A module for acquiring text to be detected, used for acquiring text to be detected;
[0042] A text input module, used for inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0043] A bidirectional representation model processing module, used to sequentially process the text to be detected through at least two layers of encoders in the bidirectional representation model, and extract vector information respectively output by the at least two layers of encoders;
[0044] The expert model processing module is used to process the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0045] Optionally, the bidirectional representation model processing module includes:
[0046] An encoder division submodule, used to divide at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder;
[0047] A vector information output submodule, used to process the to-be-detected text in sequence through at least three layers of encoders in the bidirectional representation model, and extract vector information respectively output by the at least three layers of encoders;
[0048] A top-level vector acquisition module, used to merge at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0049] A middle-level vector acquisition module, used to merge at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar;
[0050] The bottom-level vector acquisition module is used to merge at least one vector information corresponding to the output of the bottom-level encoder to obtain the bottom-level vector information representing the text structure.
[0051] Optionally, the device further comprises:
[0052] A weight information acquisition module, used to input the text to be detected into a preset gate control system, and obtain the weight information output by the gate control system;
[0053] The expert model processing module includes:
[0054] The fluency detection submodule is used to process the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0055] Optionally, the weight information acquisition module includes:
[0056] A word segmentation submodule is used to obtain a word segmentation sequence after performing word segmentation processing on the text to be detected; the word segmentation sequence includes at least one word segmentation;
[0057] A part-of-speech tagging submodule is used to perform part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence;
[0058] The syntax analysis submodule is used to perform dependency syntax analysis on the text to be detected to obtain syntax analysis structure information;
[0059] A grammatical problem identification submodule is used to identify whether there are grammatical problems in the text to be detected and determine the grammatical score corresponding to the text to be detected;
[0060] The weight information acquisition submodule is used to input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score into a preset gating system to obtain the weight information output by the gating system.
[0061] Optionally, the expert model includes at least two,
[0062] The fluency detection submodule includes:
[0063] a target vector determination unit, configured to determine, for any of the expert models, at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders;
[0064] A weight determination unit, used to determine the weights corresponding to the expert models based on the weight information and the target vector information corresponding to the expert models;
[0065] An output feature acquisition unit, used for processing the target vector information through the expert model to obtain an expert model output feature;
[0066] The fluency detection unit is used to combine the expert model output features output by at least two of the expert models based on the weights corresponding to the expert models to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0067] Optionally, the device further comprises:
[0068] A training sample set acquisition module, used to acquire a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts;
[0069] The training module is used to use the training sample set to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0070] Optionally, the device further comprises:
[0071] A fluent text acquisition module is used to acquire fluent text;
[0072] A grammatically incorrect text acquisition module is used to adjust the fluent text in character granularity and / or word granularity to obtain a grammatically incorrect text;
[0073] A fluency detection information acquisition module is used to determine the Chinese fluency detection information corresponding to the linguistically incorrect text;
[0074] The negative training sample acquisition module is used to generate negative training samples by using the grammatically incorrect text and the Chinese fluency detection information corresponding to the grammatically incorrect text.
[0075] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0076] The memory is used to store computer programs;
[0077] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0078] The embodiment of the present invention further discloses one or more computer-readable media on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.
[0079] The embodiments of the present invention include the following advantages:
[0080] The Chinese fluency detection method provided by the embodiment of the present invention obtains a text to be detected; inputs the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model; the text to be detected is processed in sequence by at least two layers of encoders in the bidirectional representation model, and vector information respectively output by the at least two layers of encoders is extracted; the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected. Thus, the Chinese fluency detection result can be analyzed based on the vector information respectively output by at least two layers of encoders in the bidirectional representation model, so that in the process of Chinese fluency detection, the features output by encoders at different levels can be considered at the same time, so that the Chinese fluency of the text can be analyzed based on different language structure dimensions at the same time, thereby improving the accuracy of Chinese fluency detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] Figure 1 is a flowchart of a method for detecting Chinese fluency provided in an embodiment of the present invention;
[0082] Figure 2 is a schematic diagram of a Chinese fluency detection model provided in an embodiment of the present invention;
[0083] Figure 3 is a structural block diagram of a Chinese fluency detection device provided in an embodiment of the present invention;
[0084] Figure 4 is a block diagram of an electronic device provided in an embodiment of the present invention;
[0085] Figure 5 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0086] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0087] Reference Figure 1 , shows a flowchart of a Chinese fluency detection method provided in an embodiment of the present invention, which may specifically include the following steps:
[0088] Step 101, obtaining the text to be detected;
[0089] In the embodiment of the present invention, Chinese fluency detection can be a method for evaluating the fluency of Chinese text, including detection of grammar and semantics. It is mainly used to determine whether a Chinese text is fluent, natural, and whether there are any problems such as false pronunciation and typos. It is mainly used for text detection in various writing scenarios to quickly find problems and improve the quality and readability of the text.
[0090] Specifically, when the fluency of Chinese in a text needs to be detected, the text to be detected can be obtained. The text to be detected can include at least one Chinese character.
[0091] Step 102, inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0092] In order to detect the Chinese fluency of the text, a Chinese fluency detection model can be set. The Chinese fluency detection model can include a bidirectional representation model (Bidirectional Encoder Representations from Transformers, BERT) and an expert model (Expert Models). Among them, the bidirectional representation model can be used to extract vector information from the text to be detected, and the patent network model can be used to analyze the extracted vector information and output the Chinese fluency detection result.
[0093] Step 103, sequentially processing the to-be-detected text through at least two layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least two layers of encoders;
[0094] In an embodiment of the present invention, the bidirectional representation model may include at least two layers of encoders, the encoders may be connected in sequence, the text to be detected may pass through the encoders in sequence, the first layer of encoders may take the text to be detected as input, perform feature extraction, and output vector information of the current layer. Thereafter, each layer of encoders may obtain the vector information output by the previous layer, perform feature extraction, and output the vector information of the current layer. Thus, each layer of encoders may output vector information respectively.
[0095] Generally speaking, feature extraction only needs to obtain the vector information output by the last layer of encoder. However, in the embodiment of the present invention, it is considered that the vector information output by different layers of encoding layers can focus on representing different language structure dimensions. Among them, the language structure dimensions can include text structure, text grammar, text semantics, etc. For example, the vector information output by some encoding layers can focus on representing text structure, the vector information output by some encoding layers can focus on representing text grammar, and the vector information output by some encoding layers can focus on representing text language.
[0096] Therefore, in the embodiment of the present invention, vector information respectively output by at least two layers of encoders can be extracted simultaneously to analyze the Chinese fluency of the text to be processed from different language structure dimensions.
[0097] Step 104, processing the vector information respectively output by the at least two layers of encoders through the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0098] In a specific implementation, the vector information respectively output by at least two layers of encoders can be input into the expert model, and the expert model can process the vector information respectively output by at least two layers of encoders to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0099] The Chinese fluency detection method provided by the embodiment of the present invention obtains a text to be detected; inputs the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model; the text to be detected is processed in sequence by at least two layers of encoders in the bidirectional representation model, and vector information respectively output by the at least two layers of encoders is extracted; the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected. Thus, the Chinese fluency detection result can be analyzed based on the vector information respectively output by at least two layers of encoders in the bidirectional representation model, so that in the process of Chinese fluency detection, the features output by encoders at different levels can be considered at the same time, so that the Chinese fluency of the text can be analyzed based on different language structure dimensions at the same time, thereby improving the accuracy of Chinese fluency detection.
[0100] In one embodiment of the present invention, the step of sequentially processing the text to be detected by at least two layers of encoders in the bidirectional representation model and extracting vector information respectively output by the at least two layers of encoders includes:
[0101] S11, dividing at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder;
[0102] In a specific implementation, the bidirectional representation model may include at least three layers of encoders, and the at least three layers of encoders may be divided into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder according to the positions of different encoders in the bidirectional representation model. The top-layer encoder, the middle-layer encoder, and the bottom-layer encoder may include one or more encoders, respectively. Thus, the encoders in the bidirectional representation model may be divided into three categories.
[0103] In an embodiment of the present invention, by analyzing and understanding the internal representation of a bidirectional representation model (such as BERT) through t-SNE (t-Distributed Stochastic NeighborEmbedding) visualization and probe task (Probe Task), it can be learned that the vector information output by the bottom encoder in the bidirectional representation model may tend to express text structure information, the vector information output by the middle encoder may tend to express text grammar information, and the top encoder may tend to express text semantic information. The text structure information, text grammar information, and text semantic information can all be important reference information in the detection of Chinese fluency. Thus, the vectors output by the top encoder, the middle encoder, and the bottom encoder can be obtained at the same time, so that the subsequent comprehensive text structure information, text grammar information, and text semantic information can be used to detect Chinese fluency.
[0104] S12, sequentially processing the to-be-detected text through at least three layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least three layers of encoders;
[0105] In an embodiment of the present invention, the text to be detected can pass through the encoder in sequence, and the first layer of encoder can take the text to be detected as input, perform feature extraction, and output the vector information of the current layer. Thereafter, each layer of encoder can obtain the vector information output by the previous layer, perform feature extraction, and output the vector information of the current layer. Thus, each layer of encoder can output vector information respectively. Thus, the vector information output by at least three layers of encoders can be extracted.
[0106] S13, merging at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0107] In a specific implementation, vector information output by at least one encoder in the top-level encoder is obtained and the vector information is merged, so as to obtain top-level vector information representing the semantics of the text.
[0108] S14, merging at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar;
[0109] In a specific implementation, vector information output by at least one encoder in a middle-level encoder is obtained and the vector information is merged, thereby obtaining middle-level vector information representing the grammar of the text.
[0110] S15, merging at least one vector information corresponding to the output of the underlying encoder to obtain underlying vector information representing the text structure.
[0111] In a specific implementation, vector information output by at least one encoder in the underlying encoder is obtained and the vector information is merged, so as to obtain underlying vector information representing the text structure.
[0112] In one embodiment of the present invention, the method further comprises:
[0113] S21, inputting the text to be detected into a preset gate control system, and obtaining weight information output by the gate control system;
[0114] In an embodiment of the present invention, in order to further improve the accuracy of Chinese fluency detection, the text to be detected can be pre-detected to find out that the text to be detected may have abnormal language structure dimensions, and in the process of controlling the expert model to determine the Chinese fluency detection result corresponding to the text to be detected, the language structure dimensions that may have abnormalities can be analyzed in detail.
[0115] Therefore, a gating system can be set up, which can be used to output weight information of the expert model based on the text to be detected and the detection result, so as to control the emphasis of the expert model output.
[0116] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0117] S31, based on the weight information, the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0118] In a specific implementation, the vector information respectively output by the at least two layers of encoders can be processed by an expert model while considering the weight information, so that the expert model can focus on the vector information corresponding to the language structure dimension that may have abnormalities during the analysis of Chinese fluency, and output the Chinese fluency detection result corresponding to the text to be detected. Thereby, the accuracy of Chinese fluency detection can be further improved.
[0119] In one embodiment of the present invention, the step of inputting the text to be detected into a preset gate control system and obtaining weight information output by the gate control system includes:
[0120] S41, performing word segmentation processing on the text to be detected to obtain a word segmentation sequence; the word segmentation sequence includes at least one word segmentation;
[0121] In a specific implementation, the text to be detected can be segmented into basic units such as words, subwords or characters to obtain a segmentation sequence; wherein the segmentation sequence includes at least one segmentation, which can be a word, subword or character, and the present invention does not impose any limitation on this.
[0122] S42, performing part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence;
[0123] Part-of-speech tagging can be performed on the word segmentation sequence to determine the part-of-speech (such as noun, verb, adjective, etc.) of each word in the text to be detected. Part-of-speech tagging can assist in understanding the structure and semantics of the text to be detected.
[0124] S43, performing dependency syntactic analysis on the text to be detected to obtain syntactic analysis structure information;
[0125] You can also perform dependency syntactic analysis on the text to be detected, analyze the dependency relationship between words in the text to be detected, and obtain syntactic analysis structure information. Dependency syntactic analysis can generate a dependency graph (Dependency Graph), in which each word is a node and the dependency relationship between words is an edge.
[0126] Dependency parsing can understand the structure and semantics of a sentence from a syntactic perspective. At the same time, it can also analyze and determine whether there are subject-verb-object, attributive-adverbial-complement structures in the sentence through syntactic analysis structural information, and analyze the structure as the input of the gating system.
[0127] S44, identifying whether there is a grammatical problem in the text to be detected, and determining a grammatical score corresponding to the text to be detected;
[0128] It is also possible to use existing language tools to preliminarily determine whether the text to be tested has grammatical problems, and determine the grammatical score corresponding to the text to be tested based on whether the text to be tested has grammatical problems.
[0129] S45, inputting at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score into a preset gating system to obtain weight information output by the gating system.
[0130] Afterwards, at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score can be input into a preset gating system, so that the gating system can determine the possible anomalies in the text to be detected by considering the structure of the pre-analysis of the text to be detected, and output weight information, so that the expert model can focus on the vector information corresponding to the language structure dimension where the anomalies may exist in the process of analyzing the fluency of Chinese, and output the Chinese fluency detection result corresponding to the text to be detected.
[0131] In one embodiment of the present invention, the expert model includes at least two,
[0132] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0133] S51, for any of the expert models, determining at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders;
[0134] Specifically, the vector information output by the bottom-level encoder in the bidirectional representation model may tend to express text structure information, the vector information output by the middle-level encoder may tend to express text grammatical information, and the vector information output by the top-level encoder may tend to express text semantic information.
[0135] For any expert model, at least one target vector information processed by the expert model can be determined in the vector information respectively output by at least two layers of encoders. Thus, different expert models can respectively process the vector information output by at least one of the bottom encoder, the middle encoder, and the top encoder, and the vector information processed by different expert models may not be exactly the same.
[0136] As a specific example of the present invention, four expert models can be set, wherein one expert model can use the vector information output by the bottom encoder, the vector information output by the middle encoder, and the vector information output by the top encoder as target vector information to comprehensively consider multiple language structure dimensions at the same time. An expert model can use the vector information output by the bottom encoder as target vector information to mainly analyze text structure information. An expert model can use the vector information output by the middle encoder as target vector information to mainly analyze text grammatical information. An expert model can use the vector information output by the top encoder as target vector information to mainly analyze text semantic information.
[0137] S52, determining weights corresponding to the expert models based on the weight information and target vector information corresponding to the expert models;
[0138] In a specific implementation, the expert model may include at least two, and different expert models may be used to process different types of vector information. Different vector information may represent different language structure dimensions. Therefore, the language structure dimensions that need to be considered currently can be determined based on the weight information and the target vector information corresponding to the expert model, and the weights corresponding to different expert models can be determined respectively.
[0139] S53, processing the target vector information through the expert model to obtain expert model output features;
[0140] Afterwards, different expert models can process their corresponding target vector information respectively to obtain the output features of the expert model.
[0141] S54, based on the weights corresponding to the expert models, merging the expert model output features output by at least two of the expert models to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0142] In the process of expert model output, the expert model output features output by the patent model can be adjusted based on the weights corresponding to the expert models. Afterwards, the expert model output features output by at least two of the expert models can be merged, and after being processed by the Classify Tower, a Chinese fluency detection result can be output. The Chinese fluency detection result can be a score value for Chinese fluency detection. The higher the score value, the better the Chinese fluency.
[0143] In one embodiment of the present invention, the method further comprises:
[0144] S61, obtaining a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts;
[0145] S62, using the training sample set to train the Chinese fluency detection model to be trained to obtain a Chinese fluency detection model.
[0146] In a specific implementation, a training sample set may be obtained. The training sample set includes positive training samples and negative training samples. The positive training samples may include fluent text and Chinese fluency detection information corresponding to the fluent text; the negative training samples may include grammatically incorrect text and Chinese fluency detection information corresponding to the grammatically incorrect text.
[0147] Thereafter, the training sample set may be used to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0148] In one embodiment of the present invention, the method further comprises:
[0149] S71, obtaining a fluent text;
[0150] S72, adjusting the fluent text at the character granularity and / or word granularity to obtain a grammatically incorrect text;
[0151] S73, determining Chinese fluency detection information corresponding to the linguistically incorrect text;
[0152] S74, using the grammatically incorrect text and the Chinese fluency detection information corresponding to the grammatically incorrect text to generate a negative training sample.
[0153] In actual implementation, fluent texts are usually obtained from textbooks, encyclopedias, serious literary works, etc. However, it may be difficult to obtain grammatically incorrect texts, which makes it difficult to obtain high-quality negative training samples.
[0154] In this case, adjustments may be made at the character granularity and / or word granularity based on the fluent text.
[0155] For example, ways to create grammatically incorrect texts may include:
[0156] (1) Redundant, missing, and disordered text construction:
[0157] Redundant construction: After the text is segmented, randomly select characters or words and copy them afterwards.
[0158] Missing construction: After the text is segmented and part-of-speech analysis is performed, the subject, predicate, and object characters or words are deleted from the data in equal proportions.
[0159] Shuffle construction: After the text is segmented, the order of two consecutive characters or words is randomly swapped.
[0160] (2) Semantic repetition and contradictory text construction
[0161] After the text is segmented, a character or word is randomly selected, and the synonyms of the selected character or word are randomly obtained through the synonym table. Then the synonyms are inserted at random positions in the text or before and after the selected character or word.
[0162] (3) Incoherent text construction of homophones
[0163] After the text is segmented, a character is randomly selected and then replaced with a homonymous / phonetic character according to the homonymous / phonetic character table.
[0164] (4) Refers to incoherent text structures
[0165] After dividing the text, check whether there are any referential characters or words, and use the referential resolution model to determine the reference. If there is no correct reference, keep it. If there is a correct reference, delete the referential character or word.
[0166] Thereafter, it is possible to further determine and generate Chinese fluency detection information corresponding to the grammatically incorrect text, that is, the grammatically incorrect text and the Chinese fluency detection information corresponding to the grammatically incorrect text can be used to generate negative training samples.
[0167] As a specific example of the present invention, Figure 2 Schematic diagram of a Chinese fluency detection model provided in an embodiment of the present invention.
[0168] The Chinese fluency detection model may include a bidirectional representation model (BERT), wherein the bidirectional representation model (BERT) may include several encoders (Encoder). According to the positions of different encoders in the bidirectional representation model, at least three layers of encoders may be divided into a top encoder, a middle encoder, and a bottom encoder. Among them, the top encoder, the middle encoder, and the bottom encoder may include one or more encoders respectively. The encoders are connected in sequence, and the text to be detected (Chinese sentence) may pass through the encoders in sequence. The first layer encoder may use the text to be detected as input, perform feature extraction, and output the vector information (CLS) of the current layer. Thereafter, each layer of encoder may obtain the vector information (CLS) output by the previous layer, perform feature extraction, and output the vector information of the current layer. Thus, each layer of encoder may output vector information (CLS) respectively. In a multi-vector neural network tower (Muti CLS Tower), the vector information output by the top encoder may be merged, the vector information output by the middle encoder may be merged, and the vector information output by the bottom encoder may be merged.
[0169] At the same time, the text to be detected (Chinese sentence) can also be pre-analyzed to obtain sentence-level features as the input of the gating system (gate), including:
[0170] (1) After the text to be tested is segmented, part-of-speech tagging is performed to obtain a part-of-speech tag sequence.
[0171] (2) After the text to be tested is segmented, dependency syntactic analysis is performed to obtain a syntactic analysis structure. The structure is analyzed to determine whether there are variables such as subject-predicate-object, attributive-adverbial-complement in the sentence, which are used as discrete feature inputs of the gating system.
[0172] (3) Use language tools to preliminarily determine whether the input text to be tested has grammatical problems. If there are problems, output the location of the incoherent text. And calculate the sentence score through matching.
[0173] Afterwards, the part-of-speech tagging sequence, syntactic analysis structure, discrete feature input, and sentence score are input into a gate system to obtain a weighted result output by the gate system.
[0174] Afterwards, the vector information is input into four expert models, specifically:
[0175] Expert 0: Expert model No. 0 receives all vector information of the Bidirectional Representation Model (BERT) as input, with the aim of retaining the overall information of the Chinese sentence.
[0176] Expert 1: Expert model No. 1 accepts the underlying encoder vector information of the Bidirectional Representation Model (BERT) as input, with the aim of paying more attention to the structural information of Chinese sentences.
[0177] Expert 2: Expert model No. 2 accepts the middle-level encoder vector information of the Bidirectional Representation Model (BERT) as input, with the aim of paying more attention to the grammatical information of Chinese sentences.
[0178] Expert 3: Expert model No. 3 accepts the top encoder vector information of the Bidirectional Representation Model (BERT) as input, with the aim of paying more attention to the semantic information of Chinese sentences.
[0179] The expert model is controlled by the weight output by the gating system. The output ratio of each expert model is adjusted through the gating system. Finally, the output features of the expert model are weighted and merged to obtain the Chinese fluency detection result.
[0180] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0181] Reference Figure 3 , shows a structural block diagram of a Chinese fluency detection device provided in an embodiment of the present invention, which may specifically include the following modules:
[0182] A to-be-detected text acquisition module 301 is used to acquire the to-be-detected text;
[0183] A text input module 302, used for inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0184] A bidirectional representation model processing module 303, used to process the to-be-detected text in sequence through at least two layers of encoders in the bidirectional representation model, and extract vector information respectively output by the at least two layers of encoders;
[0185] The expert model processing module 304 is used to process the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0186] Optionally, the bidirectional representation model processing module includes:
[0187] An encoder division submodule, used to divide at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder;
[0188] A vector information output submodule, used to process the to-be-detected text in sequence through at least three layers of encoders in the bidirectional representation model, and extract vector information respectively output by the at least three layers of encoders;
[0189] A top-level vector acquisition module, used to merge at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0190] A middle-level vector acquisition module, used to merge at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar;
[0191] The bottom-level vector acquisition module is used to merge at least one vector information corresponding to the output of the bottom-level encoder to obtain the bottom-level vector information representing the text structure.
[0192] Optionally, the device further comprises:
[0193] A weight information acquisition module, used to input the text to be detected into a preset gate control system, and obtain the weight information output by the gate control system;
[0194] The expert model processing module includes:
[0195] The fluency detection submodule is used to process the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0196] Optionally, the weight information acquisition module includes:
[0197] A word segmentation submodule is used to obtain a word segmentation sequence after performing word segmentation processing on the text to be detected; the word segmentation sequence includes at least one word segmentation;
[0198] A part-of-speech tagging submodule is used to perform part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence;
[0199] The syntax analysis submodule is used to perform dependency syntax analysis on the text to be detected to obtain syntax analysis structure information;
[0200] A grammatical problem identification submodule is used to identify whether there are grammatical problems in the text to be detected and determine the grammatical score corresponding to the text to be detected;
[0201] The weight information acquisition submodule is used to input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score into a preset gating system to obtain the weight information output by the gating system.
[0202] Optionally, the expert model includes at least two,
[0203] The fluency detection submodule includes:
[0204] a target vector determination unit, configured to determine, for any of the expert models, at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders;
[0205] A weight determination unit, used to determine the weights corresponding to the expert models based on the weight information and the target vector information corresponding to the expert models;
[0206] An output feature acquisition unit, used for processing the target vector information through the expert model to obtain an expert model output feature;
[0207] The fluency detection unit is used to combine the expert model output features output by at least two of the expert models based on the weights corresponding to the expert models to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0208] Optionally, the device further comprises:
[0209] A training sample set acquisition module, used to acquire a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts;
[0210] The training module is used to use the training sample set to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0211] Optionally, the device further comprises:
[0212] A fluent text acquisition module is used to acquire fluent text;
[0213] A grammatically incorrect text acquisition module is used to adjust the fluent text in character granularity and / or word granularity to obtain a grammatically incorrect text;
[0214] A fluency detection information acquisition module is used to determine the Chinese fluency detection information corresponding to the linguistically incorrect text;
[0215] The negative training sample acquisition module is used to generate negative training samples by using the grammatically incorrect text and the Chinese fluency detection information corresponding to the grammatically incorrect text.
[0216] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0217] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.
[0218] Memory 403, used for storing computer programs;
[0219] The processor 401 is used to execute the program stored in the memory 403 to implement the following steps:
[0220] Get the text to be detected;
[0221] Inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0222] Processing the to-be-detected text in sequence through at least two layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least two layers of encoders;
[0223] The vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0224] Optionally, the step of sequentially processing the text to be detected by at least two layers of encoders in the bidirectional representation model and extracting vector information respectively output by the at least two layers of encoders includes:
[0225] Dividing at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder;
[0226] Processing the to-be-detected text in sequence by at least three layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least three layers of encoders;
[0227] Merging at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0228] Merging at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar;
[0229] At least one vector information corresponding to the output of the underlying encoder is merged to obtain underlying vector information representing the text structure.
[0230] Optionally, the method further comprises:
[0231] Inputting the text to be detected into a preset gate control system, and obtaining weight information output by the gate control system;
[0232] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0233] Based on the weight information, the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0234] Optionally, the step of inputting the to-be-detected text into a preset gate control system and acquiring weight information output by the gate control system includes:
[0235] After performing word segmentation processing on the text to be detected, a word segmentation sequence is obtained; the word segmentation sequence includes at least one word segmentation;
[0236] Performing part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence;
[0237] Performing dependency syntactic analysis on the text to be detected to obtain syntactic analysis structure information;
[0238] Identify whether there is a grammatical problem in the text to be detected, and determine a grammatical score corresponding to the text to be detected;
[0239] At least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score is input into a preset gating system to obtain weight information output by the gating system.
[0240] Optionally, the expert model includes at least two,
[0241] The step of processing the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0242] For any of the expert models, determining at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders;
[0243] Based on the weight information and the target vector information corresponding to the expert model, the weight corresponding to the expert model is determined respectively.
[0244] Processing the target vector information through the expert model to obtain expert model output features;
[0245] Based on the weights corresponding to the expert models, the expert model output features output by at least two of the expert models are combined to obtain a Chinese fluency detection result corresponding to the text to be detected.
[0246] Optionally, the method further comprises:
[0247] Acquire a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts;
[0248] The training sample set is used to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0249] Optionally, the method further comprises:
[0250] Get fluent text;
[0251] The fluent text is adjusted in character granularity and / or word granularity to obtain a grammatically incorrect text;
[0252] Determine Chinese fluency detection information corresponding to the grammatically incorrect text;
[0253] The grammatically incorrect text and Chinese fluency detection information corresponding to the grammatically incorrect text are used to generate negative training samples.
[0254] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0255] The communication interface is used for communication between the above terminal and other devices.
[0256] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0257] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0258] like Figure 5 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 501 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the Chinese fluency detection method described in the above embodiment.
[0259] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the Chinese fluency detection method described in the above embodiment.
[0260] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0261] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0262] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0263] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for detecting fluency of Chinese, characterized in that: include: Get the text to be detected; Inputting the text to be detected into a preset Chinese fluency detection model; The Chinese fluency detection model includes a bidirectional representation model and an expert model; Processing the to-be-detected text in sequence through at least two layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least two layers of encoders; The vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
2. The method according to claim 1, characterized in that The step of sequentially processing the text to be detected by at least two layers of encoders in the bidirectional representation model and extracting vector information respectively output by the at least two layers of encoders comprises: Dividing at least three layers of encoders in the bidirectional representation model into a top-layer encoder, a middle-layer encoder, and a bottom-layer encoder; Processing the to-be-detected text in sequence by at least three layers of encoders in the bidirectional representation model, and extracting vector information respectively output by the at least three layers of encoders; Merging at least one vector information corresponding to the output of the top-level encoder to obtain top-level vector information representing the semantics of the text; Merging at least one vector information corresponding to the output of the middle-level encoder to obtain middle-level vector information representing the text grammar; At least one vector information corresponding to the output of the underlying encoder is merged to obtain underlying vector information representing the text structure.
3. The method according to claim 1, characterized in that The method further comprises: Inputting the text to be detected into a preset gate control system, and obtaining weight information output by the gate control system; The step of processing the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes: Based on the weight information, the vector information respectively output by the at least two layers of encoders is processed by the expert model to obtain a Chinese fluency detection result corresponding to the text to be detected.
4. The method according to claim 3, characterized in that The step of inputting the to-be-detected text into a preset gate control system and obtaining weight information output by the gate control system comprises: After performing word segmentation processing on the text to be detected, a word segmentation sequence is obtained; the word segmentation sequence includes at least one word segmentation; Performing part-of-speech tagging on the word segmentation sequence to obtain a part-of-speech tagging sequence; Performing dependency syntactic analysis on the text to be detected to obtain syntactic analysis structure information; Identify whether there is a grammatical problem in the text to be detected, and determine a grammatical score corresponding to the text to be detected; At least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammatical score is input into a preset gating system to obtain weight information output by the gating system.
5. The method according to claim 3, characterized in that: The expert model includes at least two, The step of obtaining a Chinese fluency detection result corresponding to the text to be detected by processing the vector information respectively output by the at least two layers of encoders through the expert model based on the weight information comprises: For any of the expert models, determining at least one target vector information processed by the expert model from the vector information respectively output by the at least two layers of encoders; Based on the weight information and the target vector information corresponding to the expert model, respectively determine the weights corresponding to the expert models; Processing the target vector information through the expert model to obtain expert model output features; Based on the weights corresponding to the expert models, the expert model output features output by at least two of the expert models are combined to obtain a Chinese fluency detection result corresponding to the text to be detected.
6. The method according to claim 1, characterized in that The method further comprises: Acquire a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent texts and Chinese fluency detection information corresponding to the fluent texts; the negative training samples include grammatically incorrect texts and Chinese fluency detection information corresponding to the grammatically incorrect texts; The training sample set is used to train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
7. The method according to claim 6, characterized in that The method further comprises: Get fluent text; The fluent text is adjusted in character granularity and / or word granularity to obtain a grammatically incorrect text; Determine Chinese fluency detection information corresponding to the grammatically incorrect text; The grammatically incorrect text and the Chinese fluency detection information corresponding to the grammatically incorrect text are used to generate negative training samples.
8. A Chinese fluency detection device, characterized in that: include: A module for acquiring text to be detected, used for acquiring text to be detected; A text input module, used for inputting the text to be detected into a preset Chinese fluency detection model; The Chinese fluency detection model includes a bidirectional representation model and an expert model; A bidirectional representation model processing module, used to sequentially process the text to be detected through at least two layers of encoders in the bidirectional representation model, and extract vector information respectively output by the at least two layers of encoders; The expert model processing module is used to process the vector information respectively output by the at least two layers of encoders through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Sensitive information detection method and device, electronic equipment and storage medium
CN112307770A
Text smoothness detection method and device, equipment and storage medium
CN114138934A
Chinese abstract generation method based on component syntactic analysis
CN114580376A
Chinese grammar error correction method and system, storage medium and terminal
CN115455949A
Abnormal session problem identification method and device, electronic equipment and readable medium
CN117612520A
Cited By
Chinese smoothness assessment method and apparatus, electronic device, and readable medium
WO2026123854A1