AI text detection method based on synonym replacement
By employing synonym replacement and multi-dimensional feature detection mechanisms, the problem of decreased accuracy in existing AI text detection technologies when facing new generative models is solved, achieving high-precision AI text detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-05-08
AI Technical Summary
Existing AI text detection technologies show a significant drop in accuracy when faced with new generative models or adversarial rewritten text, making it difficult to accurately distinguish between AI-generated text and human-written text.
By acquiring the original text and performing synonym replacement, the context fit, context window semantics, and probability distribution offset of the replaced text are calculated. The detection results are generated using a neural network model, which integrates semantic perturbation generation and multi-dimensional feature detection mechanisms.
It improves the accuracy of AI text detection, effectively distinguishing between AI-generated text and human-written text, and has high-precision detection capabilities.
Smart Images

Figure CN121997914A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of AI text detection technology, and in particular to an AI text detection method based on synonym replacement. Background Technology
[0002] With the rapid development of artificial intelligence and natural language processing technologies, large-scale language models (LLMs) have been widely applied in text generation, automated writing, and academic writing assistance. AI-generated text exhibits significant advantages in content production due to its fluency, semantic coherence, and logical consistency. However, the widespread use of AI text also brings potential risks, especially in scenarios such as academic publishing, educational assessment, and content security. AI-generated content may be used for inappropriate purposes, affecting the originality and authenticity of the text. Therefore, accurately distinguishing between AI-generated text and human-written text has become a key research focus in the field of AI content detection.
[0003] Currently, AI text detection mainly relies on two technical approaches. One is the learning-based method based on discriminative models, which collects a large number of human and AI text samples, uses deep learning models to extract their linguistic features, and then classifies them. This type of method has high accuracy when the training set is sufficient, but the model is highly dependent on the data distribution. When new generative models or adversarial rewriting of text emerge, the detection performance drops significantly, and frequent retraining is required. The other is the zero-shot method based on statistical features, which assesses the naturalness of text by calculating metrics such as perplexity or suddenness. This method requires no additional training and is suitable for rapid detection, but because it only reflects surface-level linguistic features, its ability to characterize deep semantics and contextual consistency is limited, and its accuracy drops significantly when facing highly deceptive AI text. Summary of the Invention
[0004] This invention proposes an AI text detection method based on synonym replacement, aiming to solve the problem of low detection accuracy in existing AI text detection technologies.
[0005] To achieve the above-mentioned technical effects, the technical solution of the present invention is as follows: An AI text detection method based on synonym replacement includes the following steps: S1. Obtain the original text and replace the target words in the original text with synonyms to obtain the replaced text; S2. Calculate the context fit, context window semantics, and probability distribution offset of synonyms in the replacement text; S3. Based on the context fit, context window semantics, and probability distribution offset, generate the detection result of the original text, wherein the detection result is AI text or artificial text.
[0006] Preferably, the step of performing synonym replacement on the target words in the original text to obtain the replaced text includes: S11. Identify keywords in the original text through word segmentation and part-of-speech tagging; S12. Obtain candidate synonyms for the keyword; S13. Calculate the confidence level of the filling probability of the candidate synonym in the original text, select the candidate synonym with the highest confidence level of the filling probability as the replacement synonym to replace the keyword, and obtain the replacement text.
[0007] Preferably, the calculation of the context fitness includes: S201. Construct a fixed-size context window for the replaced synonyms, the context window including several words; S202. Calculate the relevance between the replacement synonym and any word in the context window; S203. Calculate the context fit of the context window using the relevance.
[0008] Preferably, the formula for calculating the context fit F of the context window using the relevance is as follows:
[0009] Where s represents the replacement synonym, and i represents any other word in the context window. To replace the relevance of synonym s with any other word i in the context window, The frequency of any other word i in the context window.
[0010] Preferably, the calculation of the context window semantics includes: S211. Construct a vector representation of the context window; S212. Calculate the semantics of the context window using knowledge graph information and the vector representation.
[0011] Preferably, the calculation of the probability distribution offset includes: S221. Statistically analyze the frequency of occurrence of the replacement synonyms in a preset corpus, and construct an ordered vector set of the replacement synonyms; S222. Calculate the frequency of occurrence of attribute pairs corresponding to vectors in the original text in the ordered vector set; S223. Perform divergence calculation on the occurrence frequency to obtain the probability distribution offset of the replaced synonym.
[0012] Preferably, the divergence calculation is performed on the occurrence frequency to obtain the probability distribution offset of the replaced synonym. The calculation formula is as follows:
[0013] in, For attribute pairs Frequency of occurrence in the original text For attribute pairs Reference frequencies in standard human corpora.
[0014] Preferably, generating AI text detection results based on the context fit, context window semantics, and probability distribution offset includes: S31. Input the context fitness, context window semantics and probability distribution offset into a preset backpropagation neural network model, and the backpropagation neural network model outputs preliminary detection results; S32. Determine whether the preliminary detection result is AI text. If yes, input the replacement text into a preset parser to generate a semantic graph and execute S33; otherwise, determine that the preliminary detection result is artificial text. S33. Generate reconstructed text based on the semantic graph, and calculate the semantic similarity between the original text and the reconstructed text; S34. Determine whether the semantic similarity is greater than a preset threshold. If yes, determine that the AI detection result of the original text is AI text; otherwise, determine that the AI detection result of the original text is human text. The step of inputting the context fitness, context window semantics, and probability distribution offset into a preset backpropagation neural network model for detection also includes: If the detection result is AI text, the replacement text is input into a preset parser to generate a semantic graph. Based on the semantic graph, reconstructed text is generated. The semantic similarity between the original text and the reconstructed text is calculated and compared with a preset threshold to obtain a secondary verification detection result. If not, the detection result is determined to be artificial text.
[0015] Preferably, the semantic graph includes several nodes and their connections, and the step of generating reconstructed text based on the semantic graph includes: S331. Encode the nodes and their connections, and based on the connections, weighted aggregate the semantic information of the neighboring nodes of each node to obtain a contextual representation that characterizes the overall semantic graph:
[0016] Where v is a node in the semantic graph, and V is the set of nodes in the semantic graph; This represents the hidden state of node v; S332. Based on the context representation, the hidden state vector set is decoded by generating output words step by step according to the time sequence; at each time step, candidate words and their corresponding probabilities are generated according to the decoding state of the previous time step, the generated output words, and the context vector extracted from the context representation. :
[0017] Where ARM is a semantic graph, softmax( ) is the softmax function. Let be the linear transformation matrix, b be the bias term, t be the time step, and y be the output sequence. Candidate words; S333. Select the candidate word with the highest probability as the current output word until the reconstructed text corresponding to the semantic graph is generated.
[0018] Preferably, calculating the semantic similarity between the original text and the reconstructed text includes: S333. The original text and the reconstructed text are vectorized using a pre-trained sentence encoder to obtain sentence vectors for the original text and sentence vectors for the reconstructed text. S334. Calculate the cosine similarity between the original text sentence vector and the reconstructed text sentence vector to obtain the semantic similarity expression as follows:
[0019] in, Represents the original text. This indicates the reconstruction of the text. Represents the sentence vector of the original text. This represents the sentence vector of the reconstructed text.
[0020] Compared with the prior art, the beneficial effects of the technical solution of the present invention are: This invention proposes an AI text detection method based on synonym replacement. First, the original text is acquired, and target words in the original text are replaced with synonyms to obtain replaced text, thereby enhancing the discriminative information of the detection samples. Second, the context fit, context window semantics, and probability distribution offset of the synonyms in the replaced text are calculated to form a multi-dimensional semantic feature representation. Finally, the context fit, context window semantics, and probability distribution offset are input into a preset neural network model for detection to obtain the detection result. The overall scheme effectively integrates semantic perturbation generation and multi-dimensional feature detection mechanisms, enabling general detection of original text and possessing the advantage of high-precision detection. Attached Figure Description
[0021] Figure 1 This is a flowchart of the AI text detection method based on synonym replacement in an embodiment of the present invention; Figure 2 This is a conceptual framework diagram of the AI text detection method based on synonym replacement in an embodiment of the present invention; Figure 3 This is a flowchart illustrating the steps for obtaining the replaced text in an embodiment of the present invention; Figure 4 This is a flowchart illustrating the steps for obtaining context suitability in an embodiment of the present invention; Figure 5 This is a flowchart illustrating the steps for obtaining the semantics of the context window in an embodiment of the present invention; Figure 6 This is a flowchart illustrating the step of obtaining the probability distribution offset in an embodiment of the present invention; Figure 7 This is a flowchart illustrating the steps for obtaining the detection results of the original text in an embodiment of the present invention. Figure 8 This is a flowchart illustrating the steps for generating reconstructed text in an embodiment of the present invention; Figure 9 This is a flowchart illustrating the steps for obtaining semantic similarity in an embodiment of the present invention. Detailed Implementation
[0022] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent. It is understandable to those skilled in the art that some well-known details may be omitted from the accompanying drawings; The positional relationships depicted in the accompanying drawings are for illustrative purposes only and should not be construed as limiting this patent. To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments.
[0023] Example 1 like Figure 1 and Figure 2 As shown, this embodiment proposes an AI text detection method based on synonym replacement, including the following steps: S1. Obtain the original text and replace the target words in the original text with synonyms to obtain the replaced text; like Figure 3 As shown, the specific implementation of this step is as follows: To perform synonym replacement on the original text, the first step is to identify replaceable keywords (such as nouns and verbs) through word segmentation and part-of-speech tagging. Then, using dictionary resources (such as WordNet and HowNet) or pre-trained language models (such as BERT), context-related synonym candidates are obtained. To avoid semantic shift, semantically consistent and logically appropriate terms are selected based on the context. For example, a masked language model can be used to calculate the probability of candidate words filling the original sentence, selecting the one with the highest confidence. Simultaneously, stop words, proper nouns, and grammatical structures are preserved to ensure syntactic correctness.
[0024] S2. Calculate the context fit, context window semantics, and probability distribution offset of synonyms in the replacement text; The specific implementation of this step is as follows: like Figure 4 As shown, the calculation of the context fitness includes: S202. Calculate the relevance between the replacement synonym and any word in the context window; S203. Calculate the context fit of the context window using the relevance.
[0025] like Figure 5 As shown, the calculation of the context window semantics includes: S211. Construct a vector representation of the context window; S212. Calculate the semantics of the context window using knowledge graph information and the vector representation.
[0026] like Figure 6 As shown, the calculation of the probability distribution offset includes: S221. Statistically analyze the frequency of occurrence of the replacement synonyms in a preset corpus, and construct an ordered vector set of the replacement synonyms; S222. Calculate the frequency of occurrence of attribute pairs corresponding to vectors in the original text in the ordered vector set; S223. Perform divergence calculation on the occurrence frequency to obtain the probability distribution offset of the replaced synonym.
[0027] S3. Based on the context fit, context window semantics, and probability distribution offset, generate the detection result of the original text, wherein the detection result is AI text or artificial text.
[0028] like Figure 7 As shown, the specific implementation of this step is as follows: S31. Input the context fitness, context window semantics and probability distribution offset into a preset backpropagation neural network model, and the backpropagation neural network model outputs preliminary detection results; S32. Determine whether the preliminary detection result is AI text. If yes, input the replacement text into a preset parser to generate a semantic graph and execute S33; otherwise, determine that the preliminary detection result is artificial text. S33. Generate reconstructed text based on the semantic graph, and calculate the semantic similarity between the original text and the reconstructed text; S34. Determine whether the semantic similarity is greater than a preset threshold. If yes, determine that the AI detection result of the original text is AI text; otherwise, determine that the AI detection result of the original text is human text.
[0029] This embodiment proposes an AI text detection method based on synonym replacement. First, the original text is acquired, and target words in the original text are replaced with synonyms to obtain replaced text, thereby enhancing the discriminative information of the detection samples. Second, the context fit, context window semantics, and probability distribution offset of the synonyms in the replaced text are calculated to form a multi-dimensional semantic feature representation. Finally, the context fit, context window semantics, and probability distribution offset are input into a preset neural network model for detection to obtain the detection result. The overall scheme effectively integrates semantic perturbation generation and multi-dimensional feature detection mechanisms, enabling general detection of original text and possessing the advantage of high-precision detection.
[0030] Example 2 This embodiment further illustrates S2 of the above embodiment.
[0031] Specifically, the calculation of the context fitness includes: Before calculating the contextual suitability of a word based on its replacement synonyms, a context window needs to be constructed around that word. Assuming each replacement word's so-called position constructs a window of size 2k, and there are k words preceding the synonym, then there are ki words following it. After representing these words as vectors, the entire window's vector representation is as follows: (1) Based on this, calculate the relevance between synonym s and any word i in the window: (2) Therefore, the vertical fit of this window is expressed as: (3) in, The frequency of any word i in the window is used to evaluate the importance of context words to synonyms. (4) Where TF(wi,d) represents the frequency of word i in document d, IDF(i,D) represents inverse document frequency, which measures the "discriminative power" of a word, and D represents the entire set of documents, i.e., the corpus.
[0032] The calculation of the context window semantics includes: According to Formula 1, the vector representation of the context window can be calculated. However, the vector representation does not represent the semantic information of the window. Therefore, this embodiment integrates knowledge graph (KG) information to obtain a knowledge-enhanced semantic representation. (5) Where α∈[0,1]: fusion weight, The embedding of entity e in the knowledge graph can be represented by the TransE model. Generally, these embedding vectors are optimized by minimizing the loss function to obtain the embedding of entity e in the knowledge graph; Ec represents the set of entities extracted from the context window.
[0033] The calculation of the probability distribution offset includes: To calculate the shift in the probability distribution of synonyms, we first need to construct attribute pairs. This involves arranging the words in a synonym group in descending order based on their frequency of occurrence in a large-scale corpus, forming an ordered synonym vector W = (w1, w2, ..., wk). The semantic attribute of each word w in this vector can be represented as an ordered pair (pos, dim), where dim = k is the vector length and pos ∈ [0, k]. 1]pos∈[0,k [1] represents the index position of the word in the vector. If the word wj is located at the j-th position (starting from 0), then its attribute pair is (j,k). The probability difference p(j,k) between different attribute pairs appearing in the text is used to... p(h,k) is used as a statistical feature for text detection, where p(j,k) represents the frequency of attribute pair (j,k) in the text to be tested, and the calculation formula is: (6) Where f(i,k) is the total number of times attribute pair f(j,k) appears in the text. Based on this, the Kullback-Leibler divergence is used to calculate its offset. (7) Where p(i,k): the frequency of attribute pair (i,k) in the current text; q(i,k): Reference frequency in standard human corpus; the larger the value, the more the DKL distribution deviates from natural usage habits, and it is often used to detect the "over-homogenization" or "preferential use of uncommon words" phenomenon in AI text.
[0034] Therefore, this embodiment obtains the synonym context fit, the synonym context window semantics, and the synonym probability distribution offset.
[0035] Example 3 This embodiment is a further supplement to the above-described embodiment.
[0036] Specifically, it is determined whether the detection result is AI text. If so, the replacement text is input into a preset parser for secondary verification to obtain a secondary verification detection result; if not, the detection result is determined to be artificial text.
[0037] In this embodiment, the first step is to generate an ARM graph from the AI-generated text. This process is called text-to-AMR parsing. Generally, automated tools are used to directly predict the AMR graph from the text. This embodiment uses the PyTorch framework to generate the ARM graph from the text.
[0038] Then, the AI-generated text, after synonym replacement, is fed into the ARM graph to obtain naturally generated text. This process of graph-to-natural-language text generation is called AMR-to-Text Generation, and its goal is to convert structured semantic graphs into fluent and accurate natural-language sentences. This process is typically based on sequence-to-sequence (Seq2Seq) or graph-to-sequence (Graph2Seq) models, combined with graph neural networks (GNNs) and attention mechanisms. Figure 8 As shown, this is generally achieved through the following steps: ① Graph Encoder Encode the AMR graph using graph neural networks (such as GNN, GGNN, Graph Transformer): (8) (9) in: V: The set of nodes in the AMR graph; hv: The hidden state of node v; N(v): Neighbors of node v; Message aggregation functions (such as averaging); The final context representation of the graph is: H={hv∣v∈V}.
[0039] ① Text Decoder Generate text using autoregressive models such as RNN and Transformer: (10) (11) (12) (13) : Context vector, extracted from the graph encoding through the attention mechanism; : Attention weight, indicating the degree of attention to node v at decoding time t; : The t-th output word.
[0040] : The previous time step t The decoder hidden state of 1 Attention(st 1, hv): Attention scoring function, measuring the correlation between the decoder state and the encoded vector of node v 之间的相关性。
[0041] : Given the historical output sequence y<t and the AMR graph, the probability of the output word at time step tt 的概率。
[0042] : Linear transformation matrix, mapping the decoder hidden state to the vocabulary space.
[0043] b: Bias term.
[0044] softmax( ):softmax函数,将输入向量转换为概率分布。
[0045] 其中:公式10表示该公式表示在时间步 t,解码器根据前一时刻的状态 、前一时刻的输出词 和当前的上下文向量 来更新其隐藏状态 。
[0046] 公式11表示该公式表示通过加权求和的方式计算上下文向量 ,其中权重由注意力机制决定。
[0047] 公式12表示该公式表示通过softmax函数计算注意力权重 This makes the sum of all weights equal to 1, thereby achieving weighted fusion of the encoding vectors of different nodes.
[0048] ③ Training objective: Maximum likelihood estimation (14) This formula decomposes the generation probability of the entire text Y into the generation of a single word at each time step t. The sum of conditional probabilities. This is based on the assumption of the autoregressive model that the generation of the current word depends only on the previous words and the given AMR graph. In other words, given an AMR graph G, we aim to maximize the probability of generating the target text Y by minimizing the loss function L. Specifically, we want the model to generate the correct word with a high probability at each time step, thereby ultimately generating the entire text Y.
[0049] The new natural language text generated from the ARM graph is semantically similar to the original text. T1 (Original Text): The original AI-generated text to be detected (or the text initially identified by the model as AI-generated).
[0050] Y (Reconstructed Text): After replacing T1 with synonyms, input it into the AMR parser to generate a semantic graph, and then output the natural language text (i.e., the output result of step 5) by the AMR-to-Text generator. ① Select a semantic similarity calculation model like Figure 9 As shown, this embodiment focuses on Sentence-BERT (SBERT) context embedding, using a pre-trained sentence encoder to generate sentence vectors and calculate the sentence-level similarity (using cosine similarity) of synonyms, encoding T1 and T2 into fixed-length sentence vectors respectively: (15) (16) Calculate the cosine similarity between two vectors: (17) Output value range: [0, 1]. The closer to 1, the more similar the semantics, and the more likely it is to be AI-generated text.
[0051] ② Set a similarity threshold and make a final judgment. Set an empirical threshold θ (usually obtained through debugging on a labeled dataset; an initial value of 0.8 is recommended); then make the final classification decision. (18) This concludes the AI text detection method based on synonym replacement.
[0052] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. For those skilled in the art, other variations or modifications can be made based on the above description. It is impossible to exhaustively list all the implementation methods here. All obvious variations or modifications derived from the technical solutions of the present invention are still within the protection scope of the present invention.
Claims
1. An AI text detection method based on synonym replacement, characterized in that, Includes the following steps: S1. Obtain the original text and replace the target words in the original text with synonyms to obtain the replaced text; S2. Calculate the context fit, context window semantics, and probability distribution offset of synonyms in the replacement text; S3. Based on the context fit, context window semantics, and probability distribution offset, generate the detection result of the original text, wherein the detection result is AI text or artificial text.
2. The AI text detection method based on synonym replacement according to claim 1, characterized in that, The process of replacing target words in the original text with synonyms to obtain replaced text includes: S11. Identify keywords in the original text through word segmentation and part-of-speech tagging; S12. Obtain candidate synonyms for the keyword; S13. Calculate the confidence level of the filling probability of the candidate synonym in the original text, select the candidate synonym with the highest confidence level of the filling probability as the replacement synonym to replace the keyword, and obtain the replacement text.
3. The AI text detection method based on synonym replacement according to claim 2, characterized in that, The calculation of the context fit includes: S201. Construct a fixed-size context window for the replaced synonyms, the context window including several words; S202. Calculate the relevance between the replacement synonym and any word in the context window; S203. Calculate the context fit of the context window using the relevance.
4. The AI text detection method based on synonym replacement according to claim 3, characterized in that, The formula for calculating the context fit F of the context window using the relevance is as follows: Where s represents the replacement synonym, and i represents any other word in the context window. To replace the relevance of synonym s with any other word i in the context window, The frequency of any other word i in the context window.
5. The AI text detection method based on synonym replacement according to claim 4, characterized in that, The calculation of the context window semantics includes: S211. Construct a vector representation of the context window; S212. Calculate the semantics of the context window using knowledge graph information and the vector representation.
6. The AI text detection method based on synonym replacement according to claim 2, characterized in that, The calculation of the probability distribution offset includes: S221. Statistically analyze the frequency of occurrence of the replacement synonyms in a preset corpus, and construct an ordered vector set of the replacement synonyms; S222. Calculate the frequency of occurrence of attribute pairs corresponding to vectors in the original text in the ordered vector set; S223. Perform divergence calculation on the occurrence frequency to obtain the probability distribution offset of the replaced synonym.
7. The AI text detection method based on synonym replacement according to claim 6, characterized in that, The divergence calculation of the occurrence frequency yields the probability distribution offset of the replaced synonyms. The calculation formula is as follows: in, For attribute pairs Frequency of occurrence in the original text For attribute pairs Reference frequencies in standard human corpora.
8. The AI text detection method based on synonym replacement according to claim 1, characterized in that, The process of generating AI text detection results based on the context fit, context window semantics, and probability distribution offset includes: S31. Input the context fitness, context window semantics and probability distribution offset into a preset backpropagation neural network model, and the backpropagation neural network model outputs preliminary detection results; S32. Determine whether the preliminary detection result is AI text. If yes, input the replacement text into a preset parser to generate a semantic graph and execute S33; otherwise, determine that the preliminary detection result is artificial text. S33. Generate reconstructed text based on the semantic graph, and calculate the semantic similarity between the original text and the reconstructed text; S34. Determine whether the semantic similarity is greater than a preset threshold. If yes, determine that the AI detection result of the original text is AI text; otherwise, determine that the AI detection result of the original text is human text.
9. The AI text detection method based on synonym replacement according to claim 8, characterized in that, The semantic graph includes several nodes and their connections. Generating reconstructed text based on the semantic graph includes: S331. Encode the nodes and their connections, and based on the connections, weighted aggregate the semantic information of the neighboring nodes of each node to obtain a contextual representation that characterizes the overall semantic graph: Where v is a node in the semantic graph, and V is the set of nodes in the semantic graph; This represents the hidden state of node v; S332. Based on the context representation, the hidden state vector set is decoded by generating output words step by step according to the time sequence; at each time step, candidate words and their corresponding probabilities are generated according to the decoding state of the previous time step, the generated output words, and the context vector extracted from the context representation. : Where ARM is a semantic graph, softmax( ) is the softmax function. Let be the linear transformation matrix, b be the bias term, t be the time step, and y be the output sequence. Candidate words; S333. Select the candidate word with the highest probability as the current output word until the reconstructed text corresponding to the semantic graph is generated.
10. The AI text detection method based on synonym replacement according to claim 8, characterized in that, The calculation of the semantic similarity between the original text and the reconstructed text includes: S333. The original text and the reconstructed text are vectorized using a pre-trained sentence encoder to obtain sentence vectors for the original text and sentence vectors for the reconstructed text. S334. Calculate the cosine similarity between the original text sentence vector and the reconstructed text sentence vector to obtain the semantic similarity expression as follows: in, Represents the original text. This indicates the reconstruction of the text. Represents the sentence vector of the original text. This represents the sentence vector of the reconstructed text.