CN113468334B - Ciphertext emotion classification method, device, equipment and storage medium - Google Patents

Ciphertext emotion classification method, device, equipment and storage medium Download PDF

Info

Publication number
CN113468334B
CN113468334B CN202111035746.2A CN202111035746A CN113468334B CN 113468334 B CN113468334 B CN 113468334B CN 202111035746 A CN202111035746 A CN 202111035746A CN 113468334 B CN113468334 B CN 113468334B
Authority
CN
China
Prior art keywords
vector
ciphertext
information
preset
network
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111035746.2A
Other languages
Chinese (zh)
Other versions
CN113468334A (en
Inventor
张泽鲲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202111035746.2A priority Critical patent/CN113468334B/en
Publication of CN113468334A publication Critical patent/CN113468334A/en
Application granted granted Critical
Publication of CN113468334B publication Critical patent/CN113468334B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6209Protecting access to data via a platform, e.g. using keys or access control rules to a single file or object, e.g. in a secure envelope, encrypted and accessed using a key, or with access control rules appended to the object itself
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

The invention relates to artificial intelligence and provides a ciphertext emotion classification method, device, equipment and storage medium. The method can obtain ciphertext information and a sample result, carry out occlusion processing on the ciphertext information to obtain occlusion information, generate a coding vector according to a preset coding type, obtain a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network, extract feature information of the coding vector based on the feature extraction network, input the feature information into the emotion classification network to obtain a prediction result, adjust network parameters in the preset learner according to the prediction result and the sample result to obtain a target model, obtain a ciphertext to be processed, and input the ciphertext to be processed into the target model to obtain a target result. The method and the device can improve the classification efficiency of the target result on the premise of ensuring the safety of the emotion text. In addition, the invention also relates to a block chain technology, and the target result can be stored in the block chain.

Description

Ciphertext emotion classification method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a ciphertext emotion classification method, device, equipment and storage medium.
Background
To improve security of the emotion text, the emotion text is usually encrypted. At present, when emotion analysis is performed on encrypted emotion texts, decryption is usually performed before analysis, however, in this way, not only text information leakage is easily caused, but also emotion classification efficiency is low.
Therefore, how to improve the emotion classification efficiency of the emotion text becomes a problem which needs to be solved urgently on the premise of ensuring the security of the emotion text.
Disclosure of Invention
In view of the above, it is desirable to provide a ciphertext emotion classification method, apparatus, device and storage medium, which can improve the classification efficiency of target results while ensuring the security of emotion text.
On one hand, the invention provides a ciphertext emotion classification method, which comprises the following steps:
acquiring a ciphertext sample, wherein the ciphertext sample comprises ciphertext information and a sample result;
shielding the ciphertext information to obtain shielding information;
generating a coding vector of the shielding information according to a preset coding type;
acquiring a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network;
extracting feature information of the coding vector based on the feature extraction network;
inputting the characteristic information into the emotion classification network to obtain a prediction result;
adjusting network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
when a ciphertext emotion classification request is received, acquiring a ciphertext to be processed according to the ciphertext emotion classification request;
and inputting the ciphertext to be processed into the target model to obtain a target result.
According to a preferred embodiment of the present invention, the performing the occlusion processing on the ciphertext information to obtain the occlusion information includes:
determining the total amount of all characters in the ciphertext information;
determining the shielding quantity of the ciphertext information according to a first preset proportion and the total amount of the characters, and determining the replacement quantity of the ciphertext information according to a second preset proportion and the total amount of the characters;
replacing any character in the ciphertext information based on a preset identifier until the number of the preset identifiers in the generated replacement information is the shielding number, and obtaining first information;
and extracting random characters in the first information as first characters based on the replacement number, and replacing the first characters with second characters in the first information to obtain the shielding information, wherein the second characters refer to other characters except the first characters in the first information.
According to a preferred embodiment of the present invention, the generating the coding vector of the occlusion information according to a preset coding type includes:
for any statement ciphertext in the shielding information, extracting a target character in the statement ciphertext;
acquiring a vector value corresponding to the target character from a preset vector table;
splicing the vector values according to the information positions of the target characters in the ciphertext of any statement to obtain spliced vectors;
acquiring the length of an input vector of the preset learner, and processing the spliced vector according to the length of the input vector to obtain a representation vector of any statement ciphertext;
generating a character position vector of any statement ciphertext according to the representation sequence of the any statement ciphertext in the representation vector;
generating a statement position vector of any statement ciphertext according to the statement position of any statement ciphertext in the shielding information;
generating a mask vector of the ciphertext of any statement according to the characterization vector and the splicing vector;
respectively carrying out linear transformation processing on the characterization vector, the character position vector, the statement position vector and the mask vector to obtain a first vector corresponding to the characterization vector, a second vector corresponding to the character position vector, a third vector corresponding to the statement position vector and a fourth vector corresponding to the mask vector;
calculating the average value of the first vector, the second vector, the third vector and the fourth vector in each vector dimension to obtain an initial vector of the ciphertext of any statement;
and splicing the initial vector according to the statement position to obtain the coding vector.
According to a preferred embodiment of the present invention, the adjusting the network parameters in the preset learner according to the prediction result and the sample result to obtain the target model includes:
generating a prediction representation of the prediction result according to the preset vector table, and generating a sample representation of the sample result according to the preset vector table;
calculating the ratio of the characterization difference value of the predicted characterization and the sample characterization on the sample characterization to obtain the similar distance between the predicted result and the sample result;
and adjusting the network parameters according to the similar distance until the similar distance is not reduced any more, so as to obtain the target model.
According to a preferred embodiment of the present invention, the feature extraction network includes a first network, a second network, and a normalization layer, the first network includes an attention layer, a full-link layer, and a normalization layer, and the extracting feature information of the coding vector based on the feature extraction network includes:
performing multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector;
performing linear transformation on the attention vector based on the full connection layer to obtain a transformation vector;
normalizing the transformation vector based on the regularization layer to obtain a first output vector;
inputting the coding vector and the first output vector into the second network for processing to obtain a second output vector;
and processing the first output vector and the second output vector based on the normalization layer to obtain the characteristic information.
According to a preferred embodiment of the present invention, the performing a multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector includes:
performing linear transformation on the coding vector according to a plurality of preset parameters to obtain a plurality of parameter vectors corresponding to the plurality of preset parameters;
carrying out equal-length splitting on each parameter vector according to the lengths of the parameter vectors to obtain a plurality of segmentation vectors of each parameter vector, and counting the dimension number of each segmentation length;
extracting any two parameter vectors and a characteristic parameter vector from the plurality of parameter vectors, wherein the any two parameter vectors comprise a first parameter vector and a second parameter vector;
calculating a product of each segmentation vector in the first parameter vector and the transpose of the second parameter vector, and calculating a ratio of the product in the dimension number to obtain an attention score of each segmentation vector in the first parameter vector to the second parameter vector;
performing activation processing on the attention score based on a preset function to obtain the attention probability of each segmentation vector in the first parameter vector;
and splicing the products of the attention probability and each segmentation vector in the feature parameter vector to obtain the attention vector.
According to a preferred embodiment of the present invention, the processing the first output vector and the second output vector based on the normalization layer to obtain the feature information includes:
calculating the average value of the first output vector and the second output vector to obtain a target output vector;
calculating the element mean value of all target elements in the target output vector, and calculating the element variance of all target elements in the target output vector;
calculating the ratio of the difference value of each target element in the target output vector and the element mean value to the element variance to obtain the element proportion of each target element;
acquiring a first layer parameter and a second layer parameter in the normalization layer;
calculating the parameter product of the element proportion and the first layer parameter, and calculating the sum of the parameter product and the second layer parameter to obtain the mapping element of each target element;
and replacing all target elements in the target output vector according to the mapping elements to obtain the characteristic information.
On the other hand, the invention also provides a ciphertext emotion classification device, which comprises:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a ciphertext sample, and the ciphertext sample comprises ciphertext information and a sample result;
the processing unit is used for carrying out shielding processing on the ciphertext information to obtain shielding information;
the generating unit is used for generating a coding vector of the shielding information according to a preset coding type;
the obtaining unit is used for obtaining a preset learner, and the preset learner comprises a feature extraction network and an emotion classification network;
an extraction unit configured to extract feature information of the code vector based on the feature extraction network;
the input unit is used for inputting the characteristic information into the emotion classification network to obtain a prediction result;
the adjusting unit is used for adjusting the network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
the acquiring unit is used for acquiring a ciphertext to be processed according to the ciphertext emotion classification request when the ciphertext emotion classification request is received;
the input unit is further configured to input the ciphertext to be processed into the target model, so as to obtain a target result.
In another aspect, the present invention further provides an electronic device, including:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the ciphertext emotion classification method.
In another aspect, the present invention further provides a computer-readable storage medium, where computer-readable instructions are stored, and the computer-readable instructions are executed by a processor in an electronic device to implement the ciphertext emotion classification method.
According to the technical scheme, the context prediction capability of the target model can be improved by shielding the ciphertext information, the coding vector is generated according to the preset coding type, the coding vector input into the preset learner can have information of the ciphertext information in multiple dimensions, the network parameters can be adjusted by using the ciphertext information which cannot be accurately represented, and the prediction accuracy of the target model is improved. In addition, the ciphertext to be processed is directly analyzed without being decrypted, so that the information leakage after decryption can be avoided, the safety of the ciphertext to be processed is improved, the time consumption for decrypting the ciphertext to be processed can be saved, and the generation efficiency of the target result is improved.
Drawings
FIG. 1 is a flowchart of a preferred embodiment of the method for classifying ciphertext emotions of the present invention.
FIG. 2 is a functional block diagram of the ciphertext emotion classification apparatus according to the preferred embodiment of the present invention.
FIG. 3 is a schematic structural diagram of an electronic device implementing the method for classifying ciphertext emotions according to the preferred embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flowchart illustrating a preferred embodiment of the method for classifying ciphertext emotions according to the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The ciphertext emotion classification method can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The ciphertext emotion classification method is applied to one or more electronic devices, and the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored computer readable instructions, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), a smart wearable device, and the like.
The electronic device may include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network electronic device, an electronic device group consisting of a plurality of network electronic devices, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network electronic devices.
The network in which the electronic device is located includes, but is not limited to: the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
And S10, acquiring a ciphertext sample, wherein the ciphertext sample comprises ciphertext information and a sample result.
In at least one embodiment of the present invention, the ciphertext information refers to encrypted data information, for example, the ciphertext information may be information obtained by encrypting any text.
The sample result refers to the emotion information corresponding to the arbitrary text. For example, the sample result may be a positive emotion or a negative emotion, and the sample result may also be a happy emotion, a angry emotion, or the like.
And S11, carrying out shielding processing on the ciphertext information to obtain shielding information.
In at least one embodiment of the present invention, the occlusion information refers to information generated after performing replacement of a preset identifier and replacement of a random character on the ciphertext information.
In at least one embodiment of the present invention, the performing, by the electronic device, occlusion processing on the ciphertext information to obtain occlusion information includes:
determining the total amount of all characters in the ciphertext information;
determining the shielding quantity of the ciphertext information according to a first preset proportion and the total amount of the characters, and determining the replacement quantity of the ciphertext information according to a second preset proportion and the total amount of the characters;
replacing any character in the ciphertext information based on a preset identifier until the number of the preset identifiers in the generated replacement information is the shielding number, and obtaining first information;
and extracting random characters in the first information as first characters based on the replacement number, and replacing the first characters with second characters in the first information to obtain the shielding information, wherein the second characters refer to other characters except the first characters in the first information.
The first preset proportion and the second preset proportion can be set according to the classification capability of the target model.
The preset identifier may be a character other than the ciphertext character, for example, the preset identifier may be a mask.
The random character in the first information refers to any character in the first information, and for example, the first information is: sjfhnu, the random character can be any one of s, j, f, h, n and u.
The first character refers to random characters with the number of the replacement numbers. For example, if the number of replacements is 2, the first character may be s, j, or j, u, or the like, and the first character is not particularly limited in the present invention.
Receiving the above example, the first information is: sjfhnu, the number of replacements is 2, the first character may also be j, u, and then the second character is: s, f, h, and n, and the occlusion information may be sffhnh, ssfhnf, or the like, which is not limited in the present invention.
By the implementation mode, shielding information which has a certain difference with the ciphertext information can be quickly generated, and the context prediction capability of a subsequently generated target model can be improved because the preset learner cannot know specific characters on the preset identification and cannot know the replaced specific characters when the preset learner is adjusted subsequently.
And S12, generating the coding vector of the shielding information according to a preset coding type.
In at least one embodiment of the present invention, the preset encoding type may include: the coding type of the token character information, the coding type of the token character position, the coding type of the token sentence position, the coding type of whether the token is filled or not and the like.
The coding vector is a vector capable of representing the related semantics of the shielding information, and a representation vector, a character position vector, a statement position vector and a mask vector are fused in the coding vector.
In at least one embodiment of the present invention, the generating, by the electronic device, the encoding vector of the occlusion information according to a preset encoding type includes:
for any statement ciphertext in the shielding information, extracting a target character in the statement ciphertext;
acquiring a vector value corresponding to the target character from a preset vector table;
splicing the vector values according to the information positions of the target characters in the ciphertext of any statement to obtain spliced vectors;
acquiring the length of an input vector of the learner, and processing the spliced vector according to the length of the input vector to obtain a representation vector of the ciphertext of any statement;
generating a character position vector of any statement ciphertext according to the representation sequence of the any statement ciphertext in the representation vector;
generating a statement position vector of any statement ciphertext according to the statement position of any statement ciphertext in the shielding information;
generating a mask vector of the ciphertext of any statement according to the characterization vector and the splicing vector;
respectively carrying out linear transformation processing on the characterization vector, the character position vector, the statement position vector and the mask vector to obtain a first vector corresponding to the characterization vector, a second vector corresponding to the character position vector, a third vector corresponding to the statement position vector and a fourth vector corresponding to the mask vector;
calculating the average value of the first vector, the second vector, the third vector and the fourth vector in each vector dimension to obtain an initial vector of the ciphertext of any statement;
and splicing the initial vector according to the statement position to obtain the coding vector.
And the preset vector table stores the mapping relation between the ciphertext characters and the vector elements. For example, the mapping relationship of ciphertext character f to vector element 0010.
The input vector length refers to the maximum input length of the preset learner. Accordingly, the vector length of the token vector is equal to the input vector length.
Specifically, the processing, by the electronic device, the concatenation vector according to the input vector length to obtain a token vector of the ciphertext of any statement includes:
if the length of the input vector is larger than the splicing length of the splicing vector, filling the splicing vector until the splicing length is equal to the length of the input vector, and obtaining the characterization vector; or
And if the length of the input vector is smaller than the splicing length, eliminating vector values in the splicing vector until the splicing length is equal to the length of the input vector, and obtaining the characterization vector.
Specifically, the electronic device generates a mask vector of the ciphertext of any statement according to the token vector and the concatenation vector.
For example, the token vector is [1, 1, 0, 1, 1, 0, 0], the concatenation vector is [1, 1, 0, 1, 1], and thus, the token vector is generated after the concatenation vector is filled, and according to a preset rule, a filling element is represented by 0, and a non-filling element is represented by 1, the mask vector can be generated as [1, 1, 1, 1, 1, 0, 0 ].
The generated coding vectors can have information of the occlusion information on multiple dimensions through a plurality of preset coding types, and the characterization capability of the coding vectors on the occlusion information is improved.
And S13, acquiring a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network.
In at least one embodiment of the present invention, the feature extraction network is configured to extract key information in the ciphertext information. The feature extraction network comprises a first network, a second network and a normalization layer.
The emotion classification network is used for analyzing the emotion represented by the key information extracted from the feature extraction network.
S14, extracting the feature information of the coding vector based on the feature extraction network.
In at least one embodiment of the present invention, the feature information refers to key information in the ciphertext information.
In at least one embodiment of the present invention, the feature extraction network includes a first network, a second network, and a normalization layer, the first network includes an attention layer, a full-connection layer, and a normalization layer, and the electronic device extracts feature information of the coding vector based on the feature extraction network includes:
performing multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector;
performing linear transformation on the attention vector based on the full connection layer to obtain a transformation vector;
normalizing the transformation vector based on the regularization layer to obtain a first output vector;
inputting the coding vector and the first output vector into the second network for processing to obtain a second output vector;
and processing the first output vector and the second output vector based on the normalization layer to obtain the characteristic information.
Wherein the second network may include two fully connected layers, an activation function, a normalization layer. Further, the activation function is typically set to a GELU function.
Through the combined analysis of the coding vector and the first output vector and the combined analysis of the first output vector and the second output vector, the disappearance of the gradient or the explosion of the gradient of the feature extraction network can be prevented, so that the extraction accuracy of the feature extraction network is improved.
Specifically, the electronic device performs multi-head attention analysis on the coding vector based on the attention layer, and obtaining an attention vector includes:
performing linear transformation on the coding vector according to a plurality of preset parameters to obtain a plurality of parameter vectors corresponding to the plurality of preset parameters;
carrying out equal-length splitting on each parameter vector according to the lengths of the parameter vectors to obtain a plurality of segmentation vectors of each parameter vector, and counting the dimension number of each segmentation length;
extracting any two parameter vectors and a characteristic parameter vector from the plurality of parameter vectors, wherein the any two parameter vectors comprise a first parameter vector and a second parameter vector;
calculating a product of each segmentation vector in the first parameter vector and the transpose of the second parameter vector, and calculating a ratio of the product in the dimension number to obtain an attention score of each segmentation vector in the first parameter vector to the second parameter vector;
performing activation processing on the attention score based on a preset function to obtain the attention probability of each segmentation vector in the first parameter vector;
and splicing the products of the attention probability and each segmentation vector in the feature parameter vector to obtain the attention vector.
Wherein the number of the plurality of preset parameters is the same as the number of the plurality of parameter vectors, it can be understood that the number of the plurality of preset parameters is usually 3. Each preset parameter comprises a weight matrix and an offset value.
The preset function may be any activation function, for example, the preset function may be a tanh function.
By carrying out equal-length splitting on each parameter vector, the attention probability of each segmentation vector on the ciphertext information can be analyzed from the internal information of the ciphertext information, and then the attention vector of the ciphertext information can be accurately generated based on the attention probability and the segmentation vector corresponding to the internal information.
Specifically, the processing, by the electronic device, the first output vector and the second output vector based on the normalization layer to obtain the feature information includes:
calculating the average value of the first output vector and the second output vector to obtain a target output vector;
calculating the element mean value of all target elements in the target output vector, and calculating the element variance of all target elements in the target output vector;
calculating the ratio of the difference value of each target element in the target output vector and the element mean value to the element variance to obtain the element proportion of each target element;
acquiring a first layer parameter and a second layer parameter in the normalization layer;
calculating the parameter product of the element proportion and the first layer parameter, and calculating the sum of the parameter product and the second layer parameter to obtain the mapping element of each target element;
and replacing all target elements in the target output vector according to the mapping elements to obtain the characteristic information.
Wherein the first layer parameter and the second layer parameter refer to a network parameter of the normalization layer.
The all target elements refer to all elements in the target output vector, for example, if the target output vector is (0, 1, 0), then the all target elements are 0, 1, 0.
The element mean refers to an average value of all the target elements, for example, if all the target elements are 0, 1, 0, the element mean is: 1/3, the element variance refers to the variance value of all the target elements.
By the embodiment, the characteristics extracted by the first network and the second network can be combined for standardized evaluation, the training efficiency of the target model is improved, and in addition, the learning capacity of the target model can be prevented from being degraded through the first layer parameters and the second layer parameters, so that the accuracy of the target model is improved.
And S15, inputting the characteristic information into the emotion classification network to obtain a prediction result.
In at least one embodiment of the present invention, the prediction result refers to a result predicted by the predetermined learner on the ciphertext information.
In at least one embodiment of the present invention, the emotion classification network analyzes the feature information, which belongs to the prior art and is not described in detail herein.
And S16, adjusting the network parameters in the preset learner according to the prediction result and the sample result to obtain a target model.
In at least one embodiment of the invention, the network parameters include parameters in the feature extraction network and parameters in the emotion classification network.
The target model is a preset network when the similar distance between the prediction result and the sample result is not reduced any more.
In at least one embodiment of the present invention, the adjusting, by the electronic device, the network parameter in the preset learner according to the prediction result and the sample result, and obtaining the target model includes:
generating a prediction representation of the prediction result according to the preset vector table, and generating a sample representation of the sample result according to the preset vector table;
calculating the ratio of the characterization difference value of the predicted characterization and the sample characterization on the sample characterization to obtain the similar distance between the predicted result and the sample result;
and adjusting the network parameters according to the similar distance until the similar distance is not reduced any more, so as to obtain the target model.
The prediction representation refers to a vector representation of the prediction result on the preset vector table, and the sample representation refers to a vector representation of the sample result on the preset vector table.
The influence of the preset vector table on the similar distance can be avoided through the ratio of the representation difference value on the sample representation, so that the adjustment accuracy of the network parameters is improved, and the classification accuracy of the target model is further improved.
And S17, when the ciphertext emotion classification request is received, acquiring the ciphertext to be processed according to the ciphertext emotion classification request.
In at least one embodiment of the invention, the ciphertext emotion classification request may be generated by any user trigger.
The information carried by the ciphertext emotion classification request includes, but is not limited to: and indicating the identifier of the ciphertext to be processed, and the like.
The ciphertext to be processed is encrypted information needing emotion classification.
In at least one embodiment of the present invention, the obtaining, by the electronic device, the ciphertext to be processed according to the ciphertext emotion classification request includes:
analyzing the message of the ciphertext emotion classification request to obtain data information carried by the message;
extracting a ciphertext identifier from the data information;
generating a query statement according to the ciphertext identifier;
and operating the query statement to obtain the ciphertext to be processed.
By the embodiment, the ciphertext to be processed can be quickly acquired.
And S18, inputting the ciphertext to be processed into the target model to obtain a target result.
It is emphasized that the target result can also be stored in a node of a blockchain in order to further ensure the privacy and security of the target result.
In at least one embodiment of the present invention, the target result refers to an emotion category corresponding to the ciphertext to be processed.
In at least one embodiment of the present invention, the electronic device inputs the ciphertext to be processed into the target model, and a specific manner of obtaining the target result is similar to a manner of analyzing the ciphertext information based on a preset learner by the electronic device, which is not described in detail herein.
According to the technical scheme, the context prediction capability of the target model can be improved by shielding the ciphertext information, the coding vector is generated according to the preset coding type, the coding vector input into the preset learner can have information of the ciphertext information in multiple dimensions, the network parameters can be adjusted by using the ciphertext information which cannot be accurately represented, and the prediction accuracy of the target model is improved. In addition, the ciphertext to be processed is directly analyzed without being decrypted, so that the information leakage after decryption can be avoided, the safety of the ciphertext to be processed is improved, the time consumption for decrypting the ciphertext to be processed can be saved, and the generation efficiency of the target result is improved.
Fig. 2 is a functional block diagram of the ciphertext emotion classification apparatus according to the preferred embodiment of the present invention. The ciphertext emotion classification apparatus 11 includes an acquisition unit 110, a processing unit 111, a generation unit 112, an extraction unit 113, an input unit 114, and an adjustment unit 115. The module/unit referred to herein is a series of computer readable instruction segments that can be accessed by the processor 13 and perform a fixed function and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
The obtaining unit 110 obtains a ciphertext sample, where the ciphertext sample includes ciphertext information and a sample result.
In at least one embodiment of the present invention, the ciphertext information refers to encrypted data information, for example, the ciphertext information may be information obtained by encrypting any text.
The sample result refers to the emotion information corresponding to the arbitrary text. For example, the sample result may be a positive emotion or a negative emotion, and the sample result may also be a happy emotion, a angry emotion, or the like.
The processing unit 111 performs occlusion processing on the ciphertext information to obtain occlusion information.
In at least one embodiment of the present invention, the occlusion information refers to information generated after performing replacement of a preset identifier and replacement of a random character on the ciphertext information.
In at least one embodiment of the present invention, the processing unit 111 performs occlusion processing on the ciphertext information, and obtaining occlusion information includes:
determining the total amount of all characters in the ciphertext information;
determining the shielding quantity of the ciphertext information according to a first preset proportion and the total amount of the characters, and determining the replacement quantity of the ciphertext information according to a second preset proportion and the total amount of the characters;
replacing any character in the ciphertext information based on a preset identifier until the number of the preset identifiers in the generated replacement information is the shielding number, and obtaining first information;
and extracting random characters in the first information as first characters based on the replacement number, and replacing the first characters with second characters in the first information to obtain the shielding information, wherein the second characters refer to other characters except the first characters in the first information.
The first preset proportion and the second preset proportion can be set according to the classification capability of the target model.
The preset identifier may be a character other than the ciphertext character, for example, the preset identifier may be a mask.
The random character in the first information refers to any character in the first information, and for example, the first information is: sjfhnu, the random character can be any one of s, j, f, h, n and u.
The first character refers to random characters with the number of the replacement numbers. For example, if the number of replacements is 2, the first character may be s, j, or j, u, or the like, and the first character is not particularly limited in the present invention.
Receiving the above example, the first information is: sjfhnu, the number of replacements is 2, the first character may also be j, u, and then the second character is: s, f, h, and n, and the occlusion information may be sffhnh, ssfhnf, or the like, which is not limited in the present invention.
By the implementation mode, shielding information which has a certain difference with the ciphertext information can be quickly generated, and the context prediction capability of a subsequently generated target model can be improved because the preset learner cannot know specific characters on the preset identification and cannot know the replaced specific characters when the preset learner is adjusted subsequently.
The generating unit 112 generates a coding vector of the occlusion information according to a preset coding type.
In at least one embodiment of the present invention, the preset encoding type may include: the coding type of the token character information, the coding type of the token character position, the coding type of the token sentence position, the coding type of whether the token is filled or not and the like.
The coding vector is a vector capable of representing the related semantics of the shielding information, and a representation vector, a character position vector, a statement position vector and a mask vector are fused in the coding vector.
In at least one embodiment of the present invention, the generating unit 112 generates the encoding vector of the occlusion information according to a preset encoding type, including:
for any statement ciphertext in the shielding information, extracting a target character in the statement ciphertext;
acquiring a vector value corresponding to the target character from a preset vector table;
splicing the vector values according to the information positions of the target characters in the ciphertext of any statement to obtain spliced vectors;
acquiring the length of an input vector of the learner, and processing the spliced vector according to the length of the input vector to obtain a representation vector of the ciphertext of any statement;
generating a character position vector of any statement ciphertext according to the representation sequence of the any statement ciphertext in the representation vector;
generating a statement position vector of any statement ciphertext according to the statement position of any statement ciphertext in the shielding information;
generating a mask vector of the ciphertext of any statement according to the characterization vector and the splicing vector;
respectively carrying out linear transformation processing on the characterization vector, the character position vector, the statement position vector and the mask vector to obtain a first vector corresponding to the characterization vector, a second vector corresponding to the character position vector, a third vector corresponding to the statement position vector and a fourth vector corresponding to the mask vector;
calculating the average value of the first vector, the second vector, the third vector and the fourth vector in each vector dimension to obtain an initial vector of the ciphertext of any statement;
and splicing the initial vector according to the statement position to obtain the coding vector.
And the preset vector table stores the mapping relation between the ciphertext characters and the vector elements. For example, the mapping relationship of ciphertext character f to vector element 0010.
The input vector length refers to the maximum input length of the preset learner. Accordingly, the vector length of the token vector is equal to the input vector length.
Specifically, the processing, by the generating unit 112, the concatenation vector according to the input vector length to obtain a token vector of the ciphertext of any statement includes:
if the length of the input vector is larger than the splicing length of the splicing vector, filling the splicing vector until the splicing length is equal to the length of the input vector, and obtaining the characterization vector; or
And if the length of the input vector is smaller than the splicing length, eliminating vector values in the splicing vector until the splicing length is equal to the length of the input vector, and obtaining the characterization vector.
Specifically, the generating unit 112 generates a mask vector of the ciphertext of any statement according to the token vector and the concatenation vector.
For example, the token vector is [1, 1, 0, 1, 1, 0, 0], the concatenation vector is [1, 1, 0, 1, 1], and thus, the token vector is generated after the concatenation vector is filled, and according to a preset rule, a filling element is represented by 0, and a non-filling element is represented by 1, the mask vector can be generated as [1, 1, 1, 1, 1, 0, 0 ].
The generated coding vectors can have information of the occlusion information on multiple dimensions through a plurality of preset coding types, and the characterization capability of the coding vectors on the occlusion information is improved.
The obtaining unit 110 obtains a preset learner, which includes a feature extraction network and an emotion classification network.
In at least one embodiment of the present invention, the feature extraction network is configured to extract key information in the ciphertext information. The feature extraction network comprises a first network, a second network and a normalization layer.
The emotion classification network is used for analyzing the emotion represented by the key information extracted from the feature extraction network.
The extraction unit 113 extracts feature information of the code vector based on the feature extraction network.
In at least one embodiment of the present invention, the feature information refers to key information in the ciphertext information.
In at least one embodiment of the present invention, the feature extraction network includes a first network, a second network, and a normalization layer, the first network includes an attention layer, a full-connection layer, and a normalization layer, and the electronic device extracts feature information of the coding vector based on the feature extraction network includes:
performing multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector;
performing linear transformation on the attention vector based on the full connection layer to obtain a transformation vector;
normalizing the transformation vector based on the regularization layer to obtain a first output vector;
inputting the coding vector and the first output vector into the second network for processing to obtain a second output vector;
and processing the first output vector and the second output vector based on the normalization layer to obtain the characteristic information.
Wherein the second network may include two fully connected layers, an activation function, a normalization layer. Further, the activation function is typically set to a GELU function.
Through the combined analysis of the coding vector and the first output vector and the combined analysis of the first output vector and the second output vector, the disappearance of the gradient or the explosion of the gradient of the feature extraction network can be prevented, so that the extraction accuracy of the feature extraction network is improved.
Specifically, the extracting unit 113 performs multi-head attention analysis on the encoded vector based on the attention layer, and obtaining an attention vector includes:
performing linear transformation on the coding vector according to a plurality of preset parameters to obtain a plurality of parameter vectors corresponding to the plurality of preset parameters;
carrying out equal-length splitting on each parameter vector according to the lengths of the parameter vectors to obtain a plurality of segmentation vectors of each parameter vector, and counting the dimension number of each segmentation length;
extracting any two parameter vectors and a characteristic parameter vector from the plurality of parameter vectors, wherein the any two parameter vectors comprise a first parameter vector and a second parameter vector;
calculating a product of each segmentation vector in the first parameter vector and the transpose of the second parameter vector, and calculating a ratio of the product in the dimension number to obtain an attention score of each segmentation vector in the first parameter vector to the second parameter vector;
performing activation processing on the attention score based on a preset function to obtain the attention probability of each segmentation vector in the first parameter vector;
and splicing the products of the attention probability and each segmentation vector in the feature parameter vector to obtain the attention vector.
Wherein the number of the plurality of preset parameters is the same as the number of the plurality of parameter vectors, it can be understood that the number of the plurality of preset parameters is usually 3. Each preset parameter comprises a weight matrix and an offset value.
The preset function may be any activation function, for example, the preset function may be a tanh function.
By carrying out equal-length splitting on each parameter vector, the attention probability of each segmentation vector on the ciphertext information can be analyzed from the internal information of the ciphertext information, and then the attention vector of the ciphertext information can be accurately generated based on the attention probability and the segmentation vector corresponding to the internal information.
Specifically, the extracting unit 113 processes the first output vector and the second output vector based on the normalization layer to obtain the feature information includes:
calculating the average value of the first output vector and the second output vector to obtain a target output vector;
calculating the element mean value of all target elements in the target output vector, and calculating the element variance of all target elements in the target output vector;
calculating the ratio of the difference value of each target element in the target output vector and the element mean value to the element variance to obtain the element proportion of each target element;
acquiring a first layer parameter and a second layer parameter in the normalization layer;
calculating the parameter product of the element proportion and the first layer parameter, and calculating the sum of the parameter product and the second layer parameter to obtain the mapping element of each target element;
and replacing all target elements in the target output vector according to the mapping elements to obtain the characteristic information.
Wherein the first layer parameter and the second layer parameter refer to a network parameter of the normalization layer.
The all target elements refer to all elements in the target output vector, for example, if the target output vector is (0, 1, 0), then the all target elements are 0, 1, 0.
The element mean refers to an average value of all the target elements, for example, if all the target elements are 0, 1, 0, the element mean is: 1/3, the element variance refers to the variance value of all the target elements.
By the embodiment, the characteristics extracted by the first network and the second network can be combined for standardized evaluation, the training efficiency of the target model is improved, and in addition, the learning capacity of the target model can be prevented from being degraded through the first layer parameters and the second layer parameters, so that the accuracy of the target model is improved.
The input unit 114 inputs the feature information into the emotion classification network, and obtains a prediction result.
In at least one embodiment of the present invention, the prediction result refers to a result predicted by the predetermined learner on the ciphertext information.
In at least one embodiment of the present invention, the emotion classification network analyzes the feature information, which belongs to the prior art and is not described in detail herein.
The adjusting unit 115 adjusts the network parameters in the preset learner according to the prediction result and the sample result to obtain a target model.
In at least one embodiment of the invention, the network parameters include parameters in the feature extraction network and parameters in the emotion classification network.
The target model is a preset network when the similar distance between the prediction result and the sample result is not reduced any more.
In at least one embodiment of the present invention, the adjusting unit 115 adjusts the network parameters in the preset learner according to the prediction result and the sample result, and obtaining the target model includes:
generating a prediction representation of the prediction result according to the preset vector table, and generating a sample representation of the sample result according to the preset vector table;
calculating the ratio of the characterization difference value of the predicted characterization and the sample characterization on the sample characterization to obtain the similar distance between the predicted result and the sample result;
and adjusting the network parameters according to the similar distance until the similar distance is not reduced any more, so as to obtain the target model.
The prediction representation refers to a vector representation of the prediction result on the preset vector table, and the sample representation refers to a vector representation of the sample result on the preset vector table.
The influence of the preset vector table on the similar distance can be avoided through the ratio of the representation difference value on the sample representation, so that the adjustment accuracy of the network parameters is improved, and the classification accuracy of the target model is further improved.
When a ciphertext emotion classification request is received, the obtaining unit 110 obtains a ciphertext to be processed according to the ciphertext emotion classification request.
In at least one embodiment of the invention, the ciphertext emotion classification request may be generated by any user trigger.
The information carried by the ciphertext emotion classification request includes, but is not limited to: and indicating the identifier of the ciphertext to be processed, and the like.
The ciphertext to be processed is encrypted information needing emotion classification.
In at least one embodiment of the present invention, the obtaining unit 110 obtains the ciphertext to be processed according to the ciphertext emotion classification request, where the obtaining unit includes:
analyzing the message of the ciphertext emotion classification request to obtain data information carried by the message;
extracting a ciphertext identifier from the data information;
generating a query statement according to the ciphertext identifier;
and operating the query statement to obtain the ciphertext to be processed.
By the embodiment, the ciphertext to be processed can be quickly acquired.
The input unit 114 inputs the ciphertext to be processed into the target model, so as to obtain a target result.
It is emphasized that the target result can also be stored in a node of a blockchain in order to further ensure the privacy and security of the target result.
In at least one embodiment of the present invention, the target result refers to an emotion category corresponding to the ciphertext to be processed.
In at least one embodiment of the present invention, the input unit 114 inputs the ciphertext to be processed into the target model, and a specific manner of obtaining the target result is similar to a manner of analyzing the ciphertext information based on a preset learner, which is not described in detail herein.
According to the technical scheme, the context prediction capability of the target model can be improved by shielding the ciphertext information, the coding vector is generated according to the preset coding type, the coding vector input into the preset learner can have information of the ciphertext information in multiple dimensions, the network parameters can be adjusted by using the ciphertext information which cannot be accurately represented, and the prediction accuracy of the target model is improved. In addition, the ciphertext to be processed is directly analyzed without being decrypted, so that the information leakage after decryption can be avoided, the safety of the ciphertext to be processed is improved, the time consumption for decrypting the ciphertext to be processed can be saved, and the generation efficiency of the target result is improved.
Fig. 3 is a schematic structural diagram of an electronic device implementing the method for classifying ciphertext emotions according to the preferred embodiment of the invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions stored in the memory 12 and executable on the processor 13, such as a ciphertext emotion classification program.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
Illustratively, the computer readable instructions may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing specific functions, which are used for describing the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions may be divided into an acquisition unit 110, a processing unit 111, a generation unit 112, an extraction unit 113, an input unit 114, and an adjustment unit 115.
The memory 12 may be used for storing the computer readable instructions and/or modules, and the processor 13 implements various functions of the electronic device 1 by executing or executing the computer readable instructions and/or modules stored in the memory 12 and invoking data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. The memory 12 may include non-volatile and volatile memories, such as: a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory having a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the above embodiments may be implemented by hardware that is configured to be instructed by computer readable instructions, which may be stored in a computer readable storage medium, and when the computer readable instructions are executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer readable instructions comprise computer readable instruction code which may be in source code form, object code form, an executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying said computer readable instruction code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM).
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
With reference to fig. 1, the memory 12 in the electronic device 1 stores computer-readable instructions to implement a ciphertext emotion classification method, and the processor 13 can execute the computer-readable instructions to implement:
acquiring a ciphertext sample, wherein the ciphertext sample comprises ciphertext information and a sample result;
shielding the ciphertext information to obtain shielding information;
generating a coding vector of the shielding information according to a preset coding type;
acquiring a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network;
extracting feature information of the coding vector based on the feature extraction network;
inputting the characteristic information into the emotion classification network to obtain a prediction result;
adjusting network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
when a ciphertext emotion classification request is received, acquiring a ciphertext to be processed according to the ciphertext emotion classification request;
and inputting the ciphertext to be processed into the target model to obtain a target result.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the computer readable instructions, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The computer readable storage medium has computer readable instructions stored thereon, wherein the computer readable instructions when executed by the processor 13 are configured to implement the steps of:
acquiring a ciphertext sample, wherein the ciphertext sample comprises ciphertext information and a sample result;
shielding the ciphertext information to obtain shielding information;
generating a coding vector of the shielding information according to a preset coding type;
acquiring a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network;
extracting feature information of the coding vector based on the feature extraction network;
inputting the characteristic information into the emotion classification network to obtain a prediction result;
adjusting network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
when a ciphertext emotion classification request is received, acquiring a ciphertext to be processed according to the ciphertext emotion classification request;
and inputting the ciphertext to be processed into the target model to obtain a target result.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. The plurality of units or devices may also be implemented by one unit or device through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (9)

1. A ciphertext emotion classification method is characterized by comprising the following steps:
acquiring a ciphertext sample, wherein the ciphertext sample comprises ciphertext information and a sample result;
shielding the ciphertext information to obtain shielding information;
generating a coding vector of the shielding information according to a preset coding type;
acquiring a preset learner, wherein the preset learner comprises a feature extraction network and an emotion classification network, the feature extraction network comprises a first network, a second network and a normalization layer, and the first network comprises an attention layer, a full connection layer and a regularization layer;
extracting feature information of the coding vector based on the feature extraction network, including: performing multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector; performing linear transformation on the attention vector based on the full connection layer to obtain a transformation vector; normalizing the transformation vector based on the regularization layer to obtain a first output vector; inputting the coding vector and the first output vector into the second network for processing to obtain a second output vector; processing the first output vector and the second output vector based on the normalization layer to obtain the feature information;
inputting the characteristic information into the emotion classification network to obtain a prediction result;
adjusting network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
when a ciphertext emotion classification request is received, acquiring a ciphertext to be processed according to the ciphertext emotion classification request;
and inputting the ciphertext to be processed into the target model to obtain a target result.
2. The method for classifying ciphertext emotions according to claim 1, wherein the step of performing the occlusion processing on the ciphertext information to obtain the occlusion information comprises:
determining the total amount of all characters in the ciphertext information;
determining the shielding quantity of the ciphertext information according to a first preset proportion and the total amount of the characters, and determining the replacement quantity of the ciphertext information according to a second preset proportion and the total amount of the characters;
replacing any character in the ciphertext information based on a preset identifier until the number of the preset identifiers in the generated replacement information is the shielding number, and obtaining first information;
and extracting random characters in the first information as first characters based on the replacement number, and replacing the first characters with second characters in the first information to obtain the shielding information, wherein the second characters refer to other characters except the first characters in the first information.
3. The method for classifying ciphertext emotions according to claim 1, wherein the generating the coding vector of the occlusion information according to a preset coding type comprises:
for any statement ciphertext in the shielding information, extracting a target character in the statement ciphertext;
acquiring a vector value corresponding to the target character from a preset vector table;
splicing the vector values according to the information positions of the target characters in the ciphertext of any statement to obtain spliced vectors;
acquiring the length of an input vector of the preset learner, and processing the spliced vector according to the length of the input vector to obtain a representation vector of any statement ciphertext;
generating a character position vector of any statement ciphertext according to the representation sequence of the any statement ciphertext in the representation vector;
generating a statement position vector of any statement ciphertext according to the statement position of any statement ciphertext in the shielding information;
generating a mask vector of the ciphertext of any statement according to the characterization vector and the splicing vector;
respectively carrying out linear transformation processing on the characterization vector, the character position vector, the statement position vector and the mask vector to obtain a first vector corresponding to the characterization vector, a second vector corresponding to the character position vector, a third vector corresponding to the statement position vector and a fourth vector corresponding to the mask vector;
calculating the average value of the first vector, the second vector, the third vector and the fourth vector in each vector dimension to obtain an initial vector of the ciphertext of any statement;
and splicing the initial vector according to the statement position to obtain the coding vector.
4. The method of classifying ciphertext emotions according to claim 3, wherein the adjusting the network parameters in the predetermined learner according to the prediction result and the sample result to obtain the target model comprises:
generating a prediction representation of the prediction result according to the preset vector table, and generating a sample representation of the sample result according to the preset vector table;
calculating the ratio of the characterization difference value of the predicted characterization and the sample characterization on the sample characterization to obtain the similar distance between the predicted result and the sample result;
and adjusting the network parameters according to the similar distance until the similar distance is not reduced any more, so as to obtain the target model.
5. The method for classifying ciphertext emotions according to claim 1, wherein the performing the multi-head attention analysis on the encoded vector based on the attention layer to obtain the attention vector comprises:
performing linear transformation on the coding vector according to a plurality of preset parameters to obtain a plurality of parameter vectors corresponding to the plurality of preset parameters;
carrying out equal-length splitting on each parameter vector according to the lengths of the parameter vectors to obtain a plurality of segmentation vectors of each parameter vector, and counting the dimension number of each segmentation length;
extracting any two parameter vectors and a characteristic parameter vector from the plurality of parameter vectors, wherein the any two parameter vectors comprise a first parameter vector and a second parameter vector;
calculating a product of each segmentation vector in the first parameter vector and the transpose of the second parameter vector, and calculating a ratio of the product in the dimension number to obtain an attention score of each segmentation vector in the first parameter vector to the second parameter vector;
performing activation processing on the attention score based on a preset function to obtain the attention probability of each segmentation vector in the first parameter vector;
and splicing the products of the attention probability and each segmentation vector in the feature parameter vector to obtain the attention vector.
6. The method for classifying ciphertext emotions according to claim 1, wherein the processing the first output vector and the second output vector based on the normalization layer to obtain the feature information comprises:
calculating the average value of the first output vector and the second output vector to obtain a target output vector;
calculating the element mean value of all target elements in the target output vector, and calculating the element variance of all target elements in the target output vector;
calculating the ratio of the difference value of each target element in the target output vector and the element mean value to the element variance to obtain the element proportion of each target element;
acquiring a first layer parameter and a second layer parameter in the normalization layer;
calculating the parameter product of the element proportion and the first layer parameter, and calculating the sum of the parameter product and the second layer parameter to obtain the mapping element of each target element;
and replacing all target elements in the target output vector according to the mapping elements to obtain the characteristic information.
7. A ciphertext emotion classification apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a ciphertext sample, and the ciphertext sample comprises ciphertext information and a sample result;
the processing unit is used for carrying out shielding processing on the ciphertext information to obtain shielding information;
the generating unit is used for generating a coding vector of the shielding information according to a preset coding type;
the obtaining unit is used for obtaining a preset learner, the preset learner comprises a feature extraction network and an emotion classification network, the feature extraction network comprises a first network, a second network and a normalization layer, and the first network comprises an attention layer, a full connection layer and a regularization layer;
an extracting unit, configured to extract feature information of the coding vector based on the feature extraction network, including: performing multi-head attention analysis on the coding vector based on the attention layer to obtain an attention vector; performing linear transformation on the attention vector based on the full connection layer to obtain a transformation vector; normalizing the transformation vector based on the regularization layer to obtain a first output vector; inputting the coding vector and the first output vector into the second network for processing to obtain a second output vector; processing the first output vector and the second output vector based on the normalization layer to obtain the feature information;
the input unit is used for inputting the characteristic information into the emotion classification network to obtain a prediction result;
the adjusting unit is used for adjusting the network parameters in the preset learner according to the prediction result and the sample result to obtain a target model;
the acquiring unit is used for acquiring a ciphertext to be processed according to the ciphertext emotion classification request when the ciphertext emotion classification request is received;
the input unit is further configured to input the ciphertext to be processed into the target model, so as to obtain a target result.
8. An electronic device, characterized in that the electronic device comprises:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the ciphertext emotion classification method of any one of claims 1 to 6.
9. A computer-readable storage medium characterized by: the computer readable storage medium stores computer readable instructions, and the computer readable instructions are executed by a processor in an electronic device to implement the ciphertext emotion classification method according to any one of claims 1 to 6.
CN202111035746.2A 2021-09-06 2021-09-06 Ciphertext emotion classification method, device, equipment and storage medium Active CN113468334B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111035746.2A CN113468334B (en) 2021-09-06 2021-09-06 Ciphertext emotion classification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111035746.2A CN113468334B (en) 2021-09-06 2021-09-06 Ciphertext emotion classification method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113468334A CN113468334A (en) 2021-10-01
CN113468334B true CN113468334B (en) 2021-11-23

Family

ID=77867467

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111035746.2A Active CN113468334B (en) 2021-09-06 2021-09-06 Ciphertext emotion classification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113468334B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020172649A1 (en) * 2019-02-22 2020-08-27 Newvoicemedia Us Inc. System and method for text categorization and sentiment analysis
CN113268597A (en) * 2021-05-25 2021-08-17 平安科技(深圳)有限公司 Text classification method, device, equipment and storage medium
WO2021169364A1 (en) * 2020-09-23 2021-09-02 平安科技(深圳)有限公司 Semantic emotion analysis method and apparatus, device, and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11115203B2 (en) * 2018-05-17 2021-09-07 Badge Inc. System and method for securing personal information via biometric public key
US20200104726A1 (en) * 2018-09-29 2020-04-02 VII Philip Alvelda Machine learning data representations, architectures, and systems that intrinsically encode and represent benefit, harm, and emotion to optimize learning
US20200311114A1 (en) * 2019-03-25 2020-10-01 Jpmorgan Chase Bank, N.A. System for topic discovery and sentiment analysis on a collection of documents
CN110011784B (en) * 2019-04-04 2021-06-08 东北大学 KNN classification service system and method supporting privacy protection
CN111582653A (en) * 2020-04-14 2020-08-25 五邑大学 Government affair service evaluation processing method, system, device and storage medium
CN112910624B (en) * 2021-01-14 2022-05-10 东北大学 Ciphertext prediction method based on homomorphic encryption
CN113179223B (en) * 2021-04-23 2022-08-26 中山大学 Network application identification method and system based on deep learning and serialization features

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020172649A1 (en) * 2019-02-22 2020-08-27 Newvoicemedia Us Inc. System and method for text categorization and sentiment analysis
WO2021169364A1 (en) * 2020-09-23 2021-09-02 平安科技(深圳)有限公司 Semantic emotion analysis method and apparatus, device, and storage medium
CN113268597A (en) * 2021-05-25 2021-08-17 平安科技(深圳)有限公司 Text classification method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN113468334A (en) 2021-10-01

Similar Documents

Publication Publication Date Title
CN111694826B (en) Data enhancement method and device based on artificial intelligence, electronic equipment and medium
CN113032528B (en) Case analysis method, case analysis device, case analysis equipment and storage medium
CN113656547B (en) Text matching method, device, equipment and storage medium
CN112989826B (en) Test question score determining method, device, equipment and medium based on artificial intelligence
CN113408278B (en) Intention recognition method, device, equipment and storage medium
CN113435196B (en) Intention recognition method, device, equipment and storage medium
CN113536770B (en) Text analysis method, device and equipment based on artificial intelligence and storage medium
CN113408268A (en) Slot filling method, device, equipment and storage medium
CN113283675A (en) Index data analysis method, device, equipment and storage medium
CN113268597B (en) Text classification method, device, equipment and storage medium
CN113918467A (en) Financial system testing method, device, equipment and storage medium
CN113705468A (en) Digital image identification method based on artificial intelligence and related equipment
CN113420545B (en) Abstract generation method, device, equipment and storage medium
CN113468334B (en) Ciphertext emotion classification method, device, equipment and storage medium
CN113627186B (en) Entity relation detection method based on artificial intelligence and related equipment
CN112989044B (en) Text classification method, device, equipment and storage medium
CN112949305B (en) Negative feedback information acquisition method, device, equipment and storage medium
CN113342977B (en) Invoice image classification method, device, equipment and storage medium
CN114942749A (en) Development method, device and equipment of approval system and storage medium
CN113486680A (en) Text translation method, device, equipment and storage medium
CN113177543A (en) Certificate identification method, device, equipment and storage medium
CN113516205A (en) Data classification method, device, equipment and storage medium based on artificial intelligence
CN113269179A (en) Data processing method, device, equipment and storage medium
CN113408265A (en) Semantic analysis method, device and equipment based on human-computer interaction and storage medium
CN113283677A (en) Index data processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant