CN114817511B - Question-answer interaction method and device based on kernel principal component analysis and computer equipment - Google Patents

Question-answer interaction method and device based on kernel principal component analysis and computer equipment Download PDF

Info

Publication number
CN114817511B
CN114817511B CN202210732742.8A CN202210732742A CN114817511B CN 114817511 B CN114817511 B CN 114817511B CN 202210732742 A CN202210732742 A CN 202210732742A CN 114817511 B CN114817511 B CN 114817511B
Authority
CN
China
Prior art keywords
tensor
text
dimension reduction
current
principal component
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
CN202210732742.8A
Other languages
Chinese (zh)
Other versions
CN114817511A (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.)
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Original Assignee
Shenzhen Qianhai Huanrong Lianyi Information Technology Service 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 Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd filed Critical Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority to CN202210732742.8A priority Critical patent/CN114817511B/en
Publication of CN114817511A publication Critical patent/CN114817511A/en
Application granted granted Critical
Publication of CN114817511B publication Critical patent/CN114817511B/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/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • G06F18/2135Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods based on approximation criteria, e.g. principal component analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Human Computer Interaction (AREA)
  • Evolutionary Biology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Computation (AREA)
  • Machine Translation (AREA)

Abstract

The method comprises the steps of performing feature extraction on a text to be replied correspondingly, obtaining a current dimension reduction tensor after dimension reduction based on kernel principal component analysis, obtaining a corresponding target dimension reduction tensor in a prestored dimension reduction tensor database based on the current dimension reduction tensor, and finally taking original text data corresponding to the target dimension reduction tensor as a reply text. The method and the device have the advantages that when the similarity between the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database is obtained after feature extraction and dimension reduction based on kernel principal component analysis are carried out correspondingly on the text to be replied, the tensor is reduced into the uniform dimension, the condition that the lengths of basis vectors in each dimension are different does not exist, the cosine similarity result between the calculated tensors is more accurate, and the obtained reply text corresponding to the target dimension reduction tensor is more accurate.

Description

Question-answer interaction method and device based on kernel principal component analysis and computer equipment
Technical Field
The application relates to the technical field of artificial intelligence natural language processing, in particular to a question-answer interaction method and device based on kernel principal component analysis, computer equipment and a storage medium.
Background
At present, when similarity between a search text or a consultation text sent by a user and each answer text in a background knowledge base is calculated in an intelligent question-answering system, a Sentence Embedding tensor (namely, sequence Embedding) is generally obtained by using a pre-training model for the search text or the consultation text, or an average Sentence Embedding tensor of the last two layers of data of the pre-training model is used, and then cosine similarity of the Sentence Embedding tensor of each answer text in the background knowledge base is calculated by using the Sentence Embedding tensor or the average Sentence Embedding tensor to obtain a target tensor which can be finally used as a reply text.
However, when the cosine similarity between the sentence embedding tensor or the average sentence embedding tensor and each answer text sentence embedding tensor in the background knowledge base is calculated, the case that the length of the base vector in each dimension is different between the sentence embedding tensor or the average sentence embedding tensor and the answer text sentence embedding tensor may exist, which is not in accordance with the assumption of the cosine similarity, and a deviation may be generated when the vector similarity is calculated, so that the result of the cosine similarity between the calculated tensors is not accurate.
Disclosure of Invention
The embodiment of the application provides a question-answer interaction method, a question-answer interaction device, computer equipment and a storage medium based on kernel principal component analysis, and aims to solve the problem that in the prior art, when similarity between a retrieval text or a consultation text sent by a user and each answer text in a background knowledge base is calculated directly by using an average sentence embedding tensor of sentence embedding tensors obtained by a pre-training model or last two layers of data and cosine similarity of each answer text sentence embedding tensor in the background knowledge base, the length of a base vector in each dimension is different, and the result of the cosine similarity between the calculated tensors is inaccurate.
In a first aspect, an embodiment of the present application provides a question-answer interaction method based on kernel principal component analysis, which includes:
acquiring a text to be replied based on input of a user side;
determining a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression;
reducing the dimension of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimension reduction tensor;
determining a target dimension reduction tensor which has the maximum similarity with the current dimension reduction tensor in the dimension reduction tensor database based on a prestored dimension reduction tensor database;
acquiring original text data corresponding to the target dimension reduction tensor as a reply text; and
and sending the reply text to the user side.
In a second aspect, an embodiment of the present application provides a question-answer interaction device based on kernel principal component analysis, which includes:
the login information acquisition unit is used for acquiring a text to be replied based on the input of the user side;
the current tensor acquiring unit is used for determining a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression;
the tensor dimensionality reduction unit is used for reducing the dimensionality of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimensionality reduction tensor;
the target tensor acquiring unit is used for determining a target dimension reduction tensor which has the maximum similarity with the current dimension reduction tensor in the dimension reduction tensor database based on a prestored dimension reduction tensor database;
the reply text acquisition unit is used for acquiring original text data corresponding to the target dimension reduction tensor as a reply text; and
and the reply text sending unit is used for sending the reply text to the user side.
In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor, when executing the computer program, implements the question-answering interaction method based on kernel principal component analysis according to the first aspect.
In a fourth aspect, the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and the computer program, when executed by a processor, causes the processor to execute the question-answer interaction method based on kernel principal component analysis according to the first aspect.
The embodiment of the application provides a question-answer interaction method, device and equipment based on kernel principal component analysis, which comprises the steps of firstly carrying out feature extraction on a text to be replied correspondingly, then carrying out dimensionality reduction based on kernel principal component analysis to obtain a current dimensionality reduction tensor, then obtaining a corresponding target dimensionality reduction tensor from a prestored dimensionality reduction tensor database based on the current dimensionality reduction tensor, and finally taking original text data corresponding to the target dimensionality reduction tensor as a replied text. The method and the device have the advantages that when the similarity between the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database is obtained after feature extraction is carried out on the corresponding text to be replied and dimension reduction is carried out on the basis of kernel principal component analysis, the tensor is reduced into uniform dimensions, the condition that the lengths of basis vectors in all dimensions are different does not exist, the cosine similarity result between the calculated tensors is more accurate, and the obtained reply text corresponding to the target dimension reduction tensor is more accurate.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic view of an application scenario of a question-answer interaction method based on kernel principal component analysis according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a question-answer interaction method based on kernel principal component analysis according to an embodiment of the present application;
FIG. 3 is a schematic block diagram of a question-answering interaction device based on kernel principal component analysis according to an embodiment of the present application;
fig. 4 is a schematic block diagram of a computer device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Referring to fig. 1 and fig. 2, fig. 1 is a schematic view of an application scenario of a question-answer interaction method based on kernel principal component analysis according to an embodiment of the present application; fig. 2 is a schematic flowchart of a question-answer interaction method based on kernel principal component analysis according to an embodiment of the present application, where the question-answer interaction method based on kernel principal component analysis is applied to a server, and the method is executed by application software installed in the server.
As shown in FIG. 2, the method includes steps S101 to S106.
S101, acquiring a text to be replied based on input of a user side.
In this embodiment, a server is used as an execution subject to describe the technical solution. A user side (such as an intelligent terminal like a smart phone or a tablet computer) used by a user can perform data interaction with the server, specifically, the server provides an intelligent customer service question-answering system, and the user side can log in the intelligent customer service question-answering system. And a user interaction interface of the intelligent customer service question and answer system is displayed on a terminal interface of the user side, and a chat frame exists in the user interaction interface. The user can input any character string to be consulted in the chat frame as a text to be replied, and after the server receives the text to be replied sent by the user side, the server can quickly acquire corresponding reply data from a background knowledge base of the intelligent customer service question-answering system and correspondingly display the reply data in the chat frame to finish the intelligent question-answering process.
Wherein, the source of the text to be replied has at least the following three modes:
the first is that the user terminal sends the data in text form as the text to be replied;
the second is data in a voice form sent by a user terminal, and at this time, the data in the voice form needs to be converted into data in a text form based on a voice recognition model (such as an N-gram multivariate model) stored in a server and used as a text to be replied;
the third is data in picture form sent by the user terminal, and at this time, the data in picture form needs to be converted into data in text form based on an image recognition model (such as an optical character recognition model) stored in the server, and the data is used as text to be replied.
However, no matter which form of data is sent from the user side to the server, the server correspondingly converts the data into a text to be replied, and then further determines the reply data.
In an embodiment, after step S101, the method further includes:
and detecting the sensitive words of the text to be replied, and if the text to be replied is determined to have no sensitive words, storing the text to be replied.
In this embodiment, since the text to be answered sent by the user after logging in the intelligent customer service question and answer system may not be a certain canonical expression, that is, there may be a case where a sensitive word exists, the server needs to perform sensitive word detection on the text to be answered after receiving the text to be answered obtained by correspondingly converting the information sent by the user side. Specifically, when the sensitive word detection is performed on the text to be replied, word segmentation processing may be performed on the text to be replied first (a jieba word segmentation model may be specifically adopted), each word segmentation in the word segmentation result may be compared with each sensitive word in a pre-stored sensitive word dictionary, if there is no sensitive word in the word segmentation result, it is determined that there is no sensitive word in the text to be replied, and at this time, corresponding reply data may be further obtained in the server based on the text to be replied. If the sensitive words exist in the word segmentation result, the existence of the sensitive words in the text to be replied is judged, and then prompt sentences such as 'please pay attention to the words of the current speaking line, please make civilized terms, thank' can be automatically generated by the server and sent to the server.
S102, determining a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression.
In this embodiment, the BERT in the BERT model is collectively called Bidirectional Encoder Representation from Transformers, which represents a Transformer model of Bidirectional encoding expression, and may also be understood as a pre-trained language characterization model. And inputting the text to be replied to the BERT model for feature extraction to obtain a current sentence embedding tensor corresponding to the text to be replied.
In an embodiment, the step S102 specifically includes:
acquiring a text preprocessing strategy corresponding to the BERT model;
preprocessing the text to be replied according to the text preprocessing strategy to obtain a preprocessing result;
and inputting the preprocessing result into the BERT model for feature extraction to obtain the current sentence embedding tensor.
In this embodiment, when extracting features of an input text based on a BERT model, corresponding preprocessing needs to be performed first, for example, adding a [ CLS ] special character to the head of the text to be replied and adding a [ SEP ] special character to the tail of the text to be replied may be regarded as a text preprocessing policy, or adding a [ CLS ] special character only to the head of the text to be replied may also be regarded as a text preprocessing policy. At this time, the text to be replied is preprocessed based on any one of the enumerated text preprocessing strategies, and then a preprocessing result can be obtained. And then inputting the preprocessing result into the BERT model for feature extraction, rather than directly inputting the text to be replied into the BERT model for feature extraction, so that a more accurate current sentence embedding tensor can be obtained. Typically how many characters are entered in the pre-processing result,
in an embodiment, the inputting the preprocessing result into the BERT model for feature extraction to obtain a current sentence embedding tensor includes:
acquiring a word vector, a text vector and a position vector of each character in the preprocessing result, and summing the word vector, the text vector and the position vector of each character to obtain an input vector of each character;
connecting the input vectors of each character in the preprocessing result to obtain a comprehensive input vector;
and inputting the comprehensive input vector into the BERT model for feature extraction to obtain the current sentence embedding tensor.
In this embodiment, when the BERT model is specifically used to process the preprocessing result to obtain a final feature tensor (that is, a current sentence Embedding tensor), a word vector (that is, Token Embedding), a text vector (that is, Segment Embedding) and a Position vector (that is, Position Embedding) of each character in the preprocessing result need to be obtained first, and the word vector, the text vector and the Position vector of each character are summed to obtain an input vector of each character. And after the input vector of each character in the preprocessing result is obtained, the input vector of each character is a column vector, the column vectors corresponding to the characters are connected according to the arrangement sequence of the characters in the preprocessing result at the moment to obtain a comprehensive input vector corresponding to the preprocessing result, finally, the comprehensive input vector is input into the BERT model for feature extraction, and the last layer of the BERT model is output to obtain the current sentence embedding tensor. Generally, the BERT model includes 12 layers, and the output of the 12 th layer is obtained as the current sentence embedding tensor. It can be seen that the feature tensor of the preprocessing result can be quickly extracted based on the BERT model.
S103, reducing the dimension of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimension reduction tensor.
In this embodiment, because the dimension of the current sentence embedding tensor is 768 dimensions, the dimension can still be reduced to solve the nonlinear problem of the sentence embedding tensor distribution, so that the dimension of the current sentence embedding tensor can be reduced by using kernel principal component analysis to obtain a 300-dimensional current dimension reduction tensor.
In an embodiment, step S103 specifically includes:
acquiring nonlinear mapping and feature space corresponding to the kernel principal component analysis, and mapping the current sentence embedding tensor to the feature space based on the nonlinear mapping to obtain a mapping result;
and acquiring a principal component analysis strategy corresponding to the kernel principal component analysis, and performing dimensionality reduction on the mapping result based on the principal component analysis strategy to obtain the current dimensionality reduction tensor.
In this embodiment, a Kernel Principal component Analysis method corresponding to Kernel Principal component Analysis, whose english is abbreviated as KPCA (Kernel Principal Components Analysis), is a nonlinear data processing method, and its core idea is to project data of an original space to a high-dimensional feature space through a nonlinear mapping, and then perform data processing based on Principal Component Analysis (PCA) in the high-dimensional feature space.
The nonlinear mapping corresponding to the kernel principal component analysis is a strategy of projecting data of an original space to a high-dimensional feature space, and the original space dimension to which the current sentence embedding tensor belongs is a dimension lower than the feature space. And after the current sentence embedding tensor is mapped to the feature space based on the nonlinear mapping to obtain a mapping result, performing dimensionality reduction processing on the mapping result by referring to a principal component analysis strategy, specifically, reducing the dimensionality of the 768-dimensional current sentence embedding tensor to a 300-dimensional current dimensionality reduction tensor.
In order to more clearly understand the dimensionality reduction process of the tensor by the kernel principal component analysis, a specific example is described below. The two most central concepts in kernel principal component analysis are kernel matrix and data matrix.
First defineThe kernel function is a function of two vectors x and y, and a commonly used kernel function is a gaussian kernel function, that is, k (x, y) = exp (— | x-y | |) 2 /(2σ 2 ));
Let the data matrix be X and N rows and d columns, that is, there are BERT embedding corresponding to question sentences and search keywords in N corpora, each BERT embedding length is d, ith action X i Namely, the sentence embedding tensor of the ith sentence;
defining a kernel matrix as K, wherein the value of the ith row and the jth column in the kernel matrix K is K ij = k(x i , x j );
Centralizing K, i.e.
Figure 710446DEST_PATH_IMAGE001
= K-1 N * K –K * 1 N + 1 N * K * 1 N (ii) a Wherein 1 is N Is a matrix of N x N, each element being 1/N;
below by K
Figure 830848DEST_PATH_IMAGE001
= K-1 N * K –K * 1 N + 1 N * K * 1 N Middle left side
Figure 876165DEST_PATH_IMAGE001
Then, calculating a characteristic value lambda and a corresponding characteristic vector a based on lambda, N, a = K, a, wherein a is N;
arranging the non-zero solution of the eigenvalue lambda and the corresponding eigenvector a according to the descending order of lambda to obtain a pair of solutions of alpha and lambda, (a) 1 , λ 1 ), (a 2 , λ 2 )…, (a d , λ d ) And let the kth solution of the eigenvector λ be a k
Then, the vector normalization is carried out, let a k ’* a k = 1/(λ k N), wherein a k ' means a k And (4) transposition. Let the k-th feature vector already normalized be a k
After the most core kernel function matrix K and data matrix X in the kernel principal component analysis are known, thenFor a new data point x, the corresponding kth principal component is:
Figure 474636DEST_PATH_IMAGE002
(ii) a Wherein,
Figure 554588DEST_PATH_IMAGE003
the ith element, k (x, x), representing the kth feature vector i ) And embedding a tensor into a sentence, which represents the data point X and the ith row, namely the ith sentence, in the data matrix X, and passing through a kernel function.
In an embodiment, step S103 is followed by:
and acquiring a text emotion analysis result of the text to be replied, and connecting an eigenvalue corresponding to the text emotion analysis result with the current dimension reduction tensor so as to update the current dimension reduction tensor.
In this embodiment, if only the current dimension reduction tensor corresponding to the keyword of the text to be replied is analyzed to obtain the corresponding target dimension reduction tensor and the corresponding reply text in the dimension reduction tensor database of the server, the obtained reply text may not be the most suitable text because the emotion analysis result of the text is not further analyzed. In order to improve the accuracy of the obtained reply text, a text emotion analysis result of the text to be replied may be further obtained, for example, a text emotion analysis method based on an emotion dictionary is used to determine the text emotion analysis result of the text to be replied.
Specifically, the text emotion analysis method based on the emotion dictionary comprises the following text emotion analysis process of a text to be replied:
the word segmentation result of the text to be replied is obtained firstly (for example, the ending word segmentation model exemplified by the above example is also adopted), then weight assignment is carried out on whether each word in the word segmentation result is a positive emotion or a negative emotion based on a prestored emotion dictionary, for example, a weight value 1 is given if the word is the positive emotion, a weight value-1 is given if the word is the negative emotion, and the weight values of each word are summed to obtain a weight sum corresponding to the word segmentation result. If the weight sum is a positive number, the text emotion analysis result of the text to be replied is a positive emotion and corresponds to a characteristic value 1, and if the weight sum is a negative number, the text emotion analysis result of the text to be replied is a negative emotion and corresponds to a characteristic value 0. And after the text emotion analysis result of the text to be replied and the characteristic value corresponding to the text emotion analysis result are obtained, connecting the characteristic value corresponding to the text emotion analysis result with the current dimension reduction tensor so as to update the current dimension reduction tensor. For example, the current dimension reduction tensor is 300 dimensions, the eigenvalue representing the emotion analysis result of the text is added by 1 dimension, and the current dimension reduction tensor is 301 dimensions after updating.
And S104, determining a target dimension reduction tensor which has the maximum similarity with the current dimension reduction tensor in the dimension reduction tensor database based on a prestored dimension reduction tensor database.
In this embodiment, for each answer text in the answer text knowledge base stored in advance, feature dimension reduction is performed on the basis of feature extraction of the BERT model and on the basis of kernel principal component analysis in the server, so as to obtain a dimension reduction tensor database corresponding to the answer text knowledge base. Each dimension reduction tensor in the dimension reduction tensor database is provided with an answer text correspondingly in the answer text knowledge base, so that feature extraction and feature dimension reduction processing of each answer text in the answer text knowledge base are effectively guaranteed. After the current dimension reduction tensor corresponding to the text to be replied is known, a target dimension reduction tensor having the largest similarity with the current dimension reduction tensor can be obtained in the dimension reduction tensor database, and the original text corresponding to the target dimension reduction tensor is generally the best reply text of the text to be replied.
In an embodiment, step S104 specifically includes:
and obtaining cosine similarity values of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database, and obtaining a target dimension reduction tensor which has the largest cosine similarity value with the current dimension reduction tensor.
In this embodiment, specifically, cosine similarity values of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database are calculated, where the larger the cosine similarity value of two vectors or tensors is, the larger the similarity between the two vectors or tensors is, so that a target dimension reduction tensor having the largest cosine similarity value with the current dimension reduction tensor is selected, and a text corresponding to the target dimension reduction tensor in an answer text knowledge base is taken as the best answer text of the text to be answered.
The current dimension reduction tensor may be a 300-dimensional vector and does not include a corresponding feature value of the text emotion analysis result of the text to be replied, or may be a 301-dimensional vector and includes a corresponding feature value of the text emotion analysis result of the text to be replied. However, in any of the above cases, the dimension reduction tensor stored in the dimension reduction tensor database is always consistent with the dimension of the current dimension reduction tensor, that is, the dimension reduction tensor stored in the dimension reduction tensor database is also a 300-dimensional vector when the current dimension reduction tensor is a 300-dimensional vector, and the dimension reduction tensor stored in the dimension reduction tensor database is also a 301-dimensional vector when the current dimension reduction tensor is a 301-dimensional vector. Therefore, based on the calculation of the cosine similarity value of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database, because the tensors are reduced into uniform dimensions, the condition that the lengths of the basis vectors in all dimensions are different does not exist, the assumption of cosine similarity is met, deviation is not generated when the vector similarity is calculated, and the result of the cosine similarity between the calculated tensors is more accurate.
And S105, acquiring original text data corresponding to the target dimension reduction tensor as a reply text.
In this embodiment, since the server has previously extracted the features of each answer text in the answer text knowledge base based on the BERT model and performed feature dimension reduction based on kernel principal component analysis to obtain the dimension reduction tensor database corresponding to the answer text knowledge base, after the dimension reduction tensor database has obtained the target dimension reduction tensor, the original text data corresponding to the target dimension reduction tensor can be obtained in the answer text knowledge base and serve as the reply text corresponding to the text to be replied. Therefore, based on the retrieval mode, the reply text is retrieved reversely after the target dimension reduction tensor is acquired, and the reply text can be acquired more efficiently.
And S106, sending the reply text to the user side.
In this embodiment, after the reply text corresponding to the text to be replied is acquired in the server, the reply text can be sent to the user side to be visually displayed in a reply information manner, so that the user can conveniently check the reply text.
According to the method, when the similarity between the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database is obtained after feature extraction and dimension reduction based on kernel principal component analysis are carried out correspondingly on the text to be replied, the tensor is reduced into the uniform dimension, the condition that the lengths of basis vectors in each dimension are different does not exist, the cosine similarity result between the calculated tensors is more accurate, and the obtained reply text corresponding to the target dimension reduction tensor is more accurate.
The embodiment of the application also provides a question-answer interaction device based on the kernel principal component analysis, and the question-answer interaction device based on the kernel principal component analysis is used for executing any embodiment of the question-answer interaction method based on the kernel principal component analysis. Specifically, referring to fig. 3, fig. 3 is a schematic block diagram of a question-answering interaction device 100 based on kernel principal component analysis according to an embodiment of the present application.
As shown in fig. 3, the question-answering interaction device 100 based on kernel principal component analysis includes a to-be-replied text acquisition unit 101, a current tensor acquisition unit 102, a tensor dimension reduction unit 103, a target tensor acquisition unit 104, a reply text acquisition unit 105, and a reply text sending unit 106.
A text to be replied acquiring unit 101, configured to acquire a text to be replied based on an input at a user end.
In this embodiment, a server is used as an execution subject to describe the technical solution. A user side (such as an intelligent terminal like a smart phone or a tablet computer) used by a user can perform data interaction with a server, specifically, the server provides an intelligent customer service question-answering system, and the user side can log in the intelligent customer service question-answering system. And a user interaction interface of the intelligent customer service question and answer system is displayed on a terminal interface of the user side, and a chat frame exists in the user interaction interface. The user can input any character string to be consulted in the chat frame as a text to be replied, and after the server receives the text to be replied sent by the user side, the server can quickly acquire corresponding reply data from a background knowledge base of the intelligent customer service question-answering system and correspondingly display the reply data in the chat frame to finish the intelligent question-answering process.
Wherein, the source of the text to be replied has at least the following three modes:
the first is that the user sends text data as the reply text;
the second is data in a voice form sent by a user terminal, and at this time, the data in the voice form needs to be converted into data in a text form based on a voice recognition model (such as an N-gram multivariate model) stored in a server and used as a text to be replied;
the third is data in picture form sent by the user terminal, and at this time, the data in picture form needs to be converted into data in text form based on an image recognition model (such as an optical character recognition model) stored in the server, and the data is used as text to be replied.
However, no matter which form of data is sent from the user side to the server, the server correspondingly converts the data into a text to be replied, and then further determines the reply data.
In one embodiment, the question-answering interaction device 100 based on kernel principal component analysis further includes:
and the sensitive word detection unit is used for detecting the sensitive words of the text to be replied, and storing the text to be replied if the situation that the sensitive words do not exist in the text to be replied is determined.
In this embodiment, since the text to be answered sent by the user after logging in the intelligent customer service question and answer system may not be a certain canonical expression, that is, there may be a case where a sensitive word exists, the server needs to perform sensitive word detection on the text to be answered after receiving the text to be answered obtained by correspondingly converting the information sent by the user side. Specifically, when the sensitive word detection is performed on the text to be replied, word segmentation processing may be performed on the text to be replied first (a jieba word segmentation model may be specifically adopted), each word segmentation in the word segmentation result may be compared with each sensitive word in a pre-stored sensitive word dictionary, and if there is no sensitive word in the word segmentation result, it is determined that there is no sensitive word in the text to be replied, and at this time, corresponding reply data may be further obtained in the server based on the text to be replied. If the sensitive words exist in the word segmentation result, the existence of the sensitive words in the text to be replied is judged, and then prompt sentences such as 'please pay attention to the words of the current speaking line, please make civilized terms, thank' can be automatically generated by the server and sent to the server.
A current tensor obtaining unit 102, configured to determine a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression.
In this embodiment, the BERT in the BERT model is collectively called Bidirectional Encoder Representation from transforms, which represents a transform model of Bidirectional encoding expression, and may also be understood as a pre-trained language Representation model. And inputting the text to be replied to the BERT model for feature extraction to obtain a current sentence embedding tensor corresponding to the text to be replied.
In an embodiment, the current tensor acquisition unit 102 is specifically configured to:
acquiring a text preprocessing strategy corresponding to the BERT model;
preprocessing the text to be replied according to the text preprocessing strategy to obtain a preprocessing result;
and inputting the preprocessing result into the BERT model for feature extraction to obtain the current sentence embedding tensor.
In this embodiment, when extracting features of an input text based on a BERT model, corresponding preprocessing needs to be performed first, for example, adding a [ CLS ] special character to the head of the text to be replied and adding a [ SEP ] special character to the tail of the text to be replied may be regarded as a text preprocessing policy, or adding a [ CLS ] special character only to the head of the text to be replied may also be regarded as a text preprocessing policy. At this time, a preprocessing result can be obtained after preprocessing the text to be replied based on any one of the enumerated text preprocessing strategies. And then inputting the preprocessing result into the BERT model for feature extraction, instead of directly inputting the text to be replied into the BERT model for feature extraction, so that a more accurate current sentence embedding tensor can be obtained. Typically how many characters are entered in the pre-processing result,
in an embodiment, the inputting the preprocessing result into the BERT model for feature extraction to obtain a current sentence embedding tensor includes:
acquiring a word vector, a text vector and a position vector of each character in the preprocessing result, and summing the word vector, the text vector and the position vector of each character to obtain an input vector of each character;
connecting the input vectors of each character in the preprocessing result to obtain a comprehensive input vector;
and inputting the comprehensive input vector into the BERT model for feature extraction to obtain the current sentence embedding tensor.
In this embodiment, when the BERT model is specifically used to process the preprocessing result to obtain a final feature tensor (that is, a current sentence Embedding tensor), a word vector (that is, Token Embedding), a text vector (that is, Segment Embedding) and a Position vector (that is, Position Embedding) of each character in the preprocessing result need to be obtained first, and the word vector, the text vector and the Position vector of each character are summed to obtain an input vector of each character. And after the input vector of each character in the preprocessing result is obtained, the input vector of each character is a column vector, the column vectors respectively corresponding to the plurality of characters are connected according to the arrangement sequence of the characters in the preprocessing result at the moment to obtain a comprehensive input vector corresponding to the preprocessing result, finally, the comprehensive input vector is input into the BERT model for feature extraction, and the current sentence embedding tensor is obtained through the last layer output of the BERT model. Generally, the BERT model includes 12 layers, and the output of the 12 th layer is obtained as the current sentence embedding tensor. It can be seen that the feature tensor of the preprocessing result can be quickly extracted based on the BERT model.
And the tensor dimension reduction unit 103 is used for reducing the dimension of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimension reduction tensor.
In this embodiment, because the current sentence is embedded into the tensor for 768 dimensions, the dimension of the current sentence can be reduced continuously to solve the nonlinear problem of the distribution of the sentence embedding tensor, so that the dimension of the current sentence embedding tensor can be reduced by using kernel principal component analysis to obtain a 300-dimensional current dimension reduction tensor.
In an embodiment, the tensor dimension reduction unit 103 is specifically configured to:
acquiring a nonlinear mapping and an eigenspace corresponding to the kernel principal component analysis, and mapping the current sentence embedding tensor to the eigenspace based on the nonlinear mapping to obtain a mapping result;
and acquiring a principal component analysis strategy corresponding to the kernel principal component analysis, and performing dimensionality reduction on the mapping result based on the principal component analysis strategy to obtain the current dimensionality reduction tensor.
In this embodiment, a Kernel Principal component Analysis method corresponding to Kernel Principal component Analysis, whose english is abbreviated as KPCA (Kernel Principal Components Analysis), is a nonlinear data processing method, and its core idea is to project data of an original space to a high-dimensional feature space through a nonlinear mapping, and then perform data processing based on Principal Component Analysis (PCA) in the high-dimensional feature space.
The nonlinear mapping corresponding to the kernel principal component analysis is a strategy of projecting data of an original space to a high-dimensional feature space, and the original space dimension to which the current sentence embedding tensor belongs is a dimension lower than the feature space. And after the current sentence embedding tensor is mapped to the feature space based on the nonlinear mapping to obtain a mapping result, performing dimensionality reduction processing on the mapping result by referring to a principal component analysis strategy, specifically, reducing the dimensionality of the 768-dimensional current sentence embedding tensor to a 300-dimensional current dimensionality reduction tensor.
In order to more clearly understand the dimensionality reduction process of the tensor by the kernel principal component analysis, a specific example is described below. The two most central concepts in kernel principal component analysis are kernel matrix and data matrix.
Firstly, defining a kernel function as a function of two vectors x and y, wherein a commonly used kernel function is a Gaussian kernel function, namely k (x, y) = exp (- | | x-y | | | | ^2/(2\ sigma ^ 2));
let the data matrix be X and be N rows and d columns, namely there are questions in N corpora and BERT embedding corresponding to search keyword, each BERT embedding length is d, the ith behavior X _ i is sentence embedding tensor of the ith sentence;
defining a kernel matrix as K, wherein the value of the ith row and the jth column in the kernel matrix K is K ij = k(x i , x j );
Centralizing K, i.e.
Figure 829580DEST_PATH_IMAGE001
= K-1 N * K –K * 1 N + 1 N * K * 1 N (ii) a Wherein 1 is N Is a matrix of N x N, each element being 1/N;
below by K
Figure 362193DEST_PATH_IMAGE001
= K-1 N * K –K * 1 N + 1 N * K * 1 N Middle left side
Figure 764355DEST_PATH_IMAGE001
Then, calculating a characteristic value lambda and a corresponding characteristic vector a based on lambda, N, a = K, a, wherein a is N;
arranging the non-zero solution of the eigenvalue lambda and the corresponding eigenvector a according to the sequence of the lambda from large to small to obtain a pair of solutions of the alpha and the lambda, (a) 1 , λ 1 ), (a 2 , λ 2 )…, (a d , λ d ) And let the kth solution of the eigenvector λ be a k
Then, vector normalization is carried out, and let a k ’* a k = 1/(λ k N), wherein a k ' means a k And (4) transposition. Let the k-th feature vector already normalized be a k
After the most core kernel function matrix K and the data matrix X in the kernel principal component analysis are known, then for a new data point X, the corresponding kth principal component is:
Figure 902075DEST_PATH_IMAGE002
(ii) a Wherein,
Figure 161018DEST_PATH_IMAGE003
the ith element, k (x, x), representing the kth feature vector i ) The sentence embedding tensor, which represents the data point X and the ith row, i.e. the ith sentence, in the data matrix X, passes through the kernel function.
In one embodiment, the question-answering interaction device 100 based on kernel principal component analysis further includes:
and the emotion analysis unit is used for acquiring a text emotion analysis result of the text to be replied and connecting the eigenvalue corresponding to the text emotion analysis result with the current dimension reduction tensor so as to update the current dimension reduction tensor.
In this embodiment, if only the current dimension reduction tensor corresponding to the keyword of the text to be replied is analyzed to obtain the corresponding target dimension reduction tensor and the corresponding reply text in the dimension reduction tensor database of the server, the obtained reply text may not be the most suitable text because the emotion analysis result of the text is not further analyzed. In order to improve the accuracy of the obtained reply text, a text emotion analysis result of the text to be replied may be further obtained, for example, a text emotion analysis method based on an emotion dictionary is used to determine the text emotion analysis result of the text to be replied.
Specifically, the text emotion analysis method based on the emotion dictionary comprises the following text emotion analysis process of a text to be replied:
the word segmentation result of the text to be replied is obtained firstly (for example, the ending word segmentation model exemplified by the above example is also adopted), then weight assignment is carried out on whether each word in the word segmentation result is a positive emotion or a negative emotion based on a prestored emotion dictionary, for example, a weight value 1 is given if the word is the positive emotion, a weight value-1 is given if the word is the negative emotion, and the weight values of each word are summed to obtain a weight sum corresponding to the word segmentation result. If the weight sum is a positive number, the text emotion analysis result of the text to be replied is a positive emotion and corresponds to a characteristic value 1, and if the weight sum is a negative number, the text emotion analysis result of the text to be replied is a negative emotion and corresponds to a characteristic value 0. And after the text emotion analysis result of the text to be replied and the characteristic value corresponding to the text emotion analysis result are obtained, connecting the characteristic value corresponding to the text emotion analysis result with the current dimension reduction tensor so as to update the current dimension reduction tensor. For example, the current dimension reduction tensor is 300 dimensions, the eigenvalue representing the emotion analysis result of the text is added by 1 dimension, and the current dimension reduction tensor is 301 dimensions after updating.
And the target tensor acquiring unit 104 is configured to determine, based on a pre-stored dimension reduction tensor database, a target dimension reduction tensor having the largest similarity with the current dimension reduction tensor in the dimension reduction tensor database.
In this embodiment, for each answer text in the answer text knowledge base stored in advance, feature dimension reduction is performed on the basis of feature extraction of the BERT model and on the basis of kernel principal component analysis in the server, so as to obtain a dimension reduction tensor database corresponding to the answer text knowledge base. Each dimension reduction tensor in the dimension reduction tensor database is provided with an answer text correspondingly in the answer text knowledge base, so that feature extraction and feature dimension reduction processing of each answer text in the answer text knowledge base are effectively guaranteed. After the current dimension reduction tensor corresponding to the text to be replied is known, a target dimension reduction tensor having the largest similarity with the current dimension reduction tensor can be obtained in the dimension reduction tensor database, and the original text corresponding to the target dimension reduction tensor is generally the best reply text of the text to be replied.
In an embodiment, the target tensor obtaining unit 104 is specifically configured to:
and obtaining cosine similarity values of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database, and obtaining a target dimension reduction tensor with the largest cosine similarity value between the current dimension reduction tensor and the current dimension reduction tensor.
In this embodiment, specifically, cosine similarity values of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database are calculated, where the larger the cosine similarity values of two vectors or tensors are, the larger the similarity between the two vectors or tensors is, so that a target dimension reduction tensor having the largest cosine similarity value with the current dimension reduction tensor is selected, and a text of the target dimension reduction tensor corresponding to the answer text knowledge base is taken as the best answer text of the text to be answered.
The current dimension reduction tensor may be a 300-dimensional vector and does not include a corresponding feature value of the text emotion analysis result of the text to be replied, or may be a 301-dimensional vector and includes a corresponding feature value of the text emotion analysis result of the text to be replied. However, in any of the above-mentioned cases, the dimension reduction tensor stored in the dimension reduction tensor database is always consistent with the dimension of the current dimension reduction tensor, that is, the dimension reduction tensor stored in the dimension reduction tensor database is also a 300-dimensional vector when the current dimension reduction tensor is a 300-dimensional vector, and the dimension reduction tensor stored in the dimension reduction tensor database is also a 301-dimensional vector when the current dimension reduction tensor is a 301-dimensional vector. Therefore, based on the calculation of the cosine similarity value of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database, because the tensors are reduced into uniform dimensions, the condition that the lengths of the basis vectors in all dimensions are different does not exist, the assumption of cosine similarity is met, deviation is not generated when the vector similarity is calculated, and the result of the cosine similarity between the calculated tensors is more accurate.
And the reply text acquisition unit 105 is configured to acquire original text data corresponding to the target dimension reduction tensor as a reply text.
In this embodiment, since the server has previously performed feature dimension reduction on each answer text in the answer text knowledge base based on the feature extraction of the BERT model and based on kernel principal component analysis to obtain the dimension reduction tensor database corresponding to the answer text knowledge base, after the dimension reduction tensor database obtains the target dimension reduction tensor, the original text data corresponding to the target dimension reduction tensor can be obtained in the answer text knowledge base and used as the reply text corresponding to the text to be replied. Therefore, based on the retrieval mode, the reply text is retrieved reversely after the target dimension reduction tensor is acquired, and the reply text can be acquired more efficiently.
A reply text sending unit 106, configured to send the reply text to the user side.
In this embodiment, after the reply text corresponding to the text to be replied is acquired in the server, the reply text can be sent to the user side to be visually displayed in a reply information manner, so that the user can conveniently check the reply text.
The device realizes that when the similarity between the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database is obtained after the feature extraction and the dimension reduction based on the kernel principal component analysis are correspondingly carried out on the text to be replied, the tensor has been reduced into the uniform dimension, the condition that the lengths of the basis vectors in each dimension are different does not exist, the cosine similarity result between the calculated tensors is more accurate, and the obtained reply text corresponding to the target dimension reduction tensor is more accurate.
The above-mentioned question-answering interaction device based on kernel principal component analysis may be implemented in the form of a computer program, which may be run on a computer apparatus as shown in fig. 4.
Referring to fig. 4, fig. 4 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 may be a server or a server cluster. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a web service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), and a big data and artificial intelligence platform.
Referring to fig. 4, the computer apparatus 500 comprises a processor 502, a memory, and a network interface 505 connected by a device bus 501, wherein the memory may comprise a storage medium 503 and an internal memory 504.
The storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032, when executed, causes the processor 502 to perform a question-answer interaction method based on kernel principal component analysis.
The processor 502 is used to provide computing and control capabilities that support the operation of the overall computer device 500.
The internal memory 504 provides an environment for the operation of the computer program 5032 in the storage medium 503, and when the computer program 5032 is executed by the processor 502, the processor 502 can be enabled to execute the question-answering interaction method based on the kernel principal component analysis.
The network interface 505 is used for network communication, such as providing transmission of data information. Those skilled in the art will appreciate that the configuration shown in fig. 4 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation of the computer device 500 to which the present application may be applied, and that a particular computer device 500 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
The processor 502 is configured to run the computer program 5032 stored in the memory to implement the question answering interaction method based on kernel principal component analysis disclosed in the embodiment of the present application.
Those skilled in the art will appreciate that the embodiment of a computer device illustrated in fig. 4 does not constitute a limitation on the specific construction of the computer device, and that in other embodiments a computer device may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may only include a memory and a processor, and in such embodiments, the structures and functions of the memory and the processor are consistent with those of the embodiment shown in fig. 4, which are not described herein again.
It should be understood that in the embodiment of the present Application, the Processor 502 may be a Central Processing Unit (CPU), and the Processor 502 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In another embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium may be a nonvolatile computer-readable storage medium or a volatile computer-readable storage medium. The computer readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the question-answer interaction method based on kernel principal component analysis disclosed in the embodiments of the present application.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the above-described devices, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus, device and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the units is only a logical division, and there may be other divisions when the actual implementation is performed, or units having the same function may be grouped into one unit, for example, a plurality of units or components may be combined or may be integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may also be an electric, mechanical or other form of connection.
The units described as separate parts may or may not be physically separate, and parts displayed as units 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 units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present application.
In addition, functional units in the embodiments of the present application 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, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a storage medium. Based on such understanding, the technical solutions of the present application may substantially or partially contribute to the prior art, or all or part of the technical solutions may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a background server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (8)

1. A question-answer interaction method based on kernel principal component analysis is characterized by comprising the following steps:
acquiring a text to be replied based on input of a user side;
determining a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression;
reducing the dimension of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimension reduction tensor;
determining a target dimension reduction tensor which has the maximum similarity with the current dimension reduction tensor in the dimension reduction tensor database based on a prestored dimension reduction tensor database;
acquiring original text data corresponding to the target dimension reduction tensor as a reply text; and
sending the reply text to a user side;
performing dimensionality reduction on the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimensionality reduction tensor, including:
acquiring a nonlinear mapping and an eigenspace corresponding to the kernel principal component analysis, and mapping the current sentence embedding tensor to the eigenspace based on the nonlinear mapping to obtain a mapping result;
obtaining a principal component analysis strategy corresponding to the kernel principal component analysis, and performing dimensionality reduction on the mapping result based on the principal component analysis strategy to obtain the current dimensionality reduction tensor;
the dimensionality reduction is performed on the current sentence embedding tensor based on the kernel principal component analysis, and after the current dimensionality reduction tensor is obtained, the method further comprises the following steps:
acquiring a text emotion analysis result of the text to be replied, and connecting an eigenvalue corresponding to the text emotion analysis result with the current dimension reduction tensor to update the current dimension reduction tensor;
the dimension reduction tensor database stores a dimension reduction tensor that is the same as the dimension of the current dimension reduction tensor.
2. The question-answering interaction method based on kernel principal component analysis according to claim 1, wherein the determining of the current sentence embedding tensor of the text to be replied based on the pre-stored BERT model comprises:
acquiring a text preprocessing strategy corresponding to the BERT model;
preprocessing the text to be replied according to the text preprocessing strategy to obtain a preprocessing result;
and inputting the preprocessing result into the BERT model for feature extraction to obtain the current sentence embedding tensor.
3. The question-answer interaction method based on kernel principal component analysis according to claim 2, wherein the inputting the preprocessing result to the BERT model for feature extraction to obtain a current sentence embedding tensor comprises:
acquiring a word vector, a text vector and a position vector of each character in the preprocessing result, and summing the word vector, the text vector and the position vector of each character to obtain an input vector of each character;
connecting the input vectors of each character in the preprocessing result to obtain a comprehensive input vector;
and inputting the comprehensive input vector to the BERT model for feature extraction to obtain the current sentence embedding tensor.
4. The question-answer interaction method based on kernel principal component analysis according to claim 1, wherein after obtaining the text to be replied based on the input from the user side, the method further comprises:
and detecting the sensitive words of the text to be replied, and if the text to be replied is determined to have no sensitive words, storing the text to be replied.
5. The method for interacting questions and answers based on kernel principal component analysis according to claim 1, wherein the determining a target dimension reduction tensor in the dimension reduction tensor database having the greatest similarity with the current dimension reduction tensor comprises:
and obtaining cosine similarity values of the current dimension reduction tensor and each dimension reduction tensor in the dimension reduction tensor database, and obtaining a target dimension reduction tensor with the largest cosine similarity value between the current dimension reduction tensor and the current dimension reduction tensor.
6. A question-answer interaction device based on kernel principal component analysis is characterized by comprising:
the text to be replied acquiring unit is used for acquiring a text to be replied based on the input of the user terminal;
the current tensor acquiring unit is used for determining a current sentence embedding tensor of the text to be replied based on a pre-stored BERT model; wherein the BERT model is a Transformer model of bidirectional coding expression;
the tensor dimension reduction unit is used for reducing the dimension of the current sentence embedding tensor based on kernel principal component analysis to obtain a current dimension reduction tensor;
the target tensor acquiring unit is used for determining a target dimension reduction tensor which has the maximum similarity with the current dimension reduction tensor in the dimension reduction tensor database based on a prestored dimension reduction tensor database;
a reply text acquisition unit, configured to acquire original text data corresponding to the target dimension reduction tensor as a reply text; and
the reply text sending unit is used for sending the reply text to the user side;
the tensor dimensionality reduction unit is used for:
acquiring nonlinear mapping and feature space corresponding to the kernel principal component analysis, and mapping the current sentence embedding tensor to the feature space based on the nonlinear mapping to obtain a mapping result;
obtaining a principal component analysis strategy corresponding to the kernel principal component analysis, and performing dimensionality reduction on the mapping result based on the principal component analysis strategy to obtain the current dimensionality reduction tensor;
the question-answering interaction device based on kernel principal component analysis further comprises:
the emotion analysis unit is used for acquiring a text emotion analysis result of the text to be replied and connecting a characteristic value corresponding to the text emotion analysis result with the current dimension reduction tensor so as to update the current dimension reduction tensor;
the dimension reduction tensor database stores a dimension reduction tensor that is the same as the dimension of the current dimension reduction tensor.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the kernel principal component analysis-based question-answer interaction method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, causes the processor to execute the kernel principal component analysis-based question-answer interaction method according to any one of claims 1 to 5.
CN202210732742.8A 2022-06-27 2022-06-27 Question-answer interaction method and device based on kernel principal component analysis and computer equipment Active CN114817511B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210732742.8A CN114817511B (en) 2022-06-27 2022-06-27 Question-answer interaction method and device based on kernel principal component analysis and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210732742.8A CN114817511B (en) 2022-06-27 2022-06-27 Question-answer interaction method and device based on kernel principal component analysis and computer equipment

Publications (2)

Publication Number Publication Date
CN114817511A CN114817511A (en) 2022-07-29
CN114817511B true CN114817511B (en) 2022-09-23

Family

ID=82522981

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210732742.8A Active CN114817511B (en) 2022-06-27 2022-06-27 Question-answer interaction method and device based on kernel principal component analysis and computer equipment

Country Status (1)

Country Link
CN (1) CN114817511B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117609462B (en) * 2023-11-29 2024-07-09 广州方舟信息科技有限公司 Medicine question-answering method, medicine question-answering robot, electronic device and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108549908A (en) * 2018-04-13 2018-09-18 浙江科技学院 Chemical process fault detection method based on more sampled probability core principle component models

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2979200A4 (en) * 2013-03-29 2016-11-16 Hewlett Packard Development Co Query features and questions
WO2020084787A1 (en) * 2018-10-26 2020-04-30 Nec Corporation A source separation device, a method for a source separation device, and a non-transitory computer readable medium
CN110321419B (en) * 2019-06-28 2021-06-15 神思电子技术股份有限公司 Question-answer matching method integrating depth representation and interaction model
CN111949774A (en) * 2020-07-08 2020-11-17 深圳鹏锐信息技术股份有限公司 Intelligent question answering method and system
CN113742471B (en) * 2021-09-15 2023-09-12 重庆大学 Vector retrieval type dialogue method of Pu-Fa question-answering system
CN113704386A (en) * 2021-10-27 2021-11-26 深圳前海环融联易信息科技服务有限公司 Text recommendation method and device based on deep learning and related media
CN114372835B (en) * 2022-03-22 2022-06-24 佰聆数据股份有限公司 Comprehensive energy service potential customer identification method, system and computer equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108549908A (en) * 2018-04-13 2018-09-18 浙江科技学院 Chemical process fault detection method based on more sampled probability core principle component models

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Extending classical surrogate modelling to high-dimensions through supervised dimensionality reduction: a data-driven approach;C. Lataniotis等;《https://arxiv.org/abs/1812.06309》;20200211;第1-39页 *
Scikit-learn 的内核 PCA:如何在 KPCA 中实现各向异性高斯内核或任何其他自定义内核?;作者不详;《https://www.it1352.com/2397194.html》;20210716;第1页 *
基于生成模型的高维数据异常检测;吕鹏;《中国优秀硕士学位论文全文数据库信息科技辑》;20210915(第9期);第I138-171页 *

Also Published As

Publication number Publication date
CN114817511A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN111046152B (en) Automatic FAQ question-answer pair construction method and device, computer equipment and storage medium
US11669739B2 (en) Name and face matching
CN109710942B (en) Map construction method and device and electronic equipment
CN110377733B (en) Text-based emotion recognition method, terminal equipment and medium
US20190354588A1 (en) Device and method for natural language processing
KR20210151281A (en) Textrank based core sentence extraction method and device using bert sentence embedding vector
CN109344242B (en) Dialogue question-answering method, device, equipment and storage medium
CN111368037A (en) Text similarity calculation method and device based on Bert model
CN107293285B (en) Voice processing method and device
CN111859940B (en) Keyword extraction method and device, electronic equipment and storage medium
WO2021204017A1 (en) Text intent recognition method and apparatus, and related device
CN114817511B (en) Question-answer interaction method and device based on kernel principal component analysis and computer equipment
CN115329207B (en) Intelligent sales information recommendation method and system
CN117874210B (en) Autonomous interactive question-answering method, system, equipment and medium
CN111967253A (en) Entity disambiguation method and device, computer equipment and storage medium
CN112084769A (en) Dependency syntax model optimization method, device, equipment and readable storage medium
CN111898363B (en) Compression method, device, computer equipment and storage medium for long and difficult text sentence
CN111368554B (en) Statement processing method, device, computer equipment and storage medium
CN115952854B (en) Training method of text desensitization model, text desensitization method and application
CN112800217A (en) Vector relevance matrix-based intelligent assessment method for government affair transaction processing report
CN110287396B (en) Text matching method and device
CN111680501A (en) Query information identification method and device based on deep learning and storage medium
CN116680401A (en) Document processing method, document processing device, apparatus and storage medium
KR102363958B1 (en) Method, apparatus and program for analyzing customer perception based on double clustering
CN111858899B (en) Statement processing method, device, system and 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