Text clustering method, text clustering device, electronic device, and storage medium
By using text clustering methods to extract features and cluster user questions, initial cluster centers are selected, inter-cluster divergence and intra-cluster divergence are calculated, and semantic analysis is performed. This solves the problem that intelligent robots cannot answer accurately, and improves the accuracy of question answers and the efficiency of text classification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, intelligent robots cannot accurately answer questions posed by users in different ways, resulting in low accuracy rates.
By using text clustering methods, the original question text is obtained, features are extracted and clustered, initial cluster centers are selected, inter-cluster divergence and intra-cluster divergence are calculated, text classes are adjusted, semantic analysis is performed, and standard question text and response content are determined.
It improved the accuracy of question answers, reduced manual workload, increased the efficiency and accuracy of text classification, and built an efficient question-and-answer knowledge base.
Smart Images

Figure CN116127066B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a text clustering method, a text clustering device, an electronic device and a storage medium. BACKGROUND
[0002] In the related art, an intelligent robot answers a question raised by a user, but the same question can have different ways of asking. When the question raised by the user is different from a standard question stored by the intelligent robot, the intelligent robot cannot accurately answer the question. Therefore, how to improve the accuracy of question answering has become a problem to be solved. SUMMARY
[0003] The main purpose of the embodiments of the present application is to provide a text clustering method, a text clustering device, an electronic device and a storage medium, which aims to improve the accuracy of question answering.
[0004] To achieve the above-mentioned purpose, a first aspect of the embodiments of the present application provides a text clustering method, which comprises:
[0005] obtaining a plurality of original question texts;
[0006] extracting features of each original question text to obtain an original sentence embedding vector of each original question text;
[0007] selecting an initial clustering center from a plurality of original sentence embedding vectors, and constructing an initial question text class corresponding to each initial clustering center based on the initial clustering center, wherein each initial question text class contains one initial clustering center;
[0008] performing clustering processing on all original sentence embedding vectors based on the initial clustering center to obtain a plurality of intermediate question text classes;
[0009] identifying a clustering center for each intermediate question text class to obtain a text clustering center of each intermediate question text class;
[0010] calculating an inter-class scatter and an intra-class scatter of each intermediate question text class according to the text clustering center;
[0011] adjusting the intermediate question text classes according to the inter-class scatter and the intra-class scatter to obtain a target question text class;
[0012] perform semantic analysis on all original sentence embedding vectors of the target question text class to obtain a standard question text of each target question text class, and determine standard reply content of the target question text class according to the standard question text; wherein the standard question text and the original question text are used for question matching with a user question text, and the standard reply content is used for reply generation of the user question text.
[0013] In some embodiments, the clustering processing based on the initial clustering centers on all the original sentence embedding vectors obtains a plurality of intermediate question text classes, including:
[0014] The distance value between each original sentence embedding vector and all the initial clustering centers is calculated.
[0015] Each original sentence embedding vector is divided into an initial question text class corresponding to an initial clustering center with the minimum distance value, to obtain a plurality of intermediate question text classes; wherein each intermediate question text class includes at least one original sentence embedding vector.
[0016] In some embodiments, the clustering center identification of each intermediate question text class obtains a text clustering center of each intermediate question text class, including:
[0017] According to the original sentence embedding vector, a sentence mean vector of each intermediate question text class is obtained.
[0018] According to the sentence mean vector, a text clustering center of the intermediate question text class is determined.
[0019] In some embodiments, the text adjustment of the intermediate question text class according to the inter-class divergence and the intra-class divergence obtains a target question text class, including:
[0020] According to the inter-class divergence and the intra-class divergence, a clustering loss value is determined.
[0021] According to a preset iteration number and the clustering loss value, the text adjustment of the intermediate question text class obtains the target question text class.
[0022] In some embodiments, the semantic analysis on all original sentence embedding vectors of the target question text class obtains a standard question text of each target question text class, and the standard reply content of the target question text class is determined according to the standard question text, including:
[0023] Perform semantic analysis on all the original sentence embedding vectors to obtain a question keyword.
[0024] According to the problem keyword, a preset standard question and answer library is traversed to obtain a standard question text;
[0025] A reply text corresponding to the standard question text is extracted from the standard question and answer library as standard reply content.
[0026] In some embodiments, after the standard reply content of the target question text class is determined according to the standard question text, the text clustering method further includes:
[0027] Obtaining a user question text;
[0028] Converting the user question text into a question sentence embedding feature;
[0029] Inputting the question sentence embedding feature into a preset question and answer knowledge base to generate an answer, to obtain a target reply text; wherein the question and answer knowledge base includes a plurality of target question text classes, each target question text class includes a plurality of original question texts, a standard question text and a standard reply content.
[0030] In some embodiments, inputting the question sentence embedding feature into the preset question and answer knowledge base to generate an answer to obtain a target reply text includes:
[0031] Calculating the similarity between the question sentence embedding feature and all original question texts of the question and answer knowledge base to obtain a highest-similarity original question text, and determining a target question text class in which the highest-similarity original question text is located;
[0032] Extracting the standard reply content of the target question text class in which the highest-similarity original question text is located as the target reply text.
[0033] To achieve the above object, a second aspect of the embodiment of the present application proposes a text clustering device, which comprises:
[0034] An obtaining module is configured to obtain a plurality of original question texts;
[0035] A feature extraction module is configured to extract features of each original question text to obtain an original sentence embedding vector of each original question text;
[0036] A text class construction module is configured to select an initial clustering center from a plurality of original sentence embedding vectors, and construct an initial question text class corresponding to each initial clustering center based on the initial clustering center, each initial question text class containing one initial clustering center.
[0037] a clustering module, configured to perform clustering processing on all the original sentence embedding vectors based on the initial clustering centers, to obtain a plurality of intermediate problem text classes;
[0038] a clustering center identification module, configured to identify a clustering center for each of the intermediate problem text classes, to obtain a text clustering center of each of the intermediate problem text classes;
[0039] a calculation module, configured to calculate inter-class scatters between the intermediate problem text classes and intra-class scatters of each of the intermediate problem text classes according to the text clustering centers;
[0040] a text adjustment module, configured to perform text adjustment on the intermediate problem text classes according to the inter-class scatters and the intra-class scatters, to obtain target problem text classes;
[0041] a semantic analysis module, configured to perform semantic analysis on all original sentence embedding vectors of the target problem text classes, to obtain standard problem texts of each of the target problem text classes, and determine standard reply contents of the target problem text classes according to the standard problem texts; wherein the standard problem texts and the original problem texts are used for question matching with user problem texts, and the standard reply contents are used for reply generation on the user problem texts.
[0042] To achieve the above object, a third aspect of embodiments of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.
[0043] To achieve the above object, a fourth aspect of embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.
[0044] The text clustering method, the text clustering device, the electronic equipment and the computer readable storage medium provided by the application obtain a plurality of original question texts, perform feature extraction on each original question text, obtain an original sentence embedding vector of each original question text, select an initial clustering center from the plurality of original sentence embedding vectors, and construct an initial question text class corresponding to each initial clustering center based on the initial clustering center, wherein each initial question text class contains an initial clustering center, perform clustering processing on all original sentence embedding vectors based on the initial clustering center, obtain a plurality of intermediate question text classes, and through the clustering processing, the plurality of similar question texts of the user can be clustered into the same question text class, so that the plurality of similar questions have the same standard question, thereby improving the accuracy of question answering. Further, the clustering center of each intermediate question text class is identified to obtain a text clustering center of each intermediate question text class, the inter-class dispersion between the intermediate question text classes and the intra-class dispersion of each intermediate question text class are calculated according to the text clustering center, the intermediate question text classes are adjusted according to the inter-class dispersion and the intra-class dispersion to obtain a target question text class, the text difference between different intermediate question text classes is increased and the text difference within the same intermediate question text class is reduced through the inter-class dispersion and the intra-class dispersion, and the accuracy of text clustering can be improved. Finally, semantic analysis is performed on all original sentence embedding vectors of the target question text class to obtain a standard question text of each target question text class, so that the plurality of similar questions in the target question text class have the same standard question text, and the standard reply content of the target question text class is determined according to the standard question text, wherein the standard question text and the original question text are used for question matching with the user question text, the standard reply content is used for reply generation for the user question text, the standard reply content of the similar question can be obtained, and the accuracy of question answering is improved. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 is a flowchart of the text clustering method provided by the embodiment of the application;
[0046] Figure 2 is Figure 1 is a flowchart of step S140 in
[0047] Figure 3 is Figure 1 is a flowchart of step S150 in
[0048] Figure 4 is Figure 1 is a flowchart of step S170 in
[0049] Figure 5 is Figure 1 is a flowchart of step S180 in
[0050] Figure 6 is another flowchart of the text clustering method provided by the embodiment of the present application;
[0051] Figure 7 is Figure 6 is a flowchart of step S630 in
[0052] Figure 8 is a structural schematic diagram of the text clustering apparatus provided by the embodiment of the present application;
[0053] Figure 9 is a hardware structural schematic diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the objects, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0055] It should be noted that although the functional modules are divided in the apparatus schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a manner different from the module division in the apparatus or the order in the flowchart. The terms "first", "second", and the like in the specification and claims and the above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0056] 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 the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
[0057] First, the several terms involved in the present application are analyzed:
[0058] Artificial intelligence (AI): is a new technical science of researching, developing, simulating, extending and expanding human intelligence, and is a branch of computer science. Artificial intelligence attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. The research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. Artificial intelligence can simulate the information process of human consciousness and thinking. Artificial intelligence is also the theory, method, technology and application system of using digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, to perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0059] In the related art, an intelligent robot answers a question raised by a user, but the same question can have different ways of asking, and the intelligent robot cannot accurately answer the question when the question raised by the user is different from a standard question stored by the intelligent robot. Therefore, how to improve the accuracy of question answering has become a problem to be solved.
[0060] Based on this, the embodiment of the application provides a text clustering method, a text clustering device, an electronic device and a storage medium, aiming to improve the accuracy of question answering.
[0061] The text clustering method, the text clustering device, the electronic device and the computer readable storage medium provided by the embodiment of the application are specifically explained by the following embodiment, first, the text clustering method in the embodiment of the application is described.
[0062] The embodiment of the application can acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (Artificial Intelligence, AI) is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results. Theory, method, technology and application system.
[0063] The basic technology of artificial intelligence generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, robot technology, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning, etc. Several major directions.
[0064] The text clustering method provided by the embodiment of the application relates to the field of artificial intelligence technology. The text clustering method provided by the embodiment of the application can be applied in a terminal, can also be applied in a server end, and can also be software running in a terminal or a server end. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server end can be configured as an independent physical server, can also be configured as a server cluster or a distributed system composed of multiple physical servers, can also be configured as a cloud server providing cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN and basic cloud computing services such as big data and artificial intelligence platform; the software can be an application that implements the text clustering method, etc., but is not limited to the above forms.
[0065] The application is operable in a multitude of generic or specific computer system environments or configurations. Examples of well known computing systems, environments, and / or configurations that can be suitable for use with the application include personal computers, server computers, handheld or laptop devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like, that perform particular tasks or implement particular abstract data types. The application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media including memory storage devices.
[0066] It should be noted that in each of the specific embodiments of the present application, when it is necessary to process relevant data related to the identity or characteristics of the user according to user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards of the country and region. In addition, when the embodiments of the present application need to obtain sensitive personal information of the user, the separate permission or separate consent of the user will be obtained through a pop-up window or a jump to a confirmation page, and after obtaining the separate permission or separate consent of the user, the necessary user-related data for enabling the embodiments of the present application to normally operate will be obtained.
[0067] Figure 1 is an optional flowchart of the text clustering method provided by the embodiments of the present application, Figure 1 The method in the above step S100 can include but is not limited to steps S110 to S180.
[0068] Step S110, obtaining a plurality of original question texts;
[0069] Step S120, performing feature extraction on each original question text to obtain an original sentence embedding vector of each original question text;
[0070] Step S130, screening an initial clustering center from the plurality of original sentence embedding vectors, and constructing an initial question text class corresponding to each initial clustering center based on the initial clustering center; wherein each initial question text class contains an initial clustering center.
[0071] Step S140, performing clustering processing on all original sentence embedding vectors based on the initial clustering center to obtain a plurality of intermediate question text classes.
[0072] Step S150, for each intermediate question text class, a cluster center is identified to obtain a text cluster center of each intermediate question text class;
[0073] Step S160, according to the text cluster center, inter-class dispersion between the intermediate question text classes and intra-class dispersion of each intermediate question text class are calculated;
[0074] Step S170, according to the inter-class dispersion and the intra-class dispersion, the intermediate question text classes are adjusted to obtain target question text classes;
[0075] Step S180, for all original sentence embedding vectors of the target question text classes, semantic analysis is performed to obtain standard question texts of each target question text class, and according to the standard question texts, standard reply contents of the target question text classes are determined; wherein, the standard question texts and the original question texts are used for question matching with user question texts, and the standard reply contents are used for reply generation for the user question texts.
[0076] The steps S110 to S180 shown in the embodiments of the present application are as follows: a plurality of original question texts are obtained, feature extraction is performed on each original question text to obtain an original sentence embedding vector of each original question text, an initial clustering center is selected from a plurality of original sentence embedding vectors, and an initial question text class corresponding to each initial clustering center is constructed based on the initial clustering center, wherein each initial question text class contains an initial clustering center, clustering processing is performed on all original sentence embedding vectors based on the initial clustering center, a plurality of intermediate question text classes are obtained, and through clustering processing, a plurality of similar question texts of a user can be clustered into the same question text class, so that the plurality of similar questions have the same standard question, compared with the way of manually combing the standard question and the similar question, the original question text can be quickly classified, the artificial workload is reduced, and the efficiency and accuracy of text classification are improved. Further, a clustering center of each intermediate question text class is identified to obtain a text clustering center of each intermediate question text class, the inter-class scatter and the intra-class scatter of the intermediate question text classes are calculated according to the text clustering center, the intermediate question text classes are adjusted according to the inter-class scatter and the intra-class scatter, and a target question text class is obtained. Through the inter-class scatter and the intra-class scatter, the text difference between different intermediate question text classes is increased, and the text difference within the same intermediate question text class is reduced, so that the accuracy of text clustering can be improved. Finally, semantic analysis is performed on all original sentence embedding vectors of the target question text class to obtain a standard question text of each target question text class, so that the plurality of similar questions in the target question text class have the same standard question text, and the standard reply content of the target question text class is determined according to the standard question text, wherein the standard question text and the original question text are used for question matching with the user question text, and the standard reply content is used for reply generation for the user question text, so that the standard reply content of the similar question can be obtained, and the accuracy of question answering is improved.
[0077] In step S110 of some embodiments, a plurality of original question texts are obtained from a preset data source, wherein the data source can be a database or a data set storing a plurality of question texts, and the original question text is question text data without a question category label. Specifically, the plurality of original question texts are obtained from a database or a data set storing a plurality of question texts, or the plurality of original question voices are obtained from a database or a data set storing a plurality of question voices, and then the original question voices are subjected to text conversion processing to obtain the original question texts.
[0078] In step S120 of some embodiments, text feature extraction is performed on each original question text by a BERT model to obtain an original sentence embedding vector of each original question text, where the original sentence embedding vector is a text feature expression of the original question text. For example, the original question text is "A business has what fees", and the BERT interface is called to perform text feature extraction on the original question text to obtain a 1*256-dimensional vector [0.05, 0.37, 0.89, L, 0.56], which is the original sentence embedding vector of the original question text.
[0079] In step S130 of some embodiments, a value range of the number of cluster centers K is obtained, K e [p, q], where p and q are both integers greater than 0, the initial value of the number of cluster centers K is determined as p according to the value range, p initial cluster centers are randomly selected from the plurality of original sentence embedding vectors, and an initial question text class corresponding to each initial cluster center is constructed based on the initial cluster center. For example, the initial question text class of the first initial cluster center is the first question text class, the initial question text class of the second initial cluster center is the second question text class, and the initial question text class of the qth initial cluster center is the qth question text class. Each initial question text class contains an initial cluster center.
[0080] Please refer to Figure 2 In some embodiments, step S140 can include but is not limited to steps S210 to S220:
[0081] Step S210, calculating the distance value between each original sentence embedding vector and all initial cluster centers;
[0082] Step S220, dividing each original sentence embedding vector into an initial question text class corresponding to the initial cluster center with the smallest distance value to obtain a plurality of intermediate question text classes; each intermediate question text class includes at least one original sentence embedding vector.
[0083] In step S210 of some embodiments, the distance value between each original sentence embedding vector and all initial cluster centers is calculated, where the distance value is used to measure the similarity between the original sentence embedding vector and the initial cluster center. The distance value can be Euclidean distance, Manhattan distance, etc. Taking Euclidean distance as an example, the smaller the Euclidean distance value between the original sentence embedding vector and the initial cluster center, the higher the similarity between the original sentence embedding vector and the initial cluster center; the larger the Euclidean distance value between the original sentence embedding vector and the initial cluster center, the greater the difference between the original sentence embedding vector and the initial cluster center, and the smaller the similarity between them.
[0084] In step S220 of some embodiments, each original sentence embedding vector is divided into the initial problem text class corresponding to the initial cluster center with the minimum distance value, i.e., each original distance embedding vector is divided into the initial problem text class to which the initial cluster center with the highest similarity belongs. By clustering the original sentence embedding vectors through the initial cluster center, similar problem text can be divided into the same problem text class, and problem text with a large difference can be divided into different problem text classes, to obtain a plurality of intermediate problem text classes, each of which includes at least one original sentence embedding vector.
[0085] The above steps S210 to S220 can cluster similar original sentence embedding vectors into the same initial cluster center and cluster original sentence embedding vectors with a large difference into different initial cluster centers by clustering all original sentence embedding vectors through the initial cluster center, thereby dividing similar problem text into the same problem text class and dividing problem text with a large difference into different problem text classes, to realize the classification of problem text data without problem category labels.
[0086] Please refer to Figure 3 In some embodiments, step S150 can include but is not limited to steps S310 to S320:
[0087] In step S310, a sentence mean vector of each intermediate problem text class is obtained according to the original sentence embedding vector.
[0088] In step S320, a text cluster center of the intermediate problem text class is determined according to the sentence mean vector.
[0089] In step S310 of some embodiments, the number of cluster centers of the initial cluster center is obtained, the original sentence embedding vectors of the same intermediate problem text class are added to obtain a sentence sum vector, and the sentence sum vector is divided by the number of cluster centers to obtain the sentence mean vector of the intermediate problem text class. The calculation method of the sentence mean vector is shown in formula (1).
[0090]
[0091] wherein C i,t is the text cluster center, C i,t-1 is the initial cluster center, |c i,t | is the number of cluster centers of the initial cluster center, which is equal to the number of cluster centers of the text cluster center, and x is the original sentence embedding vector.
[0092] In step S320 of some embodiments, the sentence mean vector is taken as a text clustering center of the intermediate problem text class, and the text clustering center is taken as a new clustering center to update the initial clustering center.
[0093] The steps S310 to S320 described above update the initial clustering center to obtain the text clustering center, which can optimize the clustering center to obtain the optimal text clustering center, and the original sentence embedding vector is clustered according to the text clustering center, thereby improving the accuracy of text clustering.
[0094] In step S160 of some embodiments, the inter-class dispersion between the intermediate problem text classes and the intra-class dispersion of each intermediate problem text class are calculated according to the text clustering center, wherein the calculation method of the inter-class dispersion is shown in formula (2), and the calculation method of the intra-class dispersion is shown in formula (3).
[0095] J B =|C i -C j | 2 Formula (2)
[0096] Wherein, J B represents the inter-class dispersion, C i and C j represent the text clustering centers of different intermediate problem text classes.
[0097]
[0098] Wherein, represents the intra-class dispersion, x is the original sentence embedding vector of the intermediate problem text class, and C i is the text clustering center.
[0099] Please refer to Figure 4 In some embodiments, step S170 can include but is not limited to steps S410 to S420:
[0100] Step S410, according to the inter-class dispersion and the intra-class dispersion, determining a clustering loss value;
[0101] Step S420, according to the preset number of iterations and the clustering loss value, adjusting the text of the intermediate problem text class to obtain a target problem text class.
[0102] In step S410 of some embodiments, the clustering loss is calculated according to the inter-class dispersion and the intra-class dispersion to obtain a clustering loss value. The calculation method of the clustering loss value is shown in formula (4).
[0103]
[0104] Wherein, J is the clustering loss value, n is the number of cluster centers of the text cluster center.
[0105] In step S420 of some embodiments, the current clustering iteration number t is obtained, if the current clustering iteration number t is less than the preset iteration number T, the current clustering iteration number is updated, that is, t=t+1, and the text cluster center is used to cluster all original sentence embedding vectors to obtain a plurality of intermediate problem text classes under the current clustering iteration number t, and the text cluster center of the intermediate problem text class is recalculated, and the clustering loss value under the current clustering iteration number is calculated according to the text cluster center. If the current clustering iteration number is greater than or equal to the preset iteration number, the clustering loss value under each clustering iteration number in the interval [1, T] is obtained, and the plurality of clustering loss values are screened to obtain the minimum clustering loss value. The number of cluster centers K of the text cluster center and the corresponding minimum clustering loss value and the intermediate problem text class are stored in the preset storage space, which can be cache or database. By selecting the minimum clustering loss value, that is, the maximum inter-class dispersion and the minimum intra-class dispersion, the maximum inter-class difference and the minimum intra-class difference can be obtained to obtain accurate text clustering results.
[0106] The clustering loss minimum value and the intermediate problem text class of each clustering center number K in the interval [p, q] are obtained from the storage space, the plurality of clustering loss minimum values are compared, the smallest clustering loss minimum value is selected as the target clustering loss value, the clustering center number K corresponding to the target clustering loss value is selected as the final clustering center number, and the intermediate problem text class corresponding to the target clustering loss value is selected as the target problem text class. It should be noted that the clustering center number is updated by K=K+1.
[0107] When the K-means clustering method is used for text clustering, since the K-means clustering uses the artificial specified clustering center number to perform text clustering, the accurate clustering center number cannot be obtained, which leads to inaccurate text clustering results based on the clustering center number, for example, the user asks A question, due to the inaccurate clustering center number, the question that should be clustered in A class is clustered in B class, when the intelligent customer service robot answers A question, the answer to A question is B answer, which leads to the intelligent customer service robot answering the wrong question. The steps S410 to S420 above specify the value range of the clustering center number to obtain the optimal clustering center number in a traversal manner, which can automatically determine the clustering center number, realize the self-adaptation of the clustering center number, improve the accuracy of text clustering, and thus improve the accuracy of question answering.
[0108] Please refer to Figure 5In some embodiments, step S180 can include, but is not limited to, steps S510-S530:
[0109] In step S510, semantic analysis is performed on all original sentence embedding vectors to obtain problem keywords.
[0110] In step S520, the pre-set standard question and answer library is traversed according to the problem keywords to obtain standard question texts.
[0111] In step S530, the reply texts corresponding to the standard question texts are extracted from the standard question and answer library as standard reply contents.
[0112] In step S510 of some embodiments, original question texts corresponding to all original sentence embedding vectors of the target question text class are obtained, the original question texts are processed by word segmentation according to a pre-set word segmentation library to obtain a plurality of words, the frequency of occurrence of each word in the target question text class is calculated, the words are sorted from large to small according to the frequency, and the first K words corresponding to the frequency are selected as problem keywords, where K≥1. For example, the original question texts of the target text class are “How to pay the premium of A”, “What premiums does A have”, “How much money does A collect in a year”, and “How to pay the money of A”, etc. The keywords “A”, “premium”, and “money” are obtained by calculating the frequency of the words in the original question texts. Alternatively, the semantic analysis is performed on all original sentence embedding vectors according to a keyword extraction model such as a word2vec model to obtain problem keywords.
[0113] In steps S520-S530 of some embodiments, the standard question and answer library is traversed according to the problem keywords, the similarity between the problem keywords and each question text in the standard question and answer library is calculated, the question text with the highest similarity is taken as the standard question text of the original question text, and the reply text corresponding to the standard question text is extracted from the standard question and answer library as the standard reply content, so as to construct a question and answer knowledge base according to the original question text, the standard question text, and the standard reply content of the target question text class.
[0114] The intelligent customer service robot usually adopts the knowledge base to answer questions, and the knowledge base includes standard questions, similar questions, and standard answers, but these standard questions, similar questions, and standard answers need to be manually sorted in advance. Due to the openness of the intelligent question and answer dialogue content and different ways of asking the same question, a large amount of text data needs to be manually sorted, and the manual sorting method is also prone to errors in the data of the knowledge base, resulting in answering the wrong questions. According to the final result of text clustering, the knowledge base is constructed, which not only improves the efficiency of knowledge base construction, but also ensures the accuracy of the text data of the knowledge base, thereby improving the accuracy of question answering.
[0115] Through the steps S510 to S530, the standard question text of the target question text class and the standard reply content can be determined, so as to facilitate the construction of the question and answer knowledge base according to the original question text, the standard question text and the standard reply content of the target question text class. Compared with the manual construction of the knowledge base, the efficiency of the construction of the knowledge base and the accuracy of the data in the knowledge base can be improved.
[0116] Referring to Figure 6 In some embodiments, after step S180, the text clustering method can include, but is not limited to, steps S610 to S630:
[0117] In step S610, a user question text is obtained.
[0118] In step S620, the user question text is converted into question sentence embedding features.
[0119] In step S630, the question sentence embedding features are input into a preset question and answer knowledge base to generate an answer, and a target reply text is obtained. The question and answer knowledge base includes a plurality of target question text classes, each target question text class includes a plurality of original question texts, a standard question text and a standard reply content.
[0120] In step S610 of some embodiments, the user question text is obtained, wherein the user question text is a question text obtained by a user through text input, or a question text obtained by text conversion of a user voice.
[0121] In step S620 of some embodiments, the user question text is text feature extracted according to a BERT model to obtain question sentence embedding features.
[0122] In step S630 of some embodiments, similarity calculation is performed on the question sentence embedding features and all original question texts of the question and answer knowledge base to obtain an original question text with the highest similarity, and a target question text class in which the original question text with the highest similarity is located is determined. The standard reply content of the target question text class in which the original question text with the highest similarity is located is extracted as a target reply text. Alternatively, similarity calculation is performed on the question sentence embedding features and all standard question texts of the question and answer knowledge base to obtain a standard question text with the highest similarity, and a target question text class in which the standard question text with the highest similarity is located is determined. The standard reply content of the target question text class in which the standard question text with the highest similarity is located is extracted as a target reply text. It should be noted that the user question text can be added to the corresponding target question text class of the question and answer knowledge base as an original question text to expand the question and answer knowledge base.
[0123] The steps S610 to S630 can make each user question text have corresponding standard reply content through the question and answer knowledge base, without requiring the user question text to be the same as the standard question text to obtain the standard reply content, avoiding that the intelligent question and answer robot cannot answer the question raised by the user, and improving the accuracy of question answering.
[0124] Referring to Figure 7 In some embodiments, the step S630 can include but is not limited to steps S710 to S720:
[0125] In step S710, similarity calculation is performed on the question sentence embedding feature and all original question texts of the question and answer knowledge base to obtain the original question text with the highest similarity, and a target question text class in which the original question text with the highest similarity is located is determined.
[0126] In step S720, the standard reply content of the target question text class in which the original question text with the highest similarity is located is extracted as a target reply text.
[0127] In step S710 of some embodiments, the Euclidean distance value of the question sentence embedding feature and the original sentence embedding vector of all original question texts of the question and answer knowledge base is calculated, the original question text corresponding to the original sentence embedding vector with the minimum Euclidean distance value is taken as the original question text with the highest similarity, and a target question text class is found from the question and answer knowledge base according to the original question text with the highest similarity.
[0128] In step S720 of some embodiments, the standard reply content of the target question text class in which the original question text with the highest similarity is located is taken as the target reply text.
[0129] In steps S710 to S720, similarity calculation is performed on the question sentence embedding feature and all original question texts of the question and answer knowledge base, the original question text most similar to the user question text can be obtained, and the standard reply content of the user question text is determined according to the original question text. In the case where the user question text is not the same as the standard question text, the corresponding standard reply content can also be obtained, avoiding that the intelligent question and answer robot cannot answer the question raised by the user, and improving the accuracy of question answering.
[0130] Referring to Figure 8 The application also provides a text clustering device, which can implement the above-mentioned text clustering method, and the device comprises:
[0131] The acquisition module 810 is configured to acquire a plurality of original question texts.
[0132] The feature extraction module 820 is configured to perform feature extraction on each original question text to obtain an original sentence embedding vector of each original question text.
[0133] The text class construction module 830 is configured to select an initial clustering center from the plurality of original sentence embedding vectors, and construct an initial question text class corresponding to each initial clustering center based on the initial clustering center, each initial question text class containing one initial clustering center.
[0134] The clustering module 840 is configured to perform clustering processing on all original sentence embedding vectors based on the initial clustering center to obtain a plurality of intermediate question text classes.
[0135] The clustering center identification module 850 is configured to identify a text clustering center of each intermediate question text class.
[0136] The calculation module 860 is configured to calculate inter-class dispersion between the intermediate question text classes and intra-class dispersion of each intermediate question text class according to the text clustering center.
[0137] The text adjustment module 870 is configured to perform text adjustment on the intermediate question text classes according to the inter-class dispersion and the intra-class dispersion to obtain a target question text class.
[0138] The semantic analysis module 880 is configured to perform semantic analysis on all original sentence embedding vectors of the target question text class to obtain a standard question text of each target question text class, and determine standard reply content of the target question text class according to the standard question text; wherein the standard question text and the original question text are used for question matching with a user question text, and the standard reply content is used for reply generation for the user question text.
[0139] The specific implementation of the text clustering device is basically the same as that of the above-mentioned text clustering method, and will not be repeated here.
[0140] The embodiment of the present application further provides an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned text clustering method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.
[0141] Please refer to Figure 9 , Figure 9 The hardware structure of the electronic device of another embodiment is illustrated, which includes:
[0142] The processor 910 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute related programs to implement the technical solutions provided by the embodiments of the present application.
[0143] The memory 920 can be implemented by a ROM (Read Only Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), and the like. The memory 920 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 920 and are called and executed by the processor 910 to implement the text clustering method of the embodiments of the present application.
[0144] The input / output interface 930 is configured to implement information input and output.
[0145] The communication interface 940 is configured to implement the communication interaction between the device and other devices. The communication can be realized by a wired manner (for example, a USB, a network cable, and the like) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, and the like).
[0146] The bus 950 is configured to transmit information between various components (for example, the processor 910, the memory 920, the input / output interface 930, and the communication interface 940) of the device.
[0147] The processor 910, the memory 920, the input / output interface 930, and the communication interface 940 are connected to each other through the bus 950 to realize the communication connection between the device.
[0148] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program is executed by the processor to implement the above-mentioned text clustering method.
[0149] The memory is a non-transitory computer readable storage medium, which can be used to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory can include a high-speed random access memory, and can also include a non-transitory memory, for example, at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0150] The text clustering method, the text clustering device, the electronic equipment and the computer readable storage medium provided by the embodiments of the present application can obtain a plurality of original question texts, perform feature extraction on each original question text to obtain an original sentence embedding vector of each original question text, select an initial clustering center from the plurality of original sentence embedding vectors, and construct an initial question text class corresponding to each initial clustering center based on the initial clustering center, wherein each initial question text class contains an initial clustering center. Based on the initial clustering center, all original sentence embedding vectors are clustered to obtain a plurality of intermediate question text classes. Through the clustering processing, the plurality of similar question texts of the user can be clustered into the same question text class, so that the plurality of similar questions have the same standard question. Compared with the way of manually combing the standard question and the similar question, the original question text can be quickly classified, the artificial workload is reduced, and the efficiency and accuracy of text classification are improved. Further, the clustering center of each intermediate question text class is identified to obtain a text clustering center of each intermediate question text class. According to the text clustering center, the inter-class dispersion between the intermediate question text classes and the intra-class dispersion of each intermediate question text class are calculated. According to the inter-class dispersion and the intra-class dispersion, the text of the intermediate question text class is adjusted to obtain a target question text class. Through the inter-class dispersion and the intra-class dispersion, the text difference between different intermediate question text classes is increased, and the text difference within the same intermediate question text class is reduced, so that the accuracy of text clustering can be improved. Finally, semantic analysis is performed on all original sentence embedding vectors of the target question text class to obtain a standard question text of each target question text class, so that the plurality of similar questions in the target question text class have the same standard question text. According to the standard question text, the standard reply content of the target question text class is determined. The standard question text and the original question text are used for question matching with the user question text, and the standard reply content is used for reply generation for the user question text. The standard reply content of the similar question can be obtained, and the accuracy of question answering is improved.
[0151] The embodiments described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0152] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than the figures shown, or combine certain steps or different steps.
[0153] The apparatus embodiments described above are merely exemplary, and the units described as separate units can or can not be physically separate, i.e., can be located in one place, or can be distributed over multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.
[0154] Those skilled in the art can understand that all or some of the steps in the method disclosed above, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and appropriate combinations thereof.
[0155] The terms "first", "second", "third", "fourth" and the like in the description of the application and in the claims of the foregoing drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so
[0156] It should be understood that in this application, "at least one" means one or more, and "multiple" means two or more. "And / or" is used to describe the relationship between the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that there are three cases: only A, only B, and A and B at the same time, where A and B can be singular or plural. The character " / " generally represents that the associated objects before and after are a "or" relationship. "At least one of the following" or the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c, can mean: 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.
[0157] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the above units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.
[0158] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they can be located in one place or 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 embodiment.
[0159] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0160] If the integrated unit is realized in the form of 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 solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.
[0161] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, but this does not limit the scope of the rights of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the rights of the embodiments of the present application.
Claims
1. A method of text clustering, characterized by, The method comprises: obtaining a plurality of original question texts; performing feature extraction on each of the original question texts to obtain an original sentence embedding vector of each of the original question texts; selecting an initial clustering center from a plurality of the original sentence embedding vectors, and constructing an initial question text class corresponding to each of the initial clustering centers based on the initial clustering center; wherein each of the initial question text classes comprises one of the initial clustering centers; performing clustering processing on all of the original sentence embedding vectors based on the initial clustering centers to obtain a plurality of intermediate question text classes; identifying a text clustering center of each of the intermediate question text classes; calculating an inter-class dispersion between the intermediate question text classes and an intra-class dispersion of each of the intermediate question text classes according to the text clustering center; performing text adjustment on the intermediate question text classes according to the inter-class dispersion and the intra-class dispersion to obtain a target question text class; performing semantic analysis on all of the original sentence embedding vectors of the target question text class to obtain a standard question text of each of the target question text classes, and determining standard reply content of the target question text class according to the standard question text; wherein the standard question text and the original question text are used for question matching with a user question text, and the standard reply content is used for reply generation on the user question text. The method comprises: determining a clustering loss value according to the inter-class dispersion and the intra-class dispersion; performing text adjustment on the intermediate question text classes according to a preset number of iterations and the clustering loss value to obtain the target question text class.
2. The text clustering method of claim 1, wherein, The method comprises: calculating a distance value between each of the original sentence embedding vectors and all of the initial clustering centers; dividing each of the original sentence embedding vectors into an initial question text class corresponding to an initial clustering center with the smallest distance value to obtain a plurality of the intermediate question text classes; wherein each of the intermediate question text classes comprises at least one of the original sentence embedding vectors.
3. The text clustering method of claim 1, wherein, The method comprises: obtaining a sentence mean vector of each of the intermediate question text classes according to the original sentence embedding vector; determining a text clustering center of the intermediate question text class according to the sentence mean vector.
4. The text clustering method of claim 1, wherein, The method comprises: performing semantic analysis on all of the original sentence embedding vectors to obtain a question keyword; performing question traversal on a preset standard question and answer library according to the question keyword to obtain a standard question text; extract a reply text corresponding to the standard question text from the standard question-answer library as standard reply content.
5. The text clustering method according to any one of claims 1 to 4, characterized in that, After determining the standard reply content of the target question text class according to the standard question text, the text clustering method further comprises: obtaining a user question text; converting the user question text into question sentence embedding features; inputting the question sentence embedding features into a preset question-answer knowledge base for answer generation to obtain a target reply text; wherein the question-answer knowledge base comprises a plurality of target question text classes, each target question text class comprises a plurality of original question texts, a standard question text and a standard reply content.
6. The text clustering method of claim 5, wherein, The method further comprises: performing similarity calculation on the question sentence embedding features and all original question texts of the question-answer knowledge base to obtain an original question text with the highest similarity, and determining a target question text class to which the original question text with the highest similarity belongs; extracting the standard reply content of the target question text class to which the original question text with the highest similarity belongs as the target reply text.
7. A text clustering apparatus characterized by comprising: The device comprises: an acquisition module configured to acquire a plurality of original question texts; a feature extraction module configured to perform feature extraction on each original question text to obtain an original sentence embedding vector of each original question text; a text class construction module configured to select an initial clustering center from the plurality of original sentence embedding vectors, and construct an initial question text class corresponding to each initial clustering center based on the initial clustering center, each initial question text class comprising one initial clustering center; a clustering module configured to perform clustering processing on all original sentence embedding vectors based on the initial clustering center to obtain a plurality of intermediate question text classes; a clustering center identification module configured to identify a text clustering center of each intermediate question text class; a calculation module configured to calculate inter-class scatter between the intermediate question text classes and intra-class scatter of each intermediate question text class according to the text clustering center; a text adjustment module configured to perform text adjustment on the intermediate question text classes according to the inter-class scatter and the intra-class scatter to obtain target question text classes; a semantic analysis module configured to perform semantic analysis on all original sentence embedding vectors of the target question text classes to obtain a standard question text of each target question text class, and determine standard reply content of the target question text class according to the standard question text; wherein the standard question text and the original question text are used for question matching with a user question text, and the standard reply content is used for reply generation for the user question text; The text clustering device is further configured to: determine a clustering loss value according to the inter-class scatter and the intra-class scatter; perform text adjustment on the intermediate question text classes according to a preset number of iterations and the clustering loss value to obtain the target question text classes.
8. An electronic device, characterized by The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the text clustering method in any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the text clustering method in any one of claims 1 to 6.
Citation Information
Patent Citations
Knowledge graph establishing method and device
CN112463974A
Hot topic identification method, computer equipment and storage medium
CN113342979A