Chinese smoothness assessment method and apparatus, electronic device, and readable medium
By combining bidirectional representation models and expert models, and utilizing multi-layer encoders and gating systems to analyze the semantics, syntax, and structure of text, this approach addresses the insufficient accuracy of existing Chinese fluency detection technologies, achieving a more efficient evaluation of Chinese text fluency.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
- Filing Date
- 2025-09-11
- Publication Date
- 2026-06-18
AI Technical Summary
In existing technologies, Chinese fluency detection is difficult to effectively handle the polysemy, ambiguity, and the diversity and complexity of grammatical errors in language, resulting in inaccurate detection results.
A method combining bidirectional representation model and expert model is adopted. The text to be detected is processed through at least two layers of encoder to extract vector information at different levels. Combined with gating system and expert model, the semantics, syntax and structure of the text are analyzed to output Chinese fluency detection results.
It improves the accuracy and comprehensiveness of Chinese fluency detection, enabling better identification of grammatical issues and fluency in text, thereby enhancing text readability.
Smart Images

Figure CN2025120682_18062026_PF_FP_ABST
Abstract
Description
Chinese fluency testing methods, apparatus, electronic equipment and readable media
[0001] Related applications
[0002] This application claims priority to Chinese patent application filed on December 10, 2024, application number 2024118149349, entitled "Method, Apparatus, Electronic Device and Readable Medium for Testing Chinese Fluency", the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of artificial intelligence technology, and in particular to a method and apparatus for detecting the fluency of Chinese characters, an electronic device, and a computer-readable medium. Background Technology
[0004] Chinese fluency testing is primarily used in academic reports, emails, speeches, and various online writing scenarios. It assesses text fluency from multiple aspects, including grammar and semantics. This helps authors quickly and accurately identify grammatical errors and inaccurate expressions, improving the fluency and readability of the text.
[0005] In existing technologies, traditional Chinese fluency detection mainly involves the detection of Chinese grammatical rules. However, it is difficult to detect the correct results for the polysemy and ambiguity of language, the diversity and complexity of grammatical errors, and the diversity and uncertainty of grammatical rules. Summary of the Invention
[0006] This application discloses a method for detecting the fluency of Chinese characters, including:
[0007] Obtain the text to be detected;
[0008] The text to be detected is input into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0009] The text to be detected is processed sequentially by at least two encoder layers in the bidirectional representation model, and the vector information output by the at least two encoder layers is extracted respectively.
[0010] The expert model processes the vector information output by the at least two encoder layers to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0011] Optionally, the step of processing the text to be detected sequentially through at least two encoder layers in the bidirectional representation model and extracting the vector information output by the at least two encoder layers respectively includes:
[0012] The bidirectional representation model is divided into at least three encoder layers: a top-level encoder, a middle-level encoder, and a bottom-level encoder.
[0013] The text to be detected is processed sequentially by at least three encoder layers in the bidirectional representation model, and the vector information output by the at least three encoder layers is extracted respectively;
[0014] At least one vector information output by the top-level encoder is merged to obtain top-level vector information representing the semantics of the text.
[0015] At least one vector information output by the intermediate encoder is merged to obtain intermediate vector information representing the text syntax.
[0016] At least one vector information output by the underlying encoder is merged to obtain underlying vector information representing the text structure.
[0017] Optionally, the method further includes:
[0018] The text to be detected is input into a preset gating system, and the weight information output by the gating system is obtained;
[0019] The step of processing the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0020] Based on the weight information, the vector information output by the at least two encoder layers is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0021] Optionally, the step of inputting the text to be detected into a preset gating system and obtaining the weight information output by the gating system includes:
[0022] After performing word segmentation on the text to be detected, a word segmentation sequence is obtained; the word segmentation sequence includes at least one word segmentation.
[0023] The word segmentation sequence is tagged with part-of-speech tags to obtain a tagged part-of-speech sequence;
[0024] Dependency parsing is performed on the text to be detected to obtain syntactic analysis structure information;
[0025] Identify whether there are grammatical problems in the text to be detected, and determine the grammatical score corresponding to the text to be detected;
[0026] Input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammar score into a preset gating system to obtain the weight information output by the gating system.
[0027] Optionally, the expert model includes at least two.
[0028] The step of processing the vector information output by the at least two encoder layers respectively based on the weight information and using the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0029] For any of the expert models, at least one target vector information processed by the expert model is determined from the vector information output by the at least two encoder layers respectively;
[0030] Based on the weight information and the target vector information corresponding to the expert model, the weights corresponding to the expert model are determined respectively.
[0031] The target vector information is processed by the expert model to obtain the expert model output features;
[0032] Based on the weights corresponding to the expert models, the output features of at least two expert models are merged to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0033] Optionally, the method further includes:
[0034] Obtain a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information.
[0035] The training sample set is used to train the Chinese fluency detection model to obtain the Chinese fluency detection model.
[0036] Optionally, the method further includes;
[0037] Get fluent text;
[0038] The fluent text is adjusted at the character granularity and / or word granularity to obtain the text with grammatical errors;
[0039] Determine the Chinese fluency detection information corresponding to the grammatically incorrect text;
[0040] Negative training samples are generated using the grammatically incorrect text and the corresponding Chinese fluency detection information.
[0041] This application also provides a Chinese fluency detection device, including:
[0042] The text to be detected module is used to acquire the text to be detected.
[0043] The text input module is used to input 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;
[0044] A bidirectional representation model processing module is used to process the text to be detected sequentially through at least two encoder layers in the bidirectional representation model, and extract the vector information output by the at least two encoder layers respectively;
[0045] The expert model processing module is used to process the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0046] Optionally, the bidirectional representation model processing module includes:
[0047] The encoder partitioning submodule is used to partition at least three encoder layers in the bidirectional representation model into a top-level encoder, a middle-level encoder, and a bottom-level encoder.
[0048] The vector information output submodule is used to process the text to be detected sequentially through at least three encoders in the bidirectional representation model, and extract the vector information output by the at least three encoders respectively.
[0049] The top-level vector acquisition module is used to merge at least one vector information output by the top-level encoder to obtain top-level vector information representing the semantics of the text.
[0050] The intermediate vector acquisition module is used to merge at least one vector information output by the intermediate encoder to obtain intermediate vector information representing the text syntax.
[0051] The underlying vector acquisition module is used to merge at least one vector information output by the underlying encoder to obtain underlying vector information representing the text structure.
[0052] Optionally, the device further includes:
[0053] The weight information acquisition module is used to input the text to be detected into a preset gate control system and acquire the weight information output by the gate control system.
[0054] The expert model processing module includes:
[0055] The fluency detection submodule is used to process the vector information output by the at least two encoder layers respectively through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0056] Optionally, the weight information acquisition module includes:
[0057] The word segmentation submodule is used to segment the text to be detected into words to obtain a word segmentation sequence; the word segmentation sequence includes at least one word segmentation.
[0058] The 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;
[0059] The syntax analysis submodule is used to perform dependency parsing on the text to be detected to obtain syntactic analysis structure information.
[0060] The grammar problem identification submodule is used to identify whether there are grammar problems in the text to be detected and to determine the grammar score of the text to be detected.
[0061] 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 grammar score into a preset gating system, and obtain the weight information output by the gating system.
[0062] Optionally, the expert model includes at least two.
[0063] The smoothness detection submodule includes:
[0064] A target vector determination unit is used to determine, for any one of the expert models, at least one target vector information processed by the expert model from the vector information output by the at least two encoder layers respectively;
[0065] The weight determination unit is used to determine the weights corresponding to the expert model based on the weight information and the target vector information corresponding to the expert model.
[0066] The output feature acquisition unit is used to process the target vector information through the expert model to obtain the expert model output features;
[0067] The fluency detection unit is used to merge the output features of at least two 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.
[0068] Optionally, the device further includes:
[0069] The training sample set acquisition module is 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 text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information.
[0070] The training module is used to train the Chinese fluency detection model to be trained using the training sample set, so as to obtain the Chinese fluency detection model.
[0071] Optionally, the device further includes;
[0072] The fluent text acquisition module is used to acquire fluent text.
[0073] The grammatical error text acquisition module is used to adjust the fluent text at the character granularity and / or word granularity to obtain the grammatical error text;
[0074] The fluency detection information acquisition module is used to determine the Chinese fluency detection information corresponding to the grammatically incorrect text;
[0075] The negative training sample acquisition module is used to generate negative training samples using the grammatically incorrect text and the corresponding Chinese fluency detection information.
[0076] This application also discloses an electronic device, including 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;
[0077] The memory is used to store computer programs;
[0078] When the processor executes a program stored in the memory, it implements the method described in the embodiments of this application.
[0079] This application also discloses one or more computer-readable media storing instructions that, when executed by one or more processors, cause the processors to perform the methods described in this application.
[0080] Details of one or more embodiments of this application are set forth in the following drawings and description. Other features, objects, and advantages of this application will become apparent from the specification, drawings, and claims. Attached Figure Description
[0081] Figure 1 is a flowchart of a Chinese fluency detection method provided in an embodiment of this application;
[0082] Figure 2 is a schematic diagram of a Chinese fluency detection model provided in an embodiment of this application;
[0083] Figure 3 is a structural block diagram of a Chinese fluency detection device provided in an embodiment of this application;
[0084] Figure 4 is a block diagram of an electronic device provided in an embodiment of this application;
[0085] Figure 5 is a schematic diagram of a computer-readable medium provided in an embodiment of this application. Detailed Implementation
[0086] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, this application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0087] Referring to Figure 1, a flowchart of the steps of a Chinese fluency detection method provided in an embodiment of this application is shown, which may specifically include the following steps:
[0088] Step 101: Obtain the text to be detected;
[0089] In this application embodiment, Chinese fluency detection can be a method for evaluating the fluency of Chinese text, including both grammatical and semantic detection. It is mainly used to determine whether a piece of Chinese text is fluent, natural, and free of phonetic errors or typos. It is primarily used for text detection in various writing scenarios to quickly identify problems and improve text quality and readability.
[0090] Specifically, when it is necessary to check the fluency of Chinese characters in text, the text to be checked can be obtained. The text to be checked may include at least one Chinese character.
[0091] Step 102: Input 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] To detect the fluency of Chinese text, a Chinese fluency detection model can be set up. This model can include a Bidirectional Encoder Representations from Transformers (BERT) model and expert models. The BERT model is used to extract vector information from the text to be detected, while the expert models are used to analyze the extracted vector information and output the Chinese fluency detection results.
[0093] Step 103: The text to be detected is processed sequentially by at least two encoder layers in the bidirectional representation model, and the vector information output by the at least two encoder layers is extracted respectively;
[0094] In this embodiment, the bidirectional representation model may include at least two encoder layers. These encoders can be connected sequentially, and the text to be detected can pass through them sequentially. The first encoder layer takes the text to be detected as input, performs feature extraction, and outputs the vector information of the current layer. Subsequent encoder layers can obtain the vector information output from the previous layer, perform feature extraction, and output the vector information of the current layer. Thus, each encoder layer can output vector information independently.
[0095] Generally, feature extraction only requires obtaining the vector information output by the last encoder layer. However, in this embodiment, the vector information output by different encoding layers can focus on representing different language structure dimensions. These language structure dimensions can include text structure, text syntax, and text semantics. For example, some encoding layer output vector information can focus on representing text structure, some on representing text syntax, and some on representing text language.
[0096] Therefore, in this embodiment of the application, vector information output by at least two encoder layers can be extracted simultaneously to analyze the fluency of the Chinese text to be processed from different language structure dimensions.
[0097] Step 104: Process the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0098] In a practical implementation, the vector information output by at least two encoder layers can be input into an expert model. The expert model can process the vector information output by at least two encoder layers to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0099] The Chinese fluency detection method provided in this application involves: acquiring a text to be detected; inputting the text to be detected into a preset Chinese fluency detection model; the Chinese fluency detection model including a bidirectional representation model and an expert model; processing the text to be detected sequentially through at least two encoder layers in the bidirectional representation model to extract vector information output by the at least two encoder layers respectively; and processing the vector information output by the at least two encoder layers respectively through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected. Therefore, the Chinese fluency detection result can be analyzed based on the vector information output by at least two encoder layers in the bidirectional representation model, allowing the features output by different levels of encoders to be considered simultaneously during the Chinese fluency detection process. This enables the analysis of the Chinese fluency of the text based on different language structure dimensions, thereby improving the accuracy of Chinese fluency detection.
[0100] In one embodiment of this application, the step of sequentially processing the text to be detected through at least two encoder layers in the bidirectional representation model and extracting the vector information output by the at least two encoder layers respectively includes:
[0101] S11, the at least three encoder layers in the bidirectional representation model are divided into a top-level encoder, a middle-level encoder, and a bottom-level encoder;
[0102] In a practical implementation, a bidirectional representation model can include at least three layers of encoders. These encoders can be categorized into a top-level encoder, a middle-level encoder, and a bottom-level encoder based on their position within the model. Each of the top-level, middle-level, and bottom-level encoders can contain one or more encoders. Therefore, the encoders in the bidirectional representation model can be classified into three categories.
[0103] In this embodiment, through t-SNE (t-Distributed Stochastic Neighbor Embedding) visualization and probe task analysis and understanding of the internal representation of bidirectional representation models (such as BERT), it can be seen that the vector information output by the bottom encoder in the bidirectional representation model tends to express text structure information, the vector information output by the middle encoder tends to express text syntax information, and the top encoder tends to express text semantic information. Text structure information, text syntax information, and text semantic information are all important reference information in Chinese fluency detection. Therefore, the vectors output by the top encoder, middle encoder, and bottom encoder can be obtained simultaneously to subsequently integrate text structure information, text syntax information, and text semantic information for Chinese fluency detection.
[0104] S12, the text to be detected is processed sequentially by at least three encoders in the bidirectional representation model, and the vector information output by the at least three encoders is extracted respectively;
[0105] In this embodiment, the text to be detected can pass through the encoders sequentially. The first encoder takes the text to be detected as input, performs feature extraction, and outputs the vector information of the current layer. Each subsequent 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 encoder can output vector information separately. Therefore, vector information output by at least three encoders can be extracted.
[0106] S13, merge at least one vector information output by the top-level encoder to obtain top-level vector information representing the semantics of the text;
[0107] In a specific implementation, the vector information output by at least one encoder in the top-level encoder is obtained and then merged to obtain the top-level vector information representing the semantics of the text.
[0108] S14, merge at least one vector information output by the intermediate encoder to obtain intermediate vector information representing the text syntax;
[0109] In a specific implementation, the vector information output by at least one encoder in the intermediate encoder is obtained and the vector information is merged to obtain the intermediate vector information representing the text syntax.
[0110] S15, merge at least one vector information output by the underlying encoder to obtain underlying vector information representing the text structure.
[0111] In the specific implementation, the vector information output by at least one encoder in the underlying encoder is obtained and the vector information is merged to obtain the underlying vector information representing the text structure.
[0112] In one embodiment of this application, the method further includes:
[0113] S21, input the text to be detected into a preset gate control system and obtain the weight information output by the gate control system;
[0114] In this embodiment of the application, in order to further improve the accuracy of Chinese fluency detection, the text to be detected can be pre-detected to know that the text to be detected may have abnormal language structure dimensions. In the process of controlling the expert model to determine the Chinese fluency detection result corresponding to the text to be detected, the focus can be on analyzing the language structure dimensions that may have abnormalities.
[0115] Therefore, a gating system can be set up, which can be used to output the weight information of the expert model based on the text to be detected and the detection results, so as to control the focus of the expert model output.
[0116] The step of processing the vector information output by the at least two encoder layers 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 output by the at least two encoder layers is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0118] In practical implementation, considering weight information, the vector information output by the at least two encoder layers can be processed by an expert model. This allows the expert model to focus on the vector information corresponding to potentially abnormal language structure dimensions during the analysis of Chinese fluency, and output the Chinese fluency detection result for the text to be detected. This can further improve the accuracy of Chinese fluency detection.
[0119] In one embodiment of this application, the step of inputting the text to be detected into a preset gating system and obtaining the weight information output by the gating system includes:
[0120] S41, After performing word segmentation on the text to be detected, a word segmentation sequence is obtained; 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 this application does not impose any restrictions on this.
[0122] S42, perform 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 word segments 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 help understand the structure and semantics of the text to be detected.
[0124] S43, perform dependency parsing on the text to be detected to obtain syntactic analysis structure information;
[0125] It can also perform dependency parsing on the text to be tested, analyzing the dependencies between words in the text to obtain syntactic structure information. Dependency parsing can generate a dependency graph, where each word is a node and the dependencies between words are edges.
[0126] Dependency parsing can understand the structure and semantics of a sentence from a syntactic perspective. Simultaneously, it can analyze structural information through syntactic analysis to determine whether the sentence contains subject-verb-object, attributive, adverbial, or complement structures, and use the analyzed structure as input to a gating system.
[0127] S44, identify whether there are grammatical problems in the text to be detected, and determine the grammatical score corresponding to the text to be detected;
[0128] Existing language tools can also be used to preliminarily determine whether there are grammatical problems in the text to be tested. Based on the presence of grammatical problems, a grammatical score can be determined for the text.
[0129] S45, input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammar score into a preset gating system, and obtain the weight information output by the gating system.
[0130] Subsequently, at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammar score can be input into a preset gating system. This allows the gating system to consider the structure of the text to be detected before analysis, determine possible anomalies in the text to be detected, and output weight information. This enables the expert model to focus on the vector information corresponding to the language structure dimension that may have anomalies when analyzing Chinese fluency, and output the Chinese fluency detection result corresponding to the text to be detected.
[0131] In one embodiment of this application, the expert model includes at least two.
[0132] The step of processing the vector information output by the at least two encoder layers respectively based on the weight information and using the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0133] S51, for any one of the expert models, determine at least one target vector information processed by the expert model from the vector information output by the at least two encoder layers respectively;
[0134] Specifically, in the bidirectional representation model, the vector information output by the bottom encoder tends to express text structure information, the vector information output by the middle encoder tends to express text syntax information, and the vector information output by the top encoder tends to express text semantic information.
[0135] For any given expert model, at least one target vector information that the expert model processes can be determined from the vector information output by at least two layers of encoders. Therefore, different expert models can process vector information output by at least one of the bottom-level encoder, middle-level encoder, and top-level encoder, and the vector information processed by different expert models may not be exactly the same.
[0136] As a specific example of this application, four expert models can be set up. One expert model can use the vector information output by the bottom encoder, the middle encoder, and the top encoder as target vector information to comprehensively consider multiple language structure dimensions simultaneously. Another expert model can use the vector information output by the bottom encoder as target vector information to primarily analyze text structure information. Another expert model can use the vector information output by the middle encoder as target vector information to primarily analyze text syntax information. Finally, another expert model can use the vector information output by the top encoder as target vector information to primarily analyze text semantic information.
[0137] S52, Based on the weight information and the target vector information corresponding to the expert model, determine the weights corresponding to the expert model respectively;
[0138] In practical implementation, there can be at least two expert models, each capable of processing different types of vector information. These different vector information can represent different dimensions of language structure. Therefore, based on the weight information and the target vector information corresponding to each expert model, the language structure dimension that needs to be emphasized can be determined, and the weights for each expert model can be assigned accordingly.
[0139] S53, The target vector information is processed by the expert model to obtain the expert model output features;
[0140] Subsequently, different expert models can process their corresponding target vector information to obtain the output features of the expert models.
[0141] S54, based on the weights corresponding to the expert models, merge the output features of at least two expert models to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0142] During the expert model output process, the expert model output features of the patent model can be adjusted based on the weights corresponding to the expert models. Subsequently, the expert model output features of at least two expert models can be merged, processed through a classification neural network tower, and the Chinese fluency detection result can be output. This Chinese fluency detection result can be a score for Chinese fluency detection; the higher the score, the better the Chinese fluency.
[0143] In one embodiment of this application, the method further includes:
[0144] S61, Obtain a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information.
[0145] S62, using the training sample set, train the Chinese fluency detection model to be trained to obtain the Chinese fluency detection model.
[0146] In a practical implementation, a training sample set can be obtained. The training sample set includes positive training samples and negative training samples. Positive training samples may include fluent text and the corresponding Chinese fluency detection information; negative training samples may include text with grammatical errors and the corresponding Chinese fluency detection information.
[0147] Subsequently, the training sample set can be used to train the Chinese fluency detection model to obtain the Chinese fluency detection model.
[0148] In one embodiment of this application, the method further includes;
[0149] S71, retrieve fluent text;
[0150] S72, the fluent text is adjusted at the character granularity and / or word granularity to obtain the text with grammatical errors;
[0151] S73, determine the Chinese fluency detection information corresponding to the grammatically incorrect text;
[0152] S74, using the grammatically incorrect text and the corresponding Chinese fluency detection information, generate negative training samples.
[0153] In practice, fluent texts are typically obtained from sources such as textbooks, encyclopedias, and serious literary works. However, obtaining texts with grammatical errors can be challenging, making it difficult to acquire high-quality negative training samples.
[0154] In this case, adjustments can be made at the character granularity and / or word granularity based on the fluent text.
[0155] For example, methods for creating texts with grammatical errors may include:
[0156] (1) Construction of redundant, missing, and disordered text:
[0157] Redundant construction: After segmenting the text into words, randomly select characters or words and repeat them.
[0158] Missing words construction: After segmenting the text and performing part-of-speech analysis, the data is divided into subjects, verbs, and objects, or words, and deleted in equal proportions.
[0159] Randomized construction: After segmenting the text into words, randomly swap the order of two consecutive characters or words.
[0160] (2) Semantic repetition and contradictory text construction
[0161] After segmenting the text into words, randomly select a character or word, and then randomly obtain synonyms for the selected character or word from a thesaurus. Finally, insert the synonyms at random positions in the text or before and after the selected character or word.
[0162] (3) Text construction with homophones / homophones that do not flow smoothly
[0163] After segmenting the text, randomly select a character, and then replace it with a homonym by referring to the homonym / phonetic character list.
[0164] (4) Referring to the incoherent text structure
[0165] After segmenting the text, check if there are any referential words or phrases. Use a referential resolution model to determine the referentiality. If there is no correct referentiality, retain it; if there is a correct referentiality, delete the referential words or phrases.
[0166] Subsequently, the Chinese fluency detection information corresponding to the grammatically incorrect text can be further determined. That is, negative training samples can be generated using the grammatically incorrect text and the corresponding Chinese fluency detection information.
[0167] As a specific example of this application, Figure 2 is a schematic diagram of a Chinese fluency detection model provided in an embodiment of this application.
[0168] Chinese fluency detection models can include bidirectional representation models (BERT),
[0169] The Bidirectional Representation Model (BERT) can include several encoders. Based on the position of different encoders within the model, at least three encoder layers can be divided into a top-level encoder, a middle-level encoder, and a bottom-level encoder. Each of these layers can contain one or more encoders. The encoders are connected sequentially. The text to be detected (Chinese sentence) passes through these encoders sequentially. The first encoder takes the text as input, extracts features, and outputs the current layer's vector information (CLS). Subsequent encoder layers obtain the vector information (CLS) from the previous layer, extract features, and output their own vector information. Thus, each encoder layer outputs its own vector information (CLS). In a Multi-Vector Network Tower (MUTI CLS Tower), the vector information outputs from the top-level encoder, the middle-level encoders, and the bottom-level encoders can be merged.
[0170] Simultaneously, it can also perform pre-analysis on the text to be detected (Chinese sentence) to obtain sentence-level features as input to the gating system, including:
[0171] (1) After segmenting the text to be detected into words, perform part-of-speech tagging to obtain a part-of-speech tagging sequence.
[0172] (2) After segmenting the text to be detected, dependency parsing is performed to obtain the syntactic analysis structure. The existence of subject-verb-object, attributive, adverbial, and complement structures in the sentence is determined by the analysis structure and variables are added as discrete feature inputs for the gating system.
[0173] (3) Using language tools, preliminarily determine whether the input text to be detected has grammatical problems. If so, output the locations of the incoherent text. And calculate the sentence score through matching.
[0174] Subsequently, the part-of-speech tagging sequence, syntactic analysis structure, discrete feature input, and sentence score input are fed into the gating system to obtain the weighted results output by the gating system.
[0175] Subsequently, the vector information is input into four expert models, specifically:
[0176] Expert 0: The zeroth expert model receives all vector information from the Bidirectional Representation Model (BERT) as input, with the aim of preserving the overall information of Chinese sentences.
[0177] Expert 1: The first expert model, which takes the vector information of the underlying encoder of the Bidirectional Representation Model (BERT) as input, aims to focus more on the structural information of Chinese sentences.
[0178] Expert 2: The second expert model, which takes the encoder vector information from the Bidirectional Representation Model (BERT) as input, aims to focus more on the grammatical information of Chinese sentences.
[0179] Expert 3: The third expert model, which takes the top-level encoder vector information of the Bidirectional Representation Model (BERT) as input, aims to focus more on the semantic information of Chinese sentences.
[0180] The expert models are controlled by the weights of the gating system output. The gating system adjusts the output ratio of each expert model, and finally the output features of the expert models are weighted and merged to obtain the Chinese fluency detection result.
[0181] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0182] Referring to Figure 3, a structural block diagram of a Chinese fluency detection device provided in an embodiment of this application is shown, which may specifically include the following modules:
[0183] The text acquisition module 301 is used to acquire the text to be detected.
[0184] The text input module 302 is used to input 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;
[0185] The bidirectional representation model processing module 303 is used to process the text to be detected sequentially through at least two encoder layers in the bidirectional representation model, and extract the vector information output by the at least two encoder layers respectively;
[0186] The expert model processing module 304 is used to process the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0187] Optionally, the bidirectional representation model processing module includes:
[0188] The encoder partitioning submodule is used to partition at least three encoder layers in the bidirectional representation model into a top-level encoder, a middle-level encoder, and a bottom-level encoder.
[0189] The vector information output submodule is used to process the text to be detected sequentially through at least three encoders in the bidirectional representation model, and extract the vector information output by the at least three encoders respectively.
[0190] The top-level vector acquisition module is used to merge at least one vector information output by the top-level encoder to obtain top-level vector information representing the semantics of the text.
[0191] The intermediate vector acquisition module is used to merge at least one vector information output by the intermediate encoder to obtain intermediate vector information representing the text syntax.
[0192] The underlying vector acquisition module is used to merge at least one vector information output by the underlying encoder to obtain underlying vector information representing the text structure.
[0193] Optionally, the device further includes:
[0194] The weight information acquisition module is used to input the text to be detected into a preset gate control system and acquire the weight information output by the gate control system.
[0195] The expert model processing module includes:
[0196] The fluency detection submodule is used to process the vector information output by the at least two encoder layers respectively through the expert model based on the weight information to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0197] Optionally, the weight information acquisition module includes:
[0198] The word segmentation submodule is used to segment the text to be detected into words to obtain a word segmentation sequence; the word segmentation sequence includes at least one word segmentation.
[0199] The 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;
[0200] The syntax analysis submodule is used to perform dependency parsing on the text to be detected to obtain syntactic analysis structure information.
[0201] The grammar problem identification submodule is used to identify whether there are grammar problems in the text to be detected and to determine the grammar score of the text to be detected.
[0202] 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 grammar score into a preset gating system, and obtain the weight information output by the gating system.
[0203] Optionally, the expert model includes at least two.
[0204] The smoothness detection submodule includes:
[0205] A target vector determination unit is used to determine, for any one of the expert models, at least one target vector information processed by the expert model from the vector information output by the at least two encoder layers respectively;
[0206] The weight determination unit is used to determine the weights corresponding to the expert model based on the weight information and the target vector information corresponding to the expert model, respectively.
[0207] The output feature acquisition unit is used to process the target vector information through the expert model to obtain the expert model output features;
[0208] The fluency detection unit is used to merge the output features of at least two 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.
[0209] Optionally, the device further includes:
[0210] The training sample set acquisition module is 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 text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information.
[0211] The training module is used to train the Chinese fluency detection model to be trained using the training sample set, so as to obtain the Chinese fluency detection model.
[0212] Optionally, the device further includes;
[0213] The fluent text acquisition module is used to acquire fluent text.
[0214] The grammatical error text acquisition module is used to adjust the fluent text at the character granularity and / or word granularity to obtain the grammatical error text;
[0215] The fluency detection information acquisition module is used to determine the Chinese fluency detection information corresponding to the grammatically incorrect text;
[0216] The negative training sample acquisition module is used to generate negative training samples using the grammatically incorrect text and the corresponding Chinese fluency detection information.
[0217] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0218] In addition, this application embodiment also provides an electronic device, as shown in FIG4, including 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.
[0219] Memory 403 is used to store computer programs;
[0220] When processor 401 executes the program stored in memory 403, it performs the following steps:
[0221] Obtain the text to be detected;
[0222] The text to be detected is input into a preset Chinese fluency detection model; the Chinese fluency detection model includes a bidirectional representation model and an expert model;
[0223] The text to be detected is processed sequentially by at least two encoder layers in the bidirectional representation model, and the vector information output by the at least two encoder layers is extracted respectively.
[0224] The expert model processes the vector information output by the at least two encoder layers to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0225] Optionally, the step of processing the text to be detected sequentially through at least two encoder layers in the bidirectional representation model and extracting the vector information output by the at least two encoder layers respectively includes:
[0226] The bidirectional representation model is divided into at least three encoder layers: a top-level encoder, a middle-level encoder, and a bottom-level encoder.
[0227] The text to be detected is processed sequentially by at least three encoder layers in the bidirectional representation model, and the vector information output by the at least three encoder layers is extracted respectively;
[0228] At least one vector information output by the top-level encoder is merged to obtain top-level vector information representing the semantics of the text.
[0229] At least one vector information output by the intermediate encoder is merged to obtain intermediate vector information representing the text syntax.
[0230] At least one vector information output by the underlying encoder is merged to obtain underlying vector information representing the text structure.
[0231] Optionally, the method further includes:
[0232] The text to be detected is input into a preset gating system, and the weight information output by the gating system is obtained;
[0233] The step of processing the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0234] Based on the weight information, the vector information output by the at least two encoder layers is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0235] Optionally, the step of inputting the text to be detected into a preset gating system and obtaining the weight information output by the gating system includes:
[0236] After performing word segmentation on the text to be detected, a word segmentation sequence is obtained; the word segmentation sequence includes at least one word segmentation.
[0237] The word segmentation sequence is tagged with part-of-speech tags to obtain a tagged part-of-speech sequence;
[0238] Dependency parsing is performed on the text to be detected to obtain syntactic analysis structure information;
[0239] Identify whether there are grammatical problems in the text to be detected, and determine the grammatical score corresponding to the text to be detected;
[0240] Input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammar score into a preset gating system to obtain the weight information output by the gating system.
[0241] Optionally, the expert model includes at least two.
[0242] The step of processing the vector information output by the at least two encoder layers respectively based on the weight information and using the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes:
[0243] For any of the expert models, at least one target vector information processed by the expert model is determined from the vector information output by the at least two encoder layers respectively;
[0244] Based on the weight information and the target vector information corresponding to the expert model, the weights corresponding to the expert model are determined respectively.
[0245] The target vector information is processed by the expert model to obtain the expert model output features;
[0246] Based on the weights corresponding to the expert models, the output features of at least two expert models are merged to obtain the Chinese fluency detection result corresponding to the text to be detected.
[0247] Optionally, the method further includes:
[0248] Obtain a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information.
[0249] The training sample set is used to train the Chinese fluency detection model to obtain the Chinese fluency detection model.
[0250] Optionally, the method further includes;
[0251] Get fluent text;
[0252] The fluent text is adjusted at the character granularity and / or word granularity to obtain the text with grammatical errors;
[0253] Determine the Chinese fluency detection information corresponding to the grammatically incorrect text;
[0254] Negative training samples are generated using the grammatically incorrect text and the corresponding Chinese fluency detection information.
[0255] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0256] The communication interface is used for communication between the aforementioned terminal and other devices.
[0257] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0258] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0259] As shown in Figure 5, in another embodiment provided in this application, a computer-readable storage medium 501 is also provided, which stores instructions that, when run on a computer, cause the computer to execute the Chinese fluency detection method described in the above embodiment.
[0260] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute the Chinese fluency detection method described in the above embodiments.
[0261] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially 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, all or part of the processes or functions described in the embodiments of this application are generated. 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. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0262] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0263] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0264] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A method for detecting the fluency of Chinese characters, comprising: Obtain the text to be detected; Input 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 sequentially by at least two encoder layers in the bidirectional representation model, and the vector information output by the at least two encoder layers is extracted respectively. The expert model processes the vector information output by the at least two encoder layers to obtain the Chinese fluency detection result corresponding to the text to be detected.
2. The method according to claim 1, wherein the text to be detected is processed sequentially by at least two encoder layers in the bidirectional representation model to extract vector information output by the at least two encoder layers respectively, comprising: The bidirectional representation model is divided into at least three encoder layers: a top-level encoder, a middle-level encoder, and a bottom-level encoder. The text to be detected is processed sequentially by at least three encoder layers in the bidirectional representation model, and the vector information output by the at least three encoder layers is extracted respectively; At least one vector information output by the top-level encoder is merged to obtain top-level vector information representing the semantics of the text. At least one vector information output by the intermediate encoder is merged to obtain intermediate vector information representing the text syntax. At least one vector information output by the underlying encoder is merged to obtain underlying vector information representing the text structure.
3. The method according to claim 1, wherein the method further comprises: The text to be detected is input into a preset gating system, and the weight information output by the gating system is obtained; The step of processing the vector information output by the at least two encoder layers 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 output by the at least two encoder layers is processed by the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
4. The method according to claim 3, wherein inputting the text to be detected into a preset gating system and obtaining the weight information output by the gating system includes: After performing word segmentation on the text to be detected, a word segmentation sequence is obtained; The word segmentation sequence includes at least one word segmentation; The word segmentation sequence is tagged with part-of-speech tags to obtain a tagged part-of-speech sequence; Dependency parsing is performed on the text to be detected to obtain syntactic analysis structure information; Identify whether there are grammatical problems in the text to be detected, and determine the grammatical score corresponding to the text to be detected; Input at least one of the part-of-speech tagging sequence, the syntactic analysis structure information, and the grammar score into a preset gating system to obtain the weight information output by the gating system.
5. The method according to claim 3, wherein the expert model comprises at least two. The step of processing the vector information output by the at least two encoder layers respectively based on the weight information and using the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected includes: For any of the expert models, at least one target vector information processed by the expert model is determined from the vector information output by the at least two encoder layers respectively; Based on the weight information and the target vector information corresponding to the expert model, the weights corresponding to the expert model are determined respectively. The target vector information is processed by the expert model to obtain the expert model output features; Based on the weights corresponding to the expert models, the output features of at least two expert models are merged to obtain the Chinese fluency detection result corresponding to the text to be detected.
6. The method according to claim 1, wherein the method further comprises: Obtain a training sample set; the training sample set includes positive training samples and negative training samples, the positive training samples include fluent text and the corresponding Chinese fluency detection information; the negative training samples include text with grammatical errors and the corresponding Chinese fluency detection information. The training sample set is used to train the Chinese fluency detection model to obtain the Chinese fluency detection model.
7. The method of claim 6, wherein the method further comprises; Get fluent text; The fluent text is adjusted at the character granularity and / or word granularity to obtain the text with grammatical errors; Determine the Chinese fluency detection information corresponding to the grammatically incorrect text; Negative training samples are generated using the grammatically incorrect text and the corresponding Chinese fluency detection information.
8. A Chinese fluency detection device, comprising: The text to be detected module is used to acquire the text to be detected. The text input module is used to input 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 is used to process the text to be detected sequentially through at least two encoder layers in the bidirectional representation model, and extract the vector information output by the at least two encoder layers respectively; The expert model processing module is used to process the vector information output by the at least two encoder layers through the expert model to obtain the Chinese fluency detection result corresponding to the text to be detected.
9. 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 through the communication bus; The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the method as described in any one of claims 1-7.
10. A computer-readable medium having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method as described in any one of claims 1-7.