Question corpus construction method and device, question and answer method, equipment and storage medium
By using a target text representation model and a clustering model to perform vector transformation and clustering processing on question text data, the problem of inaccurate text clustering is solved, and the accuracy of corpus construction and the matching degree of question-answering assistant responses are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2026-03-31
AI Technical Summary
Existing text clustering methods are prone to inaccurate clustering when constructing a corpus for question-answering assistants in financial scenarios, which affects the accuracy of question-answering operations.
The target question text data is vectorized by a pre-defined target text representation model, and text clustering is performed using a target clustering model. Combined with pooling and normalization, target text clusters and clustering labels are obtained to construct a question corpus.
This improved the accuracy of question corpus construction and the matching accuracy of Q&A assistant responses, ensuring the accuracy of Q&A operations.
Smart Images

Figure CN116775875B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial technology, and in particular to a method and apparatus for constructing a question corpus, a question-answering method, a device, and a storage medium. Background Technology
[0002] Text clustering refers to grouping semantically similar texts into a single class, achieving maximum intra-class similarity and minimum inter-class similarity. Text clustering methods can be used to construct corpora for question-answering assistants. However, because text clustering is an unsupervised machine learning method, meaning it cannot learn from supervised signals, it can easily lead to poor clustering results in some scenarios. For example, when constructing a corpus for a question-answering assistant in a financial context using text clustering, incorrect clustering of individual data points can occur, impacting question-answering operations. For instance, a corpus for insurance consultation might contain data related to insurance claims. Therefore, improving the accuracy of corpus construction using text clustering methods has become a pressing technical problem. Summary of the Invention
[0003] The main objective of this application is to propose a method and apparatus for constructing a question corpus, a question-answering method, a device, and a storage medium, aiming to improve the accuracy of constructing a question corpus.
[0004] To achieve the above objectives, a first aspect of this application proposes a method for constructing a question corpus, the method comprising:
[0005] Obtain the target question text data;
[0006] The target question text data is vectorized according to the preset target text representation model to obtain the target text vector;
[0007] The target text vectors are subjected to text clustering processing according to a preset target clustering model to obtain target text clusters; wherein, the target text clusters include target text clustering vectors;
[0008] The target text clustering vector is pooled to obtain the target text center vector of the target text cluster;
[0009] The target text center vector is normalized to obtain the target clustering label of the target text cluster; wherein, the target clustering label is used to characterize the semantic category of the target text cluster;
[0010] A question corpus is constructed based on the target clustering labels and the target text clusters.
[0011] In some embodiments, before performing vector transformation on the target question text data according to a preset target text representation model to obtain a target text vector, the method further includes training the target text representation model, specifically including:
[0012] Obtain the original text clusters with original clustering labels; wherein, the original clustering labels are used to characterize the semantic category of the original text clusters, and the original text clusters include the original question text data;
[0013] The original question text data is vectorized according to the preset original text representation model to obtain sample text vectors;
[0014] The sample text vectors are subjected to text clustering processing according to a preset original clustering model to obtain sample text clusters; wherein, the sample text clusters include sample text clustering vectors;
[0015] The sample text clustering vectors are pooled to obtain the sample text center vectors of the sample text clusters;
[0016] The center vector of the sample text is normalized to obtain the sample clustering label of the sample text cluster; wherein, the sample clustering label is used to characterize the semantic category of the sample text cluster;
[0017] The target text representation model is obtained by adjusting the parameters of the original text representation model based on the sample cluster labels and the original cluster labels.
[0018] In some embodiments, training the target text representation model further includes training the target text representation model, specifically including:
[0019] The clustering accuracy is calculated based on the sample clustering labels, the original clustering labels, and the original question text data to obtain the clustering accuracy value;
[0020] The model parameters of the original clustering model are adjusted based on the clustering accuracy value to obtain an initial clustering model;
[0021] The original question text data is vectorized according to the preset target text representation model to obtain training text vectors;
[0022] The training text vectors are clustered according to the initial clustering model to obtain training sample text clusters.
[0023] The target text representation model is trained based on the training sample text clusters until the clustering accuracy value equals a preset accuracy threshold.
[0024] In some embodiments, adjusting the model parameters of the original clustering model based on the clustering accuracy value to obtain an initial clustering model includes:
[0025] The clustering accuracy value is compared with the preset accuracy threshold to obtain the comparison result;
[0026] If the comparison result indicates that the clustering accuracy value is less than the preset accuracy threshold, then the center vector of the sample text is used as the center vector of the original clustering model to obtain the initial clustering model.
[0027] In some embodiments, the step of performing text clustering processing on the sample text vectors according to a preset original clustering model to obtain sample text clusters includes:
[0028] The center vector of the sample text vector is selected according to the preset number of clusters to obtain the original text center vector;
[0029] Based on the original text center vector, the sample text vector is filtered to obtain candidate text vectors;
[0030] The similarity between the candidate text vector and the original text center vector is calculated to obtain a similarity value;
[0031] The smallest similarity value is taken as the key value, and the original text center vector of the key value is taken as the key text center vector. The sample text cluster is obtained based on the key text center vector and the candidate text vector.
[0032] In some embodiments, the target text representation model includes an encoding layer and a vector representation layer;
[0033] The step of performing vector transformation on the target question text data according to a preset target text representation model to obtain a target text vector includes:
[0034] The target question text data is vectorized according to the encoding layer to obtain an initial text vector;
[0035] The initial text vector is semantically fused using the vector representation layer to obtain the target text vector.
[0036] To achieve the above objectives, a second aspect of this application proposes a question-and-answer method, the method comprising:
[0037] Obtain the text data to be answered;
[0038] The text data to be answered is semantically matched with the target text cluster in the preset question corpus to obtain the matching result; wherein, the preset question corpus is constructed according to the method described in the first aspect;
[0039] The target text clusters that represent semantic matching in the matching results are taken as key text clusters;
[0040] The key answer text clusters are obtained by filtering from the preset original answer text clusters based on the key text clusters;
[0041] The response is processed based on the key answer text cluster to obtain the answer text data of the text data to be answered.
[0042] To achieve the above objectives, a third aspect of this application provides an apparatus for constructing a problem corpus, the apparatus comprising:
[0043] The data acquisition module is used to acquire text data of the target question.
[0044] The vector conversion module is used to perform vector conversion on the target question text data according to a preset target text representation model to obtain the target text vector;
[0045] The text clustering module is used to perform text clustering processing on the target text vector according to a preset target clustering model to obtain target text clusters; wherein, the target text clusters include target text clustering vectors;
[0046] The pooling module is used to pool the target text clustering vector to obtain the target text center vector of the target text cluster;
[0047] A normalization module is used to normalize the target text center vector to obtain the target cluster label of the target text cluster; wherein, the target cluster label is used to characterize the semantic category of the target text cluster;
[0048] The corpus construction module is used to construct a question corpus based on the target clustering labels and the target text clusters.
[0049] To achieve the above objectives, a fourth aspect of the present application provides an electronic device, the electronic device including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method described in the first aspect or the method described in the second aspect.
[0050] To achieve the above objectives, a fifth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect or the method described in the second aspect.
[0051] The question corpus construction method, apparatus, question-answering method, device, and storage medium proposed in this application perform vector transformation on target question text data through a preset target text representation model to obtain target text vectors that accurately represent the semantic features of the target question text data. Then, text clustering processing is performed on the target text vectors through a target clustering model to obtain target text clusters. Therefore, the embodiments of this application avoid the method of directly constructing a corpus through text clustering in related technologies. The embodiments of this application perform text clustering processing through target text vectors, which can improve the accuracy of text clustering processing. Therefore, when target clustering labels are obtained from the target text clustering vectors in the target text clusters, and a question corpus is constructed based on the target clustering labels and target text clusters, the accuracy of constructing the question corpus can be improved. When this application is applied to the construction of a question-answering assistant corpus in a financial scenario, the accuracy of the question-answering assistant corpus construction can be improved. When intelligent responses are provided based on the above-mentioned question-answering assistant, the matching degree between the response corpus and the content of the question asked can be improved. Attached Figure Description
[0052] Figure 1 This is a flowchart of the problem corpus construction method provided in the embodiments of this application;
[0053] Figure 2 Is Figure 1 Flowchart of steps preceding step S102;
[0054] Figure 3 yes Figure 2 The flowchart of step S203 in the process;
[0055] Figure 4 yes Figure 2 The flowchart of steps S206 and later also includes steps;
[0056] Figure 5 yes Figure 4 The flowchart of step S402 in the document;
[0057] Figure 6 yes Figure 1 The flowchart of step S102 in the document;
[0058] Figure 7 This is a flowchart of the question-and-answer method provided in the embodiments of this application;
[0059] Figure 8 This is a schematic diagram of the structure of the problem corpus construction apparatus provided in the embodiments of this application;
[0060] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0062] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0064] First, let's analyze some of the terms used in this application:
[0065] Artificial intelligence (AI) is a new branch of computer science that studies, develops, and applies theories, methods, technologies, and systems to simulate, extend, and expand human intelligence. It aims to understand the essence of intelligence and produce intelligent machines that can react in a way similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thought. Furthermore, AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results.
[0066] Natural Language Processing (NLP): NLP uses computers to process, understand, and utilize human language (such as Chinese and English). NLP is a branch of artificial intelligence and an interdisciplinary field of computer science and linguistics, often referred to as computational linguistics. NLP includes syntactic analysis, semantic analysis, and discourse understanding. It is commonly used in machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, intent recognition, information extraction and filtering, text classification and clustering, sentiment analysis, and opinion mining. It involves data mining, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computation.
[0067] Text clustering refers to grouping semantically similar texts into one class, achieving the effect of maximizing intra-class similarity and minimizing inter-class similarity. Text clustering methods can be used to construct corpora for question-answering assistants. However, because text clustering is an unsupervised machine learning method, meaning it cannot learn from supervised signals, it is prone to poor clustering results in some scenarios. For example, when constructing a corpus for a question-answering assistant in a financial context using text clustering, incorrect clustering of individual data points can easily occur, impacting question-answering operations. For instance, a corpus for insurance consultation might contain data related to insurance claims. Therefore, improving the accuracy of corpus construction using text clustering methods has become a pressing technical problem.
[0068] Based on this, embodiments of this application provide a method, apparatus, device, and storage medium for constructing a problem corpus, aiming to improve the accuracy of problem corpus construction.
[0069] The problem corpus construction method, apparatus, device, and storage medium provided in this application are specifically described through the following embodiments. First, the problem corpus construction method in this application embodiment is described.
[0070] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0071] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0072] The question corpus construction method provided in this application relates to the field of financial technology. This method can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the question corpus construction method, but is not limited to the above forms.
[0073] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0074] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user corpus data, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.
[0075] Figure 1 This is an optional flowchart of the problem corpus construction method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S101 to S106.
[0076] Step S101: Obtain the target question text data;
[0077] Step S102: Perform vector transformation on the target question text data according to the preset target text representation model to obtain the target text vector;
[0078] Step S103: Perform text clustering processing on the target text vector according to the preset target clustering model to obtain target text clusters; wherein, the target text clusters include target text clustering vectors;
[0079] Step S104: Perform pooling processing on the target text cluster vector to obtain the target text center vector of the target text cluster;
[0080] Step S105: Normalize the target text center vector to obtain the target cluster label of the target text cluster; wherein, the target cluster label is used to represent the semantic category of the target text cluster;
[0081] Step S106: Construct a problem corpus based on the target clustering labels and target text clusters.
[0082] Steps S101 to S106 of this embodiment involve vector transformation of the target question text data using a preset target text representation model to obtain target text vectors that accurately represent the semantic features of the target question text data. Then, text clustering processing is performed on the target text vectors using a target clustering model to obtain target text clusters. Therefore, this embodiment avoids the method of directly constructing a corpus through text clustering in related technologies. This embodiment uses target text vectors for text clustering, which improves the accuracy of text clustering. Thus, when target clustering labels are obtained from the target text clustering vectors in the target text clusters, and a question corpus is constructed based on the target clustering labels and target text clusters, the accuracy of constructing the question corpus can be improved. When this application is applied to the construction of a question-and-answer assistant corpus in a financial scenario, the accuracy of the question-and-answer assistant corpus construction can be improved. When intelligent responses are provided based on the above-mentioned question-and-answer assistant, the matching degree between the response corpus and the content of the question asked can be improved.
[0083] In step S101 of some embodiments, multiple target question text data for constructing a question corpus are obtained through relevant Application Programming Interfaces (APIs). It is understood that the text content of the multiple target question text data can be semantically similar or semantically dissimilar. For example, two target question text data with semantically dissimilar text content are obtained; one target question text data contains the text "How is the weather today?", and the other target question text data contains the text "Which type of insurance should I buy?". It is understood that when this application is applied to different application scenarios, the method of obtaining the target question text data can be adaptively changed. For example, when applied to a customer service scenario involving text communication, the target question text data generated by the user on the corresponding terminal through typing, voice input, etc., can be directly obtained according to the API interface. When applied to a voice assistant scenario, the target question voice data obtained is the user's voice inquiry; in this case, the target question text data is obtained by performing voice recognition on the target question voice data. When applied to image recognition scenarios, the target question image data is obtained by the user through relevant methods. At this time, the target question text data is obtained by performing text recognition on the target question image data using methods such as Optical Character Recognition (OCR) and NLP.
[0084] Reference Figure 2 In some embodiments, before step S102, the method provided in this application embodiment further includes the step of training a target text representation model, specifically including but not limited to steps S201 to S206.
[0085] Step S201: Obtain the original text clusters with original cluster labels; wherein, the original cluster labels are used to characterize the semantic category of the original text clusters, and the original text clusters include the original question text data;
[0086] Step S202: Perform vector transformation on the original question text data according to the preset original text representation model to obtain sample text vectors;
[0087] Step S203: Perform text clustering processing on the sample text vectors according to the preset original clustering model to obtain sample text clusters; wherein, the sample text clusters include sample text clustering vectors;
[0088] Step S204: Perform pooling processing on the sample text cluster vectors to obtain the sample text center vectors of the sample text clusters;
[0089] Step S205: Normalize the center vector of the sample text to obtain the sample clustering label of the sample text cluster; wherein, the sample clustering label is used to characterize the semantic category of the sample text cluster.
[0090] Step S206: Adjust the parameters of the original text representation model based on the sample cluster labels and the original cluster labels to obtain the target text representation model.
[0091] In step S201 of some embodiments, multiple original question text data are acquired, and text clustering processing is performed on the multiple original question text data to obtain original text clusters. Clustering labels are then assigned based on the semantics of the text content of the original question text data included in the original text clusters to obtain original cluster labels. For example, multiple original text clusters are combined to obtain a cluster set {(A1,A2,A3)1,(A4,A5)2,...,(A... ... e ,...,A g ) j}. A set of multiple original cluster labels is obtained, resulting in a cluster label set {L}. 1 ,L 2 ,...,L j}.in,(...) j Let A represent the j-th original text cluster, Ag represent the g-th original question text data, and Lj represent the original text cluster (Ae,...,Aj). g ) j The original cluster labels are used to define the data. For example, the following multiple original text data can be clustered into one original text cluster, with the corresponding original cluster labels being "insurance consultation": "I want to learn about the types of insurance and their coverage," "I want to buy an insurance policy that suits me," "I want to learn about the coverage of critical illness insurance," etc. The following multiple original text data can be clustered into another original text cluster, with the corresponding original cluster labels being "insurance claims": "I want to know if my insurance claim complies with the terms and regulations of the insurance contract," "What is the insurance claim process and what materials are required?" "Check the insurance claim progress," etc.
[0092] In step S202 of some embodiments, a raw text representation model based on the transformer model family is pre-set. For example, the raw text representation model can be any of the following models: Bidirectional Encoder Representation from Transformers (BERT), A Robustly Optimized BERT Pretraining Approach (RoBERTa), or a lightweight BERT model (ALite BERT, ALBERT). Taking the transformer model as an example for unified explanation, the transformer model includes an encoder and a decoder. It is understood that the embodiments of this application use the encoder in the transformer model. The raw question text data is used as input data to the raw text representation model. The raw text representation model maps the raw question text data to a semantic space, obtaining a fixed-dimensional sample text vector, which is the semantic feature vector of the raw question text data.
[0093] In step S203 of some embodiments, multiple sample text vectors are clustered according to a preset original clustering model, that is, multiple sample text vectors with similar semantic features are clustered into a sample text cluster. Therefore, the original clustering model can be used to obtain the cluster set {(B1,B4)1,(B3,B7)2,...,(...,B...}. g ) m}.in,(...) m Let B represent the m-th sample text cluster. g Let m represent the sample text vector corresponding to the g-th original question text data. It's understood that the value of m is equal to the value of j. Furthermore, after text clustering, the sample text vectors within the same sample text cluster are used as the sample text cluster vector.
[0094] Reference Figure 3 In some embodiments, step S203 includes, but is not limited to, steps S301 to S304.
[0095] Step S301: Select the center vector of the sample text vector according to the preset number of clusters to obtain the original text center vector;
[0096] Step S302: Perform vector filtering on the sample text vectors based on the original text center vector to obtain candidate text vectors;
[0097] Step S303: Calculate the similarity between the candidate text vector and the original text center vector to obtain the similarity value;
[0098] Step S304: Take the smallest similarity value as the key value, take the original text center vector of the key value as the key text center vector, and obtain the sample text cluster based on the key text center vector and the candidate text vector.
[0099] In step S301 of some embodiments, for the initialized original clustering model, the number of clusters is randomly set in advance, i.e., it is expected that multiple sample text vectors will be clustered into m sample text clusters. Therefore, the center vector of each sample text cluster is selected according to the preset number of clusters to obtain the original text center vector. Specifically, m text vectors are randomly selected from multiple sample text vectors, and the selected m text vectors are used as the original text center vectors.
[0100] In step S302 of some embodiments, the unselected sample text vectors, i.e. the remaining sample text vectors, are used as candidate text vectors.
[0101] In step S303 of some embodiments, the similarity between each candidate text vector and each original text center vector is calculated to obtain the corresponding similarity value. It is understood that since both candidate text vectors and original text vectors are vectors mapped to the semantic space, the similarity can be measured based on the distance between the candidate text vectors and the original text vectors. Specifically, the similarity can be calculated using any of the vector distance calculation methods: Euclidean distance, Manhattan distance, or Chebyshev distance, to obtain the corresponding similarity value.
[0102] In step S304 of some embodiments, the similarity between each candidate text vector and m original text center vectors is calculated to obtain m similarity values. These m similarity values are then compared numerically, and the value with the smallest similarity is taken as the key value. The original text center vector corresponding to this key value is then taken as the key text center vector. In other words, the key text center vector is the text vector among the m original text center vectors that is closest to the candidate text vector. Therefore, the candidate text vector is classified into the cluster containing the key text center vector; that is, clustering is performed on the key text center vector and the candidate text vector to obtain sample text clusters.
[0103] This application embodiment uses distance to perform clustering, so that the distance between text vectors within a cluster is as small as possible, and the distance between text vectors between clusters is as large as possible, thereby enabling sample text vectors with similar semantic features to be classified into a sample text cluster.
[0104] In step S204 of some embodiments, since multiple sample text clustering vectors within the same sample text cluster have similar semantic features, pooling can be performed on the multiple sample text clustering vectors within the same sample text cluster to obtain a sample text center vector that can uniformly represent the semantic features of the sample text cluster.
[0105] In step S205 of some embodiments, the sample text center vector is normalized according to a preset classifier to obtain semantic category data, i.e., sample clustering labels, used to characterize the corresponding sample text clusters. For example, according to the cluster set {(B1,B4)1,(B3,B7)2,...,(...,B...}, ...,B...}, ...,B... g ) m The cluster label set can be obtained. in, This indicates the sample text cluster (..., B) g ) m The sample clustering labels.
[0106] In step S206 of some embodiments, the loss of the sample clustering labels and the original clustering labels is calculated according to a preset loss function to obtain a loss value. The parameters of the original text representation model are adjusted according to the loss value to obtain a target text representation model with more accurate semantic feature extraction capability. Specifically, the loss value G is calculated according to the following formula (1).
[0107]
[0108] Reference Figure 4 In some embodiments, the step of training the target text representation model may include, but is not limited to, steps S401 to S405.
[0109] Step S401: Calculate the clustering accuracy based on the sample clustering labels, original clustering labels, and original question text data to obtain the clustering accuracy value;
[0110] Step S402: Adjust the model parameters of the original clustering model based on the clustering accuracy value to obtain the initial clustering model;
[0111] Step S403: Perform vector transformation on the original question text data according to the preset target text representation model to obtain training text vectors;
[0112] Step S404: Perform text clustering processing on the training text vectors according to the initial clustering model to obtain training sample text clusters;
[0113] Step S405: Train the target text representation model based on the training sample text clusters until the clustering accuracy value equals the preset accuracy threshold.
[0114] In step S401 of some embodiments, the clustering effect of the original clustering model is detected according to a preset clustering evaluation algorithm to obtain the clustering accuracy value. It is understood that the clustering evaluation algorithm includes the Land coefficient, adjusted Land coefficient, silhouette coefficient, Davidson-Bolding index, etc., and this application embodiment does not specifically limit this. However, for ease of explanation, the Land coefficient will be used as an example for specific description below.
[0115] First, the method for calculating the accuracy value of the clustering using the RAND coefficient is explained. Assuming that set U is the pre-defined correct clustering result and set V is the predicted clustering result obtained from the original clustering model, the clustering accuracy value RI is calculated according to the following formula (2).
[0116]
[0117] Where a represents the number of data pairs that belong to the same cluster in set U and also to the same cluster in set V; b represents the number of data pairs that belong to the same cluster in set U but to different clusters in set V; c represents the number of data pairs that belong to different clusters in set U but to the same cluster in set V; and d represents the number of data pairs that belong to different clusters in set U and also to different clusters in set V. In the embodiments of this application, the cluster set {(A1,A2,A3)1,(A... 4, A5)2,...,(A e ,...,A g ) j} is equivalent to set U, and cluster set {(B1,B4)1,(B3,B7)2,...,(...,B g ) m} is equivalent to set V. Therefore, by using the original cluster labels and sample cluster labels, we can determine that the original question text data is located in the cluster set {(A1,A2,A3)1,(A4,A5)2,...,(A...}. e ,...,A g ) j}, Cluster set {(B1,B4)1,(B3,B7)2,...,(...,B g ) m The cluster to which the} belongs is determined, thus obtaining the specific values of a, b, c, and d in equation (2), and then the accurate cluster value is calculated according to equation (2).
[0118] In step S402 of some embodiments, the clustering effect of the original clustering model can be determined based on the clustering accuracy value. Therefore, the parameters of the original clustering model can be adjusted based on the clustering accuracy value to obtain an initial clustering model with stronger clustering ability, so that the clustering effect of the initial clustering model is the desired clustering effect. Specifically, the cluster centers, number of clusters, etc. of the original clustering model can be adjusted, but this embodiment of the application does not specifically limit this.
[0119] Reference Figure 5 In some embodiments, step S402 includes, but is not limited to, steps S501 to S502.
[0120] Step S501: Compare the cluster accuracy value with the preset accuracy threshold to obtain the comparison result;
[0121] Step S502: If the comparison result indicates that the clustering accuracy value is less than the preset accuracy threshold, then the center vector of the sample text is used as the center vector of the original clustering model to obtain the initial clustering model.
[0122] In step S501 of some embodiments, a preset accuracy threshold is set in advance according to the desired clustering effect, and the clustering accuracy value is compared with the preset accuracy threshold to obtain the corresponding comparison result.
[0123] In step S502 of some embodiments, if the comparison result indicates that the clustering accuracy value is less than a preset accuracy threshold, it means that the clustering effect of the current original clustering model has not achieved the expected clustering effect. Therefore, it is necessary to adjust the parameters of the original clustering model to improve its clustering effect. Specifically, the center vector of the sample text is used as the center vector of the original clustering model, that is, as the cluster center of the original clustering model, to obtain an initial clustering model, so that the original question text data is clustered according to the new cluster centers.
[0124] Understandably, when the target text representation model needs to be trained multiple times, the sample center vector obtained from the previous training is used as the center vector of the initial clustering model in the current training. Through continuous training, the clustering effect of the initial clustering model is made to achieve the desired clustering effect. Thus, when the target text representation model is trained based on the training text clusters obtained from the initial clustering model, text vectors that can achieve the desired clustering effect are obtained, ultimately improving the accuracy of the problem corpus construction.
[0125] In step S403 of some embodiments, a target text representation model based on the transformer model family is pre-set. The original question text data is used as input data to the target text representation model. The target text representation model maps the original question text data into the semantic space to obtain a fixed-dimensional training text vector, which is the semantic feature vector of the original question text data.
[0126] In step S404 of some embodiments, multiple training text vectors are subjected to text clustering processing according to the adjusted initial clustering model, that is, multiple training text vectors with similar semantic features are clustered into a training sample text cluster.
[0127] In step S405 of some embodiments, after text clustering, the training text vectors within the same training sample text cluster are used as training text cluster vectors, i.e., the training sample text cluster includes training text cluster vectors. By performing pooling and normalization on the training text cluster vectors, new sample cluster labels are obtained for the training text cluster. The parameters of the target text representation model are adjusted according to these new sample cluster labels, and the methods described in steps S301 to S305 are executed again based on the adjusted target text representation model and the new sample cluster labels until the target text representation model converges. It is understood that the convergence condition of the target text representation model can be set according to actual needs. For example, training of the target text representation model can be stopped when the number of adjustments to the parameters of the original clustering model reaches a preset number; or, training of the target text representation model can be stopped when the clustering accuracy value calculated based on the current target text representation model is greater than a preset accuracy value. This application embodiment does not specifically limit this aspect.
[0128] It is understood that in this embodiment, the target text representation model is trained based on the training sample text clusters generated by the initial clustering model. That is, the target text representation model is trained according to the desired clustering effect, enabling the trained target text representation model to generate more accurate text vectors. These text vectors, in turn, allow the target clustering model to achieve the desired clustering effect. Specifically, the target text representation model can perform vector transformation based on the desired clustering effect, ensuring that text vectors within clusters are semantically close and that text vectors between clusters are semantically far apart. For example, given target question text data C, D, E, and F, when the desired clustering effect is to cluster target question text data C and D into one cluster, and target question text data E and F into another cluster, the trained target text representation model can perform semantic feature mining on target question text data C and D according to the desired clustering effect. This ensures that the target text vectors of target question text data C and D are semantically similar, and that the target text vectors of both target question text data C and D are semantically distant from the target text vector of target question text data E. Similarly, the target text representation model also performs semantic feature mining on target question text data E and target question text data F. Therefore, the embodiments of this application can improve the accuracy of constructing a question corpus based on a target clustering model.
[0129] In step S102 of some implementations, a target text representation model trained based on a series of transformer models is pre-set. The target question text data is used as input data to the target text representation model. The target text representation model maps the target question text data into a semantic space, obtaining a fixed-dimensional target text vector, which is the semantic feature vector of the target question text data. It can be understood that since the target text representation model is a pre-trained model, it can accurately represent the semantic features of the target text data. Therefore, when the subsequent target text clustering model performs text clustering processing based on the target text vector, it can improve the accuracy of text clustering processing. When this application is applied to insurance scenarios in fintech, the target question text data is insurance-related question text data, such as question text data related to insurance consultation, insurance claims, or premium payment.
[0130] Reference Figure 6 In some embodiments, the target text representation model includes an encoding layer and a vector representation layer, and step S102 includes, but is not limited to, steps S601 to S602.
[0131] Step S601: Perform vector transformation on the target question text data according to the encoding layer to obtain the initial text vector;
[0132] Step S602: Perform semantic fusion processing on the initial text vector according to the vector representation layer to obtain the target text vector.
[0133] In step S601 of some embodiments, the target question text data is divided into characters or words by the encoding layer, and the divided characters or words are transformed into vectors to convert the target question text data into multiple word vectors, that is, to obtain multiple initial text vectors.
[0134] In step S602 of some embodiments, the vector representation layer is used to perform semantic fusion processing on multiple initial text vectors according to the attention mechanism, that is, to perform semantic fusion processing on multiple initial text vectors according to the semantic information of the full text content of the target question text data, so as to obtain a target text vector that can represent the important semantic features of the target question text data.
[0135] In step S103 of some embodiments, target text vectors are clustered using a preset target clustering model to group multiple target problem text data with similar semantic feature vectors into a single target text cluster. It is understood that the target clustering model clusters target text vectors based on any of the following methods: partitioning clustering methods, density-based clustering methods, hierarchical clustering methods, etc. Partitioning clustering methods include the K-means clustering algorithm (K-means), and its variants such as K-means++ and bi-Kmeans; density-based clustering methods include Density-Based Spatial Clustering of Applications with Noise (DBSCAN) and Ordering Points to Identify the Clustering Structure (OPTICS); hierarchical clustering methods include agglomerative hierarchical clustering (AGNES) and divisive hierarchical clustering.
[0136] It is understood that, for ease of explanation, the K-means algorithm is used as an example in this application embodiment. According to the K-means algorithm, multiple target text vectors can be divided into K target text clusters, where the specific value of K is determined based on the pre-defined target clustering model. For example, multiple target text clusters are set together to obtain a cluster set {(S1,S2,S3)1,(S4,S5)2,...,(S...}. i ,...,S n ) k}.in,(...) k S represents the Kth target text cluster. i This represents the vector representation of the i-th target question text data in high-dimensional space, i.e., the target text vector. Furthermore, after text clustering, the target text vectors within the same target text cluster are used as the target text cluster vectors.
[0137] In step S104 of some embodiments, since multiple target text clustering vectors within the same target text cluster have similar semantic features, pooling can be performed on the multiple target text clustering vectors within the same target text cluster to obtain a target text center vector that can uniformly represent the semantic features of the target text cluster.
[0138] In step S105 of some embodiments, the target text center vector is normalized according to a preset classifier to obtain semantic category data, i.e., target clustering labels, used to characterize the corresponding target text clusters. For example, the corresponding {(S1,S2,S3)1,(S4,S5)2,...,(S i ,...,S n ) k} target clustering label {y 1 ,y 2 ,...,y k}
[0139] y k =softmax(W·C k Equation (3)
[0140] Among them, C k This indicates that based on the Kth target text cluster (...) k The calculated target text center vector, where W represents the preset linear transformation matrix.
[0141] Understandably, since target text vectors with similar semantic features have been clustered into a single target text cluster, the label content corresponding to the target clustering label for each target text cluster should be different. For example, target clustering labels could include logistics queries, insurance inquiries, insurance claims, discount information queries, and ticket information queries.
[0142] In step S106 of some embodiments, a mapping relationship is established between the target clustering label and the corresponding target text cluster, thereby constructing a problem corpus.
[0143] The question corpus construction method provided in this application embodiment performs vector transformation on target question text data through a preset target text representation model to obtain target text vectors that can accurately represent the semantic features of the target question text data. Then, it performs text clustering processing on the target text vectors through a target clustering model to obtain target text clusters. Therefore, this application embodiment avoids the method of directly constructing a corpus through text clustering in related technologies. This application embodiment performs text clustering processing through target text vectors, which can improve the accuracy of text clustering processing. Therefore, when target clustering labels are obtained from the target text clustering vectors in the target text clusters, and the question corpus is constructed based on the clustering labels and target text clusters, the accuracy of corpus construction can be improved.
[0144] Reference Figure 7 This application also provides a question-and-answer method, which includes, but is not limited to, steps S701 to S705.
[0145] Step S701: Obtain the text data to be answered;
[0146] Step S702: Perform semantic matching between the text data to be answered and the target text cluster in the preset question corpus to obtain the matching result; wherein, the preset question corpus is constructed according to the question corpus construction method;
[0147] Step S703: Take the target text cluster representing the semantic matching of the matching results as the key text cluster;
[0148] Step S704: Select key answer text clusters from preset original answer text clusters based on key text clusters;
[0149] Step S705: Perform response processing based on the key answer text cluster to obtain the answer text data of the text data to be answered.
[0150] In step S701 of some embodiments, the text data to be answered is obtained through a relevant API interface. It is understood that the method of obtaining the text data to be answered can be adaptively modified when this application is applied to different application scenarios. For example, when applied to a customer service scenario involving text communication, the text data to be answered generated by the user on the corresponding terminal through typing, voice input, etc., can be directly obtained through the API interface. When applied to a voice assistant scenario, the obtained data is the voice data to be answered from the user's voice inquiry; in this case, the text data to be answered is obtained by performing speech recognition on the voice data to be answered. When applied to an image recognition scenario, the obtained data is the image data to be answered uploaded by the user through relevant methods; in this case, the text data to be answered is obtained by performing text recognition on the image data to be answered using OCR, NLP, etc. When this application is applied to an insurance scenario in fintech, the text data to be answered can be text data related to insurance questions, such as text data related to insurance consultation, insurance claims, premium payment, etc. It can also be text data related to questions unrelated to insurance. It is understandable that when the text data to be answered is a question text data that is unrelated to insurance, since there is no corresponding target text cluster in the preset question corpus, the result may be "Unable to solve, please ask questions related to insurance".
[0151] In step S702 of some embodiments, the text data to be answered is semantically matched with the target text clusters obtained according to the question corpus construction method described in any of the above embodiments to determine the semantic category of the text data to be answered. For example, determining which semantic category the text data to be answered belongs to: insurance consultation, insurance claim, or insurance service complaint. Specifically, since the question corpus includes target cluster labels and target text clusters mapped to the target cluster labels, and the target text clusters include target text cluster vectors, the text data to be answered can be input into the target text representation model for vector transformation to obtain the text vector to be answered. The text vector to be answered is semantically matched with the target text cluster vectors to determine which target text cluster the text vector to be answered belongs to, i.e., obtaining the matching result. Alternatively, when the target cluster labels are labels with dissimilar semantic categories, the text vector to be answered can be semantically matched with the target cluster labels to obtain the matching result. It is understood that dissimilar semantic categories mean that the semantic categories can be clearly distinguished; for example, "insurance consultation" and "insurance claim" are target cluster labels with dissimilar semantic categories. Conversely, semantic similarity refers to semantic categories that cannot be clearly distinguished. For example, "insurance query" and "insurance type query" are target cluster labels with similar semantic categories.
[0152] In step S703 of some embodiments, the target text cluster to which the text data to be answered belongs is determined based on the matching result, and the target text cluster to which the text data to be answered in the question corpus belongs is taken as the key text cluster.
[0153] In steps S704 to S705 of some embodiments, an original answer text cluster mapped to each target text cluster is pre-set. Therefore, the original answer text cluster mapped to the key text cluster is used as the key answer text cluster. Response processing is performed based on the key answer text cluster to obtain the answer text data of the text data to be answered. It is understood that the original answer text cluster may or may not be stored in the question corpus. When the question corpus includes the original answer text cluster, the original answer text cluster may be set based on the target text cluster and target clustering labels after the question corpus is constructed according to the question corpus construction method. Alternatively, the original answer text cluster is constructed in the question corpus construction method; in this case, the data obtained for training the target text representation model should also include the original answer text data corresponding to the original question text data, and the original answer text cluster is obtained based on the original answer text data.
[0154] Furthermore, a solution strategy can be pre-set that maps to each target cluster label in the question corpus. The corresponding solution strategy is then invoked based on the target cluster label of the key text cluster, thereby enabling the processing of responses to the text data to be answered. This application does not specifically limit the embodiments in this regard.
[0155] This application embodiment uses the question corpus described in the above embodiments for response processing. Since the question corpus constructed according to the above embodiments has high accuracy, this application embodiment can improve the accuracy of response processing.
[0156] Please see Figure 8 This application also provides a question-and-answer corpus construction apparatus, which can implement the above-described question-and-answer corpus construction method. The apparatus includes:
[0157] Data acquisition module 801 is used to acquire target question text data;
[0158] The vector conversion module 802 is used to perform vector conversion on the target problem text data according to the preset target text representation model to obtain the target text vector;
[0159] The text clustering module 803 is used to perform text clustering processing on the target text vector according to the preset target clustering model to obtain the target text cluster; wherein, the target text cluster includes the target text clustering vector;
[0160] Pooling module 804 is used to pool the target text cluster vector to obtain the target text center vector of the target text cluster;
[0161] The normalization module 805 is used to normalize the target text center vector to obtain the target cluster label of the target text cluster; wherein, the target cluster label is used to represent the semantic category of the target text cluster.
[0162] Corpus building module 806 is used to build a question corpus based on target clustering labels and target text clusters.
[0163] The specific implementation of this question-and-answer corpus construction device is basically the same as the specific implementation of the question-and-answer corpus construction method described above, and will not be repeated here.
[0164] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described question-and-answer corpus construction method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0165] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:
[0166] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0167] The memory 902 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the question-and-answer corpus construction method of the embodiments of this application.
[0168] The input / output interface 903 is used to implement information input and output;
[0169] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0170] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);
[0171] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0172] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described question-and-answer corpus construction method.
[0173] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0174] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0175] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0176] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0177] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0178] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0179] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0181] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0182] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0183] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0184] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method of constructing a corpus of questions, characterized in that, The method comprises: acquiring target question text data; vector converting the target question text data according to a preset target text representation model to obtain a target text vector; performing text clustering processing on the target text vector according to a preset target clustering model to obtain a target text cluster; wherein the target text cluster comprises a target text clustering vector; performing pooling processing on the target text clustering vector to obtain a target text center vector of the target text cluster; performing normalization processing on the target text center vector according to a preset classifier to obtain a target clustering label of the target text cluster; wherein the target clustering label is used to represent a semantic category of the target text cluster; constructing a question corpus according to the target clustering label and the target text cluster; wherein, before the vector converting the target question text data according to the preset target text representation model, the target text representation model is trained, specifically comprising: acquiring an original text cluster labeled with an original clustering label; wherein the original clustering label is used to represent a semantic category of the original text cluster, and the original text cluster comprises original question text data; vector converting the original question text data according to a preset original text representation model to obtain a sample text vector; performing text clustering processing on the sample text vector according to a preset original clustering model to obtain a sample text cluster; wherein the sample text cluster comprises a sample text clustering vector; performing pooling processing on the sample text clustering vector to obtain a sample text center vector of the sample text cluster; performing normalization processing on the sample text center vector to obtain a sample clustering label of the sample text cluster; performing loss calculation according to the sample clustering label and the original clustering label, and adjusting parameters of the original text representation model based on the calculated loss value to obtain the target text representation model; performing clustering accuracy calculation according to the sample clustering label, the original clustering label and the original question text data to obtain a clustering accuracy value; if the clustering accuracy value is less than a preset accuracy threshold, taking the sample text center vector of the sample text cluster as a center vector of the original clustering model to obtain an initial clustering model; vector converting the original question text data according to the target text representation model to obtain a training text vector; performing text clustering processing on the training text vector according to the initial clustering model to obtain a training sample text cluster; wherein the training sample text cluster comprises a training text clustering vector, and a new sample clustering label of a training text cluster is obtained by performing pooling processing and normalization processing on the training text clustering vector; adjusting parameters of the target text representation model according to the new sample clustering label until the clustering accuracy value calculated according to the current target text representation model is greater than the preset accuracy threshold to stop training the target text representation model; When the target text representation model is trained, the sample text center vector obtained by the last training is used as the center vector of the initial clustering model in the current training to obtain an adjusted initial clustering model.
2. The method of claim 1, wherein, The text clustering processing of the sample text vector according to the preset original clustering model comprises: center vector selection of the sample text vector according to a preset cluster number to obtain an original text center vector; vector screening of the sample text vector according to the original text center vector to obtain a candidate text vector; similarity calculation of the candidate text vector and the original text center vector to obtain a similarity value; the sample text cluster is obtained according to the key text center vector and the candidate text vector.
3. The method according to any one of claims 1 to 2, characterized in that, The target text representation model comprises an encoding layer and a vector representation layer. The vector conversion of the target problem text data according to the preset target text representation model comprises: vector conversion of the target problem text data according to the encoding layer to obtain an initial text vector; semantic fusion processing of the initial text vector according to the vector representation layer to obtain the target text vector.
4. A question and answer method characterized by, The method comprises: obtaining to-be-answered text data; performing semantic matching of the to-be-answered text data and a target text cluster in a preset question corpus to obtain a matching result; wherein the preset question corpus is obtained by the method according to any one of claims 1 to 3; taking the target text cluster in the semantic matching result as a key text cluster; screening a key answer text cluster from a preset original answer text cluster according to the key text cluster; performing reply processing according to the key answer text cluster to obtain answer text data of the to-be-answered text data.
5. A question corpus construction apparatus characterized by comprising: The device comprises: a data acquisition module configured to obtain target problem text data; a vector conversion module configured to perform vector conversion of the target problem text data according to a preset target text representation model to obtain a target text vector; a text clustering module configured to perform text clustering processing of the target text vector according to a preset target clustering model to obtain a target text cluster; wherein the target text cluster comprises a target text clustering vector; a pooling module configured to perform pooling processing of the target text clustering vector to obtain a target text center vector of the target text cluster; a normalization module configured to perform normalization processing of the target text center vector according to a preset classifier to obtain a target clustering label of the target text cluster; wherein the target clustering label is used to represent a semantic category of the target text cluster; a corpus construction module configured to construct a question corpus according to the target clustering label and the target text cluster. Before the vector conversion of the target problem text data according to the preset target text representation model, the target text representation model is trained, and the training specifically comprises: obtain an original text cluster marked with an original clustering label, wherein the original clustering label is used to represent a semantic category of the original text cluster, and the original text cluster comprises original question text data; perform vector conversion on the original question text data according to a preset original text representation model to obtain a sample text vector; perform text clustering processing on the sample text vector according to a preset original clustering model to obtain a sample text cluster, wherein the sample text cluster comprises a sample text clustering vector; obtain a sample text center vector of the sample text cluster through pooling processing; obtain a sample clustering label of the sample text cluster through normalization processing; perform loss calculation according to the sample clustering label and the original clustering label, and perform parameter adjustment on the original text representation model based on the calculated loss value to obtain a target text representation model; perform clustering accuracy calculation according to the sample clustering label, the original clustering label, and the original question text data to obtain a clustering accuracy value; if the clustering accuracy value is less than a preset accuracy threshold, use the sample text center vector of the sample text cluster as a center vector of the original clustering model to obtain an initial clustering model; perform vector conversion on the original question text data according to the target text representation model to obtain a training text vector; perform text clustering processing on the training text vector according to the initial clustering model to obtain a training sample text cluster, wherein the training sample text cluster comprises a training text clustering vector, and a new sample clustering label of a training text cluster is obtained through pooling processing and normalization processing on the training text clustering vector; perform parameter adjustment on the target text representation model according to the new sample clustering label until the clustering accuracy value calculated according to the current target text representation model is greater than the preset accuracy threshold, and then stop training the target text representation model; when training the target text representation model, use the sample text center vector obtained in the last training as the center vector of the initial clustering model in the current training to obtain an adjusted initial clustering model.
6. An electronic device, comprising: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of any one of claims 1 to 3 or the method of claim 4 when executing the computer program.
7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: The computer program is executed by the processor to implement the method of any one of claims 1 to 3 or the method of claim 4.
Citation Information
Patent Citations
Text processing method and device, electronic equipment and storage medium
CN114064894A
Text clustering method, text clustering device, electronic equipment and storage medium
CN116127066A