Personality feature anti-detection method, device and computer equipment based on semantic constraints
Through the prompt text template and evaluation index system based on semantic constraints, the problem of low naturalness and credibility of existing text adversarial sample generation methods is solved, and the generation and evaluation of high-quality adversarial samples is achieved, and personality privacy is effectively protected.
Patent Information
- Application Number
- CN202411102462.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-12
AI Technical Summary
Existing text adversarial sample generation methods are difficult to generate adversarial samples with high naturalness and strong credibility, and there are challenges in adversarial sample evaluation and optimization, which cannot effectively protect personality privacy.
By designing a prompt text template based on semantic constraints, a large-scale language model is guided to generate adversarial samples, and a comprehensive evaluation index system is used for detection and optimization, ensuring that the difference between adversarial samples and the original text in dimensions such as semantics and emotions is reduced, and the naturalness is improved and credibility.
High-quality generation and evaluation of adversarial samples are achieved, personal privacy is effectively protected, the differences between adversarial samples and original text are reduced, and naturalness and credibility are improved.
Smart Images

Figure CN118643347B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text adversarial sample generation, and in particular to a personality feature anti-detection method, apparatus and computer equipment based on semantic constraints. Background Art
[0002] Personality is a set of characteristic behaviors, cognitive and emotional patterns evolved from human and environmental factors, and is a high-level privacy of human beings. As text-based personality feature detection technology gradually matures, attackers use personality feature detection technology to infer the personality of victims and apply it to customized telecommunications fraud, cognitive misleading, public opinion incitement and other activities that endanger personal and national security, which brings huge challenges to the protection of personality privacy.
[0003] The method of generating adversarial examples for text refers to the process of making minor modifications to natural language text to deceive or mislead the detection model. These minor modifications are difficult for humans to perceive, but are sufficient to mislead the detection model and cause incorrect results. The current mainstream methods for generating adversarial examples for text mainly include dictionary-based adversarial sample generation methods and adversarial sample generation methods combined with deep learning. However, according to existing research, a considerable number of adversarial samples in the dictionary-based adversarial sample generation work cannot avoid the perception and judgment of the human eye, and may have problems such as not being natural enough and the modifications being detected.
[0004] Strong semantic constraints are one of the important challenges faced by the present invention. The text adversarial samples generated by the text adversarial sample generation methods based on word-level replacement technology and deep learning technology only differ from the original text in characters. It uses wrong characters to deceive the personality trait detection model. The Large Language Model (LLM) is a natural language processing technology (Natural Language Process, NLP) based on deep learning. It has strong language understanding and generation capabilities and has great potential and inherent advantages in processing and generating natural language texts. Cleverly designed prompts to guide the large-scale language model are the key to solving this difficulty and challenge.
[0005] It is also crucial and difficult to evaluate the generated text adversarial samples. When a large-scale language model is input, it will definitely output text. However, whether the output text meets the requirements of adversarial samples remains to be considered. It is difficult and challenging to design a set of targeted evaluation index systems to evaluate the generated text adversarial samples, as well as to quantify the realism and attack success rate of adversarial samples.
[0006] Therefore, how to design appropriate prompt templates to guide large-scale language models, design a targeted evaluation index system, and optimize adversarial samples with poor effects in the evaluation index system are important issues faced in the process of adversarial sample generation. Summary of the invention
[0007] Based on this, it is necessary to provide a personality feature anti-detection method, device and computer equipment based on semantic constraints to address the above technical problems.
[0008] A personality feature anti-detection method based on semantic constraints, the method comprising:
[0009] Generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, knowledge prompts and a task description; the system role includes a model role and task requirements; the knowledge prompts include personality type and language style; the task description includes a task flow and input and output formats;
[0010] Load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample;
[0011] A text adversarial sample evaluation index system is used to perform quantitative detection on the adversarial sample, and whether the adversarial sample is qualified is determined based on the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection;
[0012] If the adversarial sample fails, the prompt text is optimized according to the evaluation result, and the above process is iterated until the evaluation result of the adversarial sample passes, then the iteration is stopped and the current adversarial sample is output.
[0013] In one of the embodiments, it also includes: obtaining adversarial samples corresponding to multiple original input texts, inputting the multiple adversarial samples into a pre-trained personality detection model, and outputting corresponding prediction results; the multiple original input samples correspond to multiple posts of the same user; verifying the validity of the adversarial samples based on the prediction results and the user's real personality, if the prediction results are consistent with the real personality, adjusting the preset threshold and re-optimizing the prompt text until the prediction results are inconsistent with the real personality.
[0014] In one embodiment, the personality detection model includes an encoding module, an L2C module and a deep graph convolution module. Multiple adversarial samples are input into a pre-trained personality detection model, and the corresponding prediction results are output, including: inputting multiple adversarial samples into the encoding module, encoding each adversarial sample into a content vector through the encoding module, and outputting a content vector sequence corresponding to multiple samples; initializing the embedding representation of the content vector sequence and the user node through the deep graph convolution module to obtain an initial user personality feature map, and extracting the node representation of the initial user personality feature map; the initial user personality feature map includes a user node and multiple adversarial sample nodes; optimizing the node connection relationship between the node representation output by the previous layer of the deep graph convolution module through the L2C module, and outputting the optimized user personality feature map to the deep graph convolution module; updating the node representation of the next layer according to the optimized user personality feature map through the deep graph convolution module, iteratively optimizing the user personality feature map, and outputting the prediction results.
[0015] In one of the embodiments, it also includes: obtaining an adversarial sample, performing text detection on the adversarial sample to obtain a text detection result, if the text detection result is greater than or equal to a first threshold, performing semantic similarity detection to obtain a semantic similarity detection result, otherwise, optimizing the prompt text according to a preset prompt text optimization strategy; if the semantic similarity detection result is greater than or equal to a second threshold, performing psychological feature detection to obtain a psychological feature detection result, otherwise, optimizing the prompt text according to the prompt text optimization strategy; if the psychological feature detection result is greater than or equal to a third threshold, determining that the current adversarial sample is qualified, otherwise, optimizing the prompt text according to the prompt text optimization strategy.
[0016] In one of the embodiments, it also includes: using a pre-trained grammar detection model to classify the grammatically correct and grammatically incorrect parts in the adversarial sample, and outputting the corresponding grammar detection result; the grammar detection model is built based on BERT and TextCNN; using pre-trained Transformers to perform binary classification of sentiment on the adversarial sample, and outputting the corresponding sentiment analysis result; using the score function of the pre-trained kenlm model, splitting each sentence of the adversarial sample into an n-gram sequence and calculating the probability of each n-gram in the n-gram language model, taking the logarithm of the probability and combining to output the fluency of each sentence, and obtaining the corresponding text fluency according to the fluency of each sentence; using the perplexity function of the pre-trained kenlm model to calculate the perplexity of each sentence of the adversarial sample, and obtaining the corresponding text perplexity.
[0017] In one of the embodiments, it also includes: performing word segmentation on the adversarial sample and the original input text, and calculating the semantic similarity between the adversarial sample and the original input text using cosine value, LSA, LDA and Word2vec dictionary respectively, to obtain corresponding first semantic similarity detection result, second semantic similarity detection result, third semantic similarity detection result and fourth semantic similarity detection result.
[0018] In one of the embodiments, it also includes: obtaining corresponding expressiveness test results based on the vocabulary density of the adversarial sample; obtaining corresponding stubbornness test results based on the repetition rate of repeated content words in the adversarial sample; and obtaining corresponding introversion test results based on the pronoun density in the adversarial sample.
[0019] A personality feature anti-detection device based on semantic constraints, the device comprising:
[0020] A template construction module is used to generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, a knowledge prompt and a task description; the system role includes a model role and a task requirement; the knowledge prompt includes a personality type and a language style; the task description includes a task flow and an input and output format;
[0021] A sample generation module is used to load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample;
[0022] A sample detection module is used to perform quantitative detection on the adversarial sample using a text adversarial sample evaluation index system, and determine whether the adversarial sample is qualified based on the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection;
[0023] The sample optimization module is used to optimize the prompt text according to the evaluation result if the adversarial sample fails, iterate the above process until the evaluation result of the adversarial sample passes, stop the iteration, and output the current adversarial sample.
[0024] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0025] Generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, knowledge prompts and a task description; the system role includes a model role and task requirements; the knowledge prompts include personality type and language style; the task description includes a task flow and input and output formats;
[0026] Load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample;
[0027] A text adversarial sample evaluation index system is used to perform quantitative detection on the adversarial sample, and whether the adversarial sample is qualified is determined based on the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection;
[0028] If the adversarial sample fails, the prompt text is optimized according to the evaluation result, and the above process is iterated until the evaluation result of the adversarial sample passes, then the iteration is stopped and the current adversarial sample is output.
[0029] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0030] Generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, knowledge prompts and a task description; the system role includes a model role and task requirements; the knowledge prompts include personality type and language style; the task description includes a task flow and input and output formats;
[0031] Load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample;
[0032] A text adversarial sample evaluation index system is used to perform quantitative detection on the adversarial sample, and whether the adversarial sample is qualified is determined based on the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection;
[0033] If the adversarial sample fails, the prompt text is optimized according to the evaluation result, and the above process is iterated until the evaluation result of the adversarial sample passes, then the iteration is stopped and the current adversarial sample is output.
[0034] The above-mentioned personality feature anti-detection method, device and computer equipment based on semantic constraints can enable the large model to output personality types and language styles that meet the task requirements by initializing the prompt text template based on the pre-set system role, knowledge prompt and task description, loading the original input text into the prompt text template to obtain the prompt text, inputting the prompt text into the LLM large model, outputting the adversarial sample, performing semantic similarity detection, text detection and psychological feature detection on the adversarial sample, judging whether the adversarial sample is qualified according to the size relationship between the detection result and the preset threshold, and if the adversarial sample is unqualified, optimizing the prompt text according to the evaluation result, iterating the above process until the evaluation result of the adversarial sample is qualified, stopping the iteration, and outputting the current adversarial sample. Through this optimization process, the present invention ensures that the personality feature information implicit in the text adversarial sample is fully protected, while effectively reducing the difference between the adversarial sample and the original text in the dimensions of semantics, emotion, etc. The embodiment of the present invention can improve the naturalness and credibility of the adversarial sample and realize personality privacy protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 1 is a flow chart of a personality feature anti-detection method based on semantic constraints in one embodiment;
[0036] Figure 2 A schematic diagram of a framework for generating adversarial samples based on personality semantic constraints in one embodiment;
[0037] Figure 3 A schematic diagram of a prompt text optimization framework based on adversarial sample evaluation in one embodiment;
[0038] Figure 4 A schematic diagram of the structure of a personality detection model in one embodiment;
[0039] Figure 5 A schematic diagram of the structure of a grammar detection model in one embodiment;
[0040] Figure 6 A schematic diagram of the structure of a Transformers sentiment binary classification model in one embodiment;
[0041] Figure 7 is a structural block diagram of a personality feature anti-detection device based on semantic constraints in one embodiment;
[0042] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] The technical problems to be solved by the present invention include how to implement an adversarial sample generation method based on personality semantic constraints and how to implement a prompt text optimization method based on adversarial sample evaluation. In the present invention, the adversarial sample generation method based on personality semantic constraints is to use the prompt engineering method to design appropriate prompt text templates, and through these templates, guide the large-scale language model to generate corresponding adversarial samples based on specific personality semantic styles, while keeping the semantics of the original input text unchanged. The prompt text optimization method based on adversarial sample evaluation is to use the evaluation index system to perform quantitative detection on the generated samples, match the quantitative test results with the prompt text optimization strategy designed and implemented, and adjust the optimized prompt text according to the optimization strategy. Then use the optimized prompt text to redirect the large-scale language model and regenerate the corresponding text adversarial samples, so that the generated text adversarial samples can show better results in the evaluation index system.
[0045] In one embodiment, Figure 1 As shown, a personality feature anti-detection method based on semantic constraints is provided, comprising the following steps:
[0046] Step 102, initializing a prompt text template according to a preset adversarial sample generation task.
[0047] like Figure 2 The schematic diagram of the adversarial sample generation framework based on personality semantic constraints is shown, where the prompt text template includes system role, knowledge prompt and task description; the system role includes model role and task requirements; the knowledge prompt includes personality type and language style; the task description includes task flow and input and output formats.
[0048] System roles involve setting a clear role for a large-scale language model (LLM) to specify its style and tasks. Since system instructions have a higher weight than other manually input prompt texts and can maintain stability in multiple rounds of dialogue, it can effectively control the style and behavior of LLM. In an embodiment of the present invention, LLM is set to play the role of a text editor with a specific MBTI language style to ensure that the language style of the generated adversarial sample is consistent with the input MBTI personality characteristics.
[0049] Knowledge hints are designed to provide large-scale language models with the knowledge required to complete specific tasks, guide the model to answer based on relevant knowledge, thereby reducing the possibility of false content in the output and improving the accuracy and credibility of the results. Here, the embodiment of the present invention provides the model with knowledge and language style about a specific MBTI (Myers-Briggs Type Indicator) personality specified by the user, but does not include knowledge and language styles of other MBTI personalities, so as to prevent the model from generating samples that do not meet the requirements.
[0050] In the prompt engineering, the task description part usually details the workflow that the large-scale language model needs to complete and provides input and output formats. In the embodiment of the present invention, the model is provided with input and output formats, and is required to rewrite the input text according to the knowledge prompt and the specified MBTI personality, while retaining the semantics of the original text to generate adversarial samples that meet the semantic constraints of the specific MBTI personality. At the same time, it is emphasized that the model does not need to perform other tasks.
[0051] The user input aims to process the text information provided by the user into the input format specified in the task description and input it into the large-scale language model so that the model can generate adversarial samples that conform to specific MBTI personality traits.
[0052] In the prompt text, the design of the model's answer usually repeats the key content of the prompt text to strengthen the model's understanding of the prompt text and improve the effectiveness of the prompt text.
[0053] It can be understood that in addition to MBTI personality anti-detection, by adjusting the above-mentioned prompt engineering, the method of the present invention is also applicable to anti-detection of other personality classification methods.
[0054] Step 104, load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample.
[0055] In the embodiment of the present invention, the English large-scale language model uses mistral-7B, and the Chinese large-scale language model uses Qwen-7B. Both models are lightweight and can run on a computing device equipped with 24GB of video memory. Based on the existing computing resources, the open source models mistral-7B and Qwen-7B with excellent performance were selected for deployment and application.
[0056] After building a prompt template that matches the user input, the program will select and call the corresponding large-scale language model based on the language used by the user. These models will follow the established format requirements and generate semantically constrained adversarial samples that match the specified MBTI personality as output results.
[0057] Step 106, using the text adversarial sample evaluation index system to perform quantitative detection on the adversarial sample, and judging whether the adversarial sample is qualified based on the relationship between the detection result and the preset threshold.
[0058] The text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection. The present invention proposes a comprehensive text adversarial sample evaluation index system, which aims to accurately extract and analyze the subtle differences between the generated adversarial samples and the original text. By using this evaluation index system, the method of the present invention can effectively reduce the differences between the adversarial samples and the original text in semantics, emotions and other dimensions while ensuring that the personality feature information implicit in the text adversarial samples is fully protected. This reduction in differences helps to improve the naturalness and credibility of the adversarial samples and make them more effective in practical applications.
[0059] Step 108, if the adversarial sample fails, the prompt text is optimized according to the evaluation result, and the above process is iterated until the evaluation result of the adversarial sample passes, then the iteration is stopped and the current adversarial sample is output.
[0060] The core goal of the prompt text optimization technology based on adversarial sample evaluation is to maximize the potential of large-scale language models and improve the quality of adversarial samples. Figure 3 As shown, under this framework, the present invention uses the evaluation index system to perform quantitative detection on the generated samples, matches the quantitative test results with the prompt text optimization strategy designed and implemented, and adjusts the optimized prompt text according to the optimization strategy. The optimized prompt text is then used to redirect the large-scale language model and regenerate the corresponding text adversarial samples, so that the generated text adversarial samples can perform better in the evaluation index system. Through this prompt text optimization process, not only can the quality of adversarial samples be successfully improved, but also the behavioral characteristics of large-scale language models can be more deeply understood, providing valuable experience and data support for future research and applications.
[0061] In the above-mentioned personality feature anti-detection method based on semantic constraints, by initializing the prompt text template based on the pre-set system role, knowledge prompt and task description, the large model can output the personality type and language style that meet the task requirements, load the original input text into the prompt text template, obtain the prompt text, input the prompt text into the LLM large model, output the adversarial sample, perform semantic similarity detection, text detection and psychological feature detection on the adversarial sample, judge whether the adversarial sample is qualified according to the size relationship between the detection result and the preset threshold, if the adversarial sample is unqualified, optimize the prompt text according to the evaluation result, iterate the above process until the evaluation result of the adversarial sample is qualified, stop the iteration, and output the current adversarial sample. Through this optimization process, the present invention ensures that the personality feature information implicit in the text adversarial sample is fully protected, while effectively reducing the difference between the adversarial sample and the original text in the dimensions of semantics, emotion, etc. The embodiment of the present invention can improve the naturalness and credibility of the adversarial sample and realize personality privacy protection.
[0062] In one embodiment, the method also includes: obtaining adversarial samples corresponding to multiple original input texts, inputting the multiple adversarial samples into a pre-trained personality detection model, and outputting corresponding prediction results; the multiple original input samples correspond to multiple posts of the same user; verifying the validity of the adversarial samples based on the prediction results and the user's real personality, if the prediction results are consistent with the real personality, adjusting the preset threshold and re-optimizing the prompt text until the prediction results are inconsistent with the real personality.
[0063] In this embodiment, the goal is to solve the problem of how to generate high-quality adversarial samples for a personality detection model with strong detection capabilities. The designed personality detection model can obtain implicit user MBTI personality traits from multiple social posts of the user, and achieve accurate prediction of the user's MBTI personality. By testing the effectiveness of adversarial samples through the personality detection model, the ability of adversarial samples to mislead personality trait detection technology can be improved.
[0064] In one embodiment, the personality detection model includes an encoding module, an L2C module and a deep graph convolution module. Multiple adversarial samples are input into a pre-trained personality detection model, and the corresponding prediction results are outputted, including: inputting multiple adversarial samples into the encoding module, encoding each adversarial sample into a content vector through the encoding module, and outputting a content vector sequence corresponding to the multiple samples; initializing the embedding representation of the content vector sequence and the user node through the deep graph convolution module to obtain an initial user personality feature map, and extracting the node representation of the initial user personality feature map; the initial user personality feature map includes a user node and multiple adversarial sample nodes; optimizing the node connection relationship between the node representation output by the previous layer of the deep graph convolution module through the L2C module, and outputting the optimized user personality feature map to the deep graph convolution module; updating the node representation of the next layer according to the optimized user personality feature map through the deep graph convolution module, iteratively optimizing the user personality feature map, and outputting the prediction results.
[0065] In this embodiment, although MBTI personality detection can be naturally regarded as a multi-label classification task, the input of this task is not a document but a set of posts (short documents) that are not related to the topic, and each post does not necessarily contain clues that suggest personality. Therefore, building a personality detection model that can accurately obtain hidden information from a large amount of information is crucial to obtaining high-quality adversarial samples. The input of the personality detection model is multiple adversarial samples, which are generated by constructing prompt texts of multiple social posts of users and inputting them into a large language model after optimization.
[0066] Use the graph-based dynamic deep graph convolutional network (D-DGCN) to implement multi-classification tasks of personality traits, such as Figure 4 The structure diagram of the personality detection model shown in the figure. D-DGCN includes BERT as the post-encoder and two interactive modules (L2C and DGCN). The personality trait detection task is formally defined. Taking user posts as an example, given a set of user posts ,in is the i-th post containing M tokens, and the goal is to predict the personality characteristics of this user in T different dimensions , a graph is constructed to represent the user's posts, where each post is represented as a node and initialized by embedding the pre-trained BERT model. In addition, a special node representing the user is added to facilitate personality feature classification. In addition, considering that the connection between two nodes is established non-deterministically, a multi-hop based learning connection (L2C) module is added. This module has a differentiable threshold function and can automatically build basic edges layer by layer to better adapt and expand to different samples. In order to solve the problem that traditional graph neural networks (GCNs) cannot stack multiple layers due to over-smoothing problems, a deep graph convolutional network (DGCN) is applied to collect useful information from posts in a larger receptive field to remedy smoothing.
[0067] Specifically, the post encoding process includes:
[0068] Use BERT to encode each post separately. Posts Content vector for:
[0069] ;
[0070] in is the final hidden layer of “[CLS]” in the BERT model, and d is the dimension of the result. Based on the N posts input by the user, a set of content vectors can be obtained .
[0071] The learning connection process includes:
[0072] Get the content vector of the user's post , using DGCN to fuse them in an unordered way. First, use a graph to represent each user, the nodes in the graph represent the user's posts, and put special user nodes in the graph Aggregate information from other nodes to generate user representations that facilitate personality trait classification. The initial representation of all nodes is .
[0073] A learning method is used to build representations based on appropriate nodes. Each layer of the L2C module dynamically adjusts the learned graph based on the output of the previous DGCN layer, then passes the new graph back to the DGCN and updates the node representation of the next layer.
[0074] Used to indicate the Adjacency matrix of layer graph The calculation is as follows:
[0075] ;
[0076] For DGCN The node representation generated by the layer is Determine whether there is an edge between two nodes, such as Figure 4 As shown, two MLP layers are introduced to implement this function. Indicates query and key value, L2C module computing node The adjacency weight for:
[0077] ;
[0078] in is the sigmoid function, and For Node In DGCN The layer representation, and is a layer-specific linear transformation, d and hid are the dimensions of the post and MLP hidden layer, respectively.
[0079] For the construction of the L2C module differentiable function, first normalize the adjacency weights :
[0080] ;
[0081] in Indicates that the gradient is combined with Separation, to prevent overflow.
[0082] The mask matrix is then used to produce the final adjacency matrix , set the threshold , Elements in It is calculated as follows:
[0083] ;
[0084] In order to enhance the ability of L2C module to remove unnecessary edges, we introduce Regularization (Hard Concreted distribution) reduces the number of graph connections:
[0085] ;
[0086] In the deep graph convolution part, the adjacency matrix is dynamically calculated and the post-embedding layer is fed into GCNs for encoding. The propagation and conversion process of GCNs is as follows:
[0087] ;
[0088] in is a normalized symmetric adjacency matrix. To prevent transition smoothness from limiting the performance of the L2C module, DGCN is applied to separate the conversion and propagation operations. For DGCN, its update node is expressed as follows:
[0089] ;
[0090] Compared with the original GCNs propagation and conversion process, the above formula does not have a scientific transformation matrix , which only includes propagation operations. After L layers of iteration, the node representation of each layer is obtained:
[0091] ;
[0092] in is the initial node representation, Contains node information from the bottom and top layers, and then uses a trainable projection vector Identify key layers:
[0093] ;
[0094] in is the sigmoid function, Used to reshape the matrix for further calculations. Get the final node :
[0095] ;
[0096] in is the matrix multiplication of the last two dimensions.
[0097] As mentioned in the learning connection section, the output of DGCN Contains a special node based on the user .based on , using linear transformation and softmax function to predict personality traits:
[0098] ;
[0099] in is a trainable weight matrix, is the bias term, is the number of training samples, It is The true label of the individual personality trait dimension, It is in the parameter The predicted probability under this dimension. Personality traits use cross entropy loss function and incorporate adaptive Lagrange multipliers , the entire objective function is defined as:
[0100] ;
[0101] Through the above processing, implicit personality features can be obtained from a large number of social posts with no significant correlation. The above D-DGCN is used to predict the personality of the adversarial sample corresponding to the user. If the predicted result is the target personality used to guide the large model in the knowledge prompt, the adversarial sample is valid. If the predicted result is the user's true personality, the adversarial sample is invalid and the prompt text needs to be further optimized.
[0102] In one embodiment, a text adversarial sample evaluation index system is used to perform quantitative detection on the adversarial sample, and judging whether the adversarial sample is qualified based on the size relationship between the detection result and the preset threshold value includes: obtaining the adversarial sample, performing text detection on the adversarial sample, and obtaining a text detection result. If the text detection result is greater than or equal to a first threshold, a semantic similarity detection is performed to obtain a semantic similarity detection result, otherwise, the prompt text is optimized according to a preset prompt text optimization strategy; if the semantic similarity detection result is greater than or equal to a second threshold, a psychological feature detection is performed to obtain a psychological feature detection result, otherwise, the prompt text is optimized according to the prompt text optimization strategy; if the psychological feature detection result is greater than or equal to a third threshold, the current adversarial sample is determined to be qualified, otherwise, the prompt text is optimized according to the prompt text optimization strategy.
[0103] In one embodiment, text detection is performed on the adversarial sample to obtain the text detection result, including: using a pre-trained grammar detection model to classify the grammatically correct and grammatically incorrect parts of the adversarial sample, and outputting the corresponding grammar detection result; the grammar detection model is built based on BERT and TextCNN; using pre-trained Transformers to perform sentiment binary classification on the adversarial sample, and outputting the corresponding sentiment analysis result; using the score function of the pre-trained kenlm model, each sentence of the adversarial sample is split into an n-gram sequence and the probability of each n-gram in the n-gram language model is calculated, the probability is taken logarithm and combined to output the fluency of each sentence, and the corresponding text fluency is obtained according to the fluency of each sentence; using the perplexity function of the pre-trained kenlm model to calculate the perplexity of each sentence of the adversarial sample, and obtain the corresponding text perplexity.
[0104] In this embodiment, for grammar detection, such as Figure 5The structural diagram of the grammar detection model shown in the figure shows that the present invention uses BERT + TextCNN to process complex grammar detection. BERT has 12 encoder layers in addition to the first input layer. The first token (CLS) vector of each encoder layer is regarded as a sentence vector, that is, the shallower the encoder layer, the more the sentence vector can represent low-level semantic information; the shallower and deeper the encoder layer, the higher-level semantic information it represents. The CLS vectors of the 1st to 12th layers are used as the input of CNN for classification, which not only obtains the features of the relevant words, but also retains their semantic features. Using a grammar correction dataset, the grammatically incorrect / correct text labels are marked as 0 / 1, and Chinese and English are trained separately. The adversarial samples are input into the pre-trained grammar detection model, and the grammar detection results of the adversarial samples are output.
[0105] For sentiment analysis, since film reviews have sufficient emotional color, the embodiment of the present invention uses the alimdb film review dataset as a training set, performs binary classification of sentiment based on Transformers, labels negative / positive comments as 0 / 1, and trains in Chinese and English separately, such as Figure 6 The structural diagram of the Transformers sentiment binary classification model shown in the figure inputs the adversarial sample into the pre-trained Transformers sentiment binary classification model and outputs the sentiment analysis result of the adversarial sample.
[0106] For text fluency detection, use the n-gram language model. For a given sentence: The smallest unit of the adversarial sample is a word or phrase, and the n-gram language model is used to evaluate the probability of this sentence being true:
[0107] ;
[0108] For each of the small items Estimate probabilities using frequencies:
[0109] ;
[0110] That is, in the current adversarial sample The number of times the joint occurs.
[0111] Strong assumption based on the n-gram language model: the probability distribution of the current word is only related to the previous N-1 words, so , use the lmplz module of the kenlm model, train the Chinese-English bilingual kenlm model on the xnli dataset, use the score function of the kenlm language model, split the sentence into n-gram sequences and calculate the probability of each n-gram in the language model, and then take the logarithm of the probability to combine it into the fluency score of the entire sentence. The fluency score of the comprehensive sentence is used to obtain the fluency test result of the adversarial sample.
[0112] For text perplexity, the perplexity estimates the probability of the sentence appearing based on each word in the sentence and normalizes it by the sentence length. The smaller the perplexity, the higher the probability of the sentence appearing:
[0113] ;
[0114] We also use the Chinese-English bilingual kenlm model trained on the xnli dataset, and use the perplexity function of kenlm.LanguageModel to present the perplexity of the sentence, thereby obtaining the perplexity detection result of the adversarial sample.
[0115] In one embodiment, performing semantic similarity detection and obtaining semantic similarity detection results includes: performing word segmentation on the adversarial sample and the original input text, and calculating the semantic similarity of the adversarial sample and the original input text using cosine value, LSA, LDA and Word2vec dictionary respectively, to obtain corresponding first semantic similarity detection results, second semantic similarity detection results, third semantic similarity detection results and fourth semantic similarity detection results.
[0116] In this embodiment, semantic similarity is mainly based on a Chinese-English bilingual corpus training model or extraction vector and dictionary. After using a word segmenter to segment the sentences, the semantic similarity of the two sentences is calculated using cosine value, LSA, LDA and Word2vec dictionary.
[0117] For the evaluation of cosine similarity, cosine similarity uses the cosine value of the angle between two vectors in the vector space as a measure of the size of the difference between two individuals. When considering using cosine similarity to calculate the semantic similarity of two texts, the main difficulty and work is to encode the two texts into n-dimensional vectors. The pre-trained BERT model corresponding to Chinese and English is used to complete the encoding task, and fine-tuned on datasets such as the Chinese and English social corpus xnli. The BERT model is a pre-trained model, and its main design purpose is to learn the semantic relationship of the input. Therefore, the BERT model uses the Transformer Encoder encoder instead of the Transformer Decoder decoder. It only encodes the input sentence without decoding. The last hidden layer of the BERT model output is extracted to obtain the vector of the encoded input sentence. The vectors obtained by the BERT model of the two sentences are calculated to obtain the semantic similarity of the two sentences. Based on the semantic similarity between the original input text and the corresponding adversarial sample sentences, the first semantic similarity detection result is obtained.
[0118] The present invention adopts LSA topic model to evaluate topic similarity. LSA topic model aims to extract concepts or topics hidden behind words and perform semantic analysis and similarity calculation from the perspective of semantic understanding. LSA model performs truncated singular value analysis on the traditional word-text matrix and decomposes it into the product of three small matrices (word-topic matrix, topic-topic matrix, topic-text matrix). Based on Python's genism library, Chinese-English bilingual LSA model is trained using zhwiki and COCA_newspaper Chinese-English bilingual corpus, and its dictionary is saved for sentence similarity calculation. Based on the semantic similarity between the original input text and each sentence of the corresponding adversarial sample, the second semantic similarity detection result is obtained.
[0119] The present invention also adopts the LDA probabilistic graph model to evaluate topic similarity, which is different from the LSA topic model. The LSA model is a linear model and is not very effective in dealing with nonlinear problems. LDA is a probabilistic graph model for topic modeling, which gives the topic of each document in the document set in the form of probability distribution. The basic idea of LDA topic modeling is that each document is mixed with a set of topics, and each topic is composed of a set of words. LDA attempts to find the best combination of topics and words to explain the given text data. Based on the Python genism library, the Chinese-English bilingual LDA model is trained using the zhwiki and COCA_newspaper Chinese-English bilingual corpora, and its dictionary is saved for sentence similarity calculation. Based on the semantic similarity between the original input text and the corresponding adversarial sample sentences, the third semantic similarity detection result is obtained.
[0120] The present invention uses the Word2vec dictionary to effectively encode the semantic information of the adversarial sample and the original input text, thereby calculating the fourth semantic similarity detection result. Word2Vec uses a neural network architecture (such as CBOW or Skip-Gram) to learn the distributed representation of vocabulary, which implicitly models the complex semantic relationship between words. During the training process, the model optimizes the vocabulary vector by maximizing the conditional probability of predicting the target vocabulary, thereby achieving effective encoding of semantic information.
[0121] In one embodiment, psychological feature detection is performed to obtain psychological feature detection results including: obtaining corresponding expressiveness detection results based on the vocabulary density of the adversarial sample; obtaining corresponding stubbornness detection results based on the repetition rate of repeated content words in the adversarial sample; and obtaining corresponding introversion detection results based on the pronoun density in the adversarial sample.
[0122] In this embodiment, the psychological feature detection includes the detection of expressiveness, stubbornness and introversion, wherein the expressiveness detection result is represented by the vocabulary density, which represents the ratio of the number of different words in the text to the total number of words. A higher vocabulary density indicates that the individual has a rich vocabulary and expressiveness. Based on spacy's zh_core_web_sm and en_core_web_sm Chinese-English bilingual dictionaries, using jieba Chinese word segmentation and English natural word segmentation, the ratio of the number of different words in the original input text and the generated adversarial sample to the total number of words is calculated to obtain the expressiveness scores of the two posts, and the change amount is normalized.
[0123] The results of the stubbornness test are reflected by repeated content, repeated content words and the ratio of repeated content words to pronoun words, which reflects the degree to which the individual repeats words in his expression. A higher repetition rate indicates that the individual has stubborn or conservative personality traits.
[0124] The results of the introversion test are reflected by pronoun density, which reflects the frequency and degree of pronouns used by individuals in their expressions. A higher pronoun density and proportion indicate that individuals tend to use first-person pronouns and have egocentric or introverted personality traits.
[0125] In one embodiment, in order to improve the performance of adversarial samples in the designed evaluation index system, three sets of refined prompt text optimization strategies are designed for the three key modules of semantic similarity, text detection and personality detection. These strategies are intended to enhance the semantic consistency between adversarial samples and original texts, reduce the possibility of being recognized by the text detection system, and hide the accurate expression of real personality traits.
[0126] Minimum rating threshold : Extract adversarial samples and score them using the designed evaluation index system to continuously explore the potential of prompt text optimization.
[0127] Semantic similarity: As the primary constraint of the present invention, the present invention uses four dimensions of cosine distance, LSA, Word2Vec, and LDA to quantitatively evaluate the semantic similarity of texts.
[0128] Text detection: As the key to text generation, it includes four dimensions: grammar detection, sentiment analysis, text perplexity, and text fluency. Grammatical errors are absolutely not allowed in text generation. For adversarial samples with low grammar detection scores, the prompt will be reconstructed to generate new text adversarial samples. Sentiment analysis, text perplexity, and text fluency use μ to determine whether to regenerate.
[0129] Personality detection: It is the target of the present invention. The following indicators are selected for quantitative evaluation in the evaluation index system, including four dimensions: personality traits, expressive ability, stubbornness and introversion. The prompt text optimization is generated by screening the similarity between the adversarial samples and the original text in the above four dimensions, so that the adversarial samples are far away from the original text in each dimension in the personality detection module.
[0130] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0131] In one embodiment, Figure 7 As shown, a personality feature anti-detection device based on semantic constraints is provided, comprising:
[0132] The template construction module 702 is used to generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, a knowledge prompt and a task description; the system role includes a model role and a task requirement; the knowledge prompt includes a personality type and a language style; the task description includes a task flow and an input and output format;
[0133] The sample generation module 704 is used to load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample;
[0134] The sample detection module 706 is used to perform quantitative detection on the adversarial sample using the text adversarial sample evaluation index system, and judge whether the adversarial sample is qualified according to the relationship between the detection result and the preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection;
[0135] The sample optimization module 708 is used to optimize the prompt text according to the evaluation result if the adversarial sample fails, iterate the above process until the evaluation result of the adversarial sample passes, stop the iteration, and output the current adversarial sample.
[0136] In one of the embodiments, it is also used to obtain adversarial samples corresponding to multiple original input texts, input the multiple adversarial samples into a pre-trained personality detection model, and output corresponding prediction results; the multiple original input samples correspond to multiple posts of the same user; the validity of the adversarial samples is verified according to the prediction results and the user's real personality, and if the prediction result is consistent with the real personality, the preset threshold is adjusted and the prompt text is re-optimized until the prediction result is inconsistent with the real personality.
[0137] In one embodiment, the personality detection model includes an encoding module, an L2C module and a deep graph convolution module. Multiple adversarial samples are input into a pre-trained personality detection model, and the corresponding prediction results are outputted, including: inputting multiple adversarial samples into the encoding module, encoding each adversarial sample into a content vector through the encoding module, and outputting a content vector sequence corresponding to the multiple samples; initializing the embedding representation of the content vector sequence and the user node through the deep graph convolution module to obtain an initial user personality feature map, and extracting the node representation of the initial user personality feature map; the initial user personality feature map includes a user node and multiple adversarial sample nodes; optimizing the node connection relationship between the node representation output by the previous layer of the deep graph convolution module through the L2C module, and outputting the optimized user personality feature map to the deep graph convolution module; updating the node representation of the next layer according to the optimized user personality feature map through the deep graph convolution module, iteratively optimizing the user personality feature map, and outputting the prediction results.
[0138] In one of the embodiments, it is also used to obtain adversarial samples, perform text detection on the adversarial samples, and obtain text detection results. If the text detection result is greater than or equal to a first threshold, a semantic similarity detection is performed to obtain a semantic similarity detection result, otherwise, the prompt text is optimized according to a preset prompt text optimization strategy; if the semantic similarity detection result is greater than or equal to a second threshold, a psychological feature detection is performed to obtain a psychological feature detection result, otherwise, the prompt text is optimized according to the prompt text optimization strategy; if the psychological feature detection result is greater than or equal to a third threshold, the current adversarial sample is determined to be qualified, otherwise, the prompt text is optimized according to the prompt text optimization strategy.
[0139] In one of the embodiments, a pre-trained grammar detection model is used to classify the grammatically correct and grammatically incorrect parts in the adversarial sample, and output the corresponding grammar detection result; the grammar detection model is built based on BERT and TextCNN; pre-trained Transformers are used to perform binary classification of sentiment on the adversarial sample, and the corresponding sentiment analysis result is output; the score function of the pre-trained kenlm model is used to split each sentence of the adversarial sample into an n-gram sequence and calculate the probability of each n-gram in the n-gram language model, and the probability is taken logarithm and combined to output the fluency of each sentence, and the corresponding text fluency is obtained according to the fluency of each sentence; the perplexity function of the pre-trained kenlm model is used to calculate the perplexity of each sentence of the adversarial sample to obtain the corresponding text perplexity.
[0140] In one of the embodiments, it is also used to segment the adversarial sample and the original input text, and calculate the semantic similarity of the adversarial sample and the original input text using cosine value, LSA, LDA and Word2vec dictionary, to obtain the corresponding first semantic similarity detection result, second semantic similarity detection result, third semantic similarity detection result and fourth semantic similarity detection result.
[0141] In one of the embodiments, it is also used to obtain corresponding expressiveness test results based on the vocabulary density of the adversarial sample; to obtain corresponding stubbornness test results based on the repetition rate of repeated content words in the adversarial sample; and to obtain corresponding introversion test results based on the pronoun density in the adversarial sample.
[0142] For the specific definition of the personality trait anti-detection device based on semantic constraints, please refer to the definition of the personality trait anti-detection method based on semantic constraints above, which will not be repeated here. Each module in the above-mentioned personality trait anti-detection device based on semantic constraints can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0143] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a personality feature anti-detection method based on semantic constraints is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0144] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0145] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in the above embodiment when executing the computer program.
[0146] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method in the above embodiment are implemented.
[0147] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0148] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present invention shall be subject to the attached claims.
Claims
1. A personality feature anti-detection method based on semantic constraints, characterized in that: The method comprises: Generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, knowledge prompts and a task description; the system role includes a model role and task requirements; the knowledge prompts include personality type and language style; the task description includes a task flow and input and output formats; Load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample; A text adversarial sample evaluation index system is used to quantitatively detect the adversarial sample, and whether the adversarial sample is qualified is determined based on the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection; If the adversarial sample fails, the prompt text is optimized according to the evaluation result, and the above process is iterated until the evaluation result of the adversarial sample passes, then the iteration is stopped and the current adversarial sample is output; The text adversarial sample evaluation index system is used to quantitatively detect the adversarial sample, and judging whether the adversarial sample is qualified according to the relationship between the detection result and the preset threshold value includes: Acquire an adversarial sample, perform text detection on the adversarial sample, and obtain a text detection result. If the text detection result is greater than or equal to a first threshold, perform semantic similarity detection to obtain a semantic similarity detection result. Otherwise, optimize the prompt text according to a preset prompt text optimization strategy. If the semantic similarity detection result is greater than or equal to the second threshold, then performing psychological feature detection to obtain a psychological feature detection result; otherwise, optimizing the prompt text according to the prompt text optimization strategy; If the psychological feature detection result is greater than or equal to the third threshold, the current adversarial sample is determined to be qualified, otherwise, the prompt text is optimized according to the prompt text optimization strategy; The method further comprises: Acquire adversarial samples corresponding to multiple original input texts, input the multiple adversarial samples into a pre-trained personality detection model, and output corresponding prediction results; the multiple original input samples correspond to multiple posts of the same user; Verify the effectiveness of the adversarial sample based on the prediction result and the user's real personality. If the prediction result is consistent with the real personality, adjust the preset threshold and re-optimize the prompt text until the prediction result is inconsistent with the real personality. The personality detection model includes an encoding module, an L2C module and a deep graph convolution module. Multiple adversarial samples are input into the pre-trained personality detection model, and the corresponding prediction results are output including: Inputting multiple adversarial samples into an encoding module, encoding each adversarial sample into a content vector through the encoding module, and outputting a content vector sequence corresponding to the multiple samples; Initializing the embedding representation of the content vector sequence and the user node through the deep graph convolution module to obtain an initial user personality feature graph, and extracting the node representation of the initial user personality feature graph; the initial user personality feature graph includes a user node and multiple adversarial sample nodes; The L2C module optimizes the node representation output by the previous layer of the deep graph convolution module for the connection relationship between nodes, and outputs the optimized user personality feature map to the deep graph convolution module; The deep graph convolution module updates the node representation of the next layer according to the optimized user personality feature graph, iteratively optimizes the user personality feature graph, and outputs the prediction result.
2. The method according to claim 1, characterized in that: Perform text detection on adversarial samples, and the text detection results include: A pre-trained grammar detection model is used to classify the grammatically correct and grammatically incorrect parts of the adversarial sample, and the corresponding grammar detection results are output; the grammar detection model is built based on BERT and TextCNN; Use pre-trained Transformers to perform binary classification of sentiment on adversarial samples and output the corresponding sentiment analysis results; Using the score function of the pre-trained KenLM model, each sentence of the adversarial sample is split into an n-gram sequence and the probability of each n-gram in the n-gram language model is calculated. The logarithm of the probability is taken and the fluency of each sentence is combined and output. The corresponding text fluency is obtained according to the fluency of each sentence. The perplexity function of the pre-trained kenlm model is used to calculate the perplexity of each sentence of the adversarial sample and obtain the corresponding text perplexity.
3. The method according to claim 1, characterized in that Perform semantic similarity detection, and obtain semantic similarity detection results including: The adversarial sample and the original input text are segmented, and the semantic similarity of the adversarial sample and the original input text is calculated using cosine value, LSA, LDA and Word2vec dictionary respectively to obtain corresponding first semantic similarity detection result, second semantic similarity detection result, third semantic similarity detection result and fourth semantic similarity detection result.
4. The method according to claim 1, characterized in that: Perform psychological feature detection, and obtain psychological feature detection results including: According to the vocabulary density of the adversarial sample, the corresponding expression ability test results are obtained; According to the repetition rate of repeated content words in the adversarial sample, the corresponding stubbornness detection result is obtained; According to the pronoun density in the adversarial sample, the corresponding introversion degree detection result is obtained.
5. A personality feature anti-detection device based on semantic constraints, characterized in that: The device comprises: A template construction module is used to generate a task initialization prompt text template according to a preset adversarial sample; the prompt text template includes a system role, a knowledge prompt and a task description; the system role includes a model role and a task requirement; the knowledge prompt includes a personality type and a language style; the task description includes a task flow and an input and output format; A sample generation module is used to load the original input text into the prompt text template to obtain the prompt text, input the prompt text into the LLM large model, and output the adversarial sample; A sample detection module is used to perform quantitative detection on the adversarial sample using a text adversarial sample evaluation index system, and judge whether the adversarial sample is qualified according to the relationship between the detection result and a preset threshold; the text adversarial sample evaluation index system includes semantic similarity detection, text detection and psychological feature detection; A sample optimization module is used to optimize the prompt text according to the evaluation result if the adversarial sample fails, iterate the above process until the evaluation result of the adversarial sample passes, stop iterating, and output the current adversarial sample; The sample detection module is further used to obtain adversarial samples, perform text detection on the adversarial samples, and obtain text detection results. If the text detection result is greater than or equal to a first threshold, a semantic similarity detection is performed to obtain a semantic similarity detection result. Otherwise, the prompt text is optimized according to a preset prompt text optimization strategy. If the semantic similarity detection result is greater than or equal to a second threshold, a psychological feature detection is performed to obtain a psychological feature detection result. Otherwise, the prompt text is optimized according to the prompt text optimization strategy. If the psychological feature detection result is greater than or equal to the third threshold, the current adversarial sample is determined to be qualified, otherwise, the prompt text is optimized according to the prompt text optimization strategy; The device is also used to obtain adversarial samples corresponding to multiple original input texts, input the multiple adversarial samples into a pre-trained personality detection model, and output corresponding prediction results; the multiple original input samples correspond to multiple posts of the same user; verify the validity of the adversarial samples based on the prediction results and the user's real personality, and if the prediction results are consistent with the real personality, adjust the preset threshold and re-optimize the prompt text until the prediction results are inconsistent with the real personality; The personality detection model includes an encoding module, an L2C module and a deep graph convolution module. Multiple adversarial samples are input into the pre-trained personality detection model, and the corresponding prediction results are outputted, including: inputting multiple adversarial samples into the encoding module, encoding each adversarial sample into a content vector through the encoding module, and outputting a content vector sequence corresponding to multiple samples; initializing the embedding representation of the content vector sequence and the user node through the deep graph convolution module to obtain an initial user personality feature map, and extracting the node representation of the initial user personality feature map; the initial user personality feature map includes a user node and multiple adversarial sample nodes; optimizing the node connection relationship between nodes of the node representation output by the previous layer of the deep graph convolution module through the L2C module, and outputting the optimized user personality feature map to the deep graph convolution module; updating the node representation of the next layer according to the optimized user personality feature map through the deep graph convolution module, iteratively optimizing the user personality feature map, and outputting the prediction results.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
