Construction method of general model for intelligent customer service semantic recognition and question-answering robot
Through the TF-IDF algorithm and random forest model, a cross-domain intelligent customer service semantic recognition model was constructed, which solved the problem of insufficient response capabilities of existing intelligent customer service models in different industries, and achieved good performance in e-commerce, games and other fields. High cost performance.
Patent Information
- Application Number
- CN202210259431.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-03-16
AI Technical Summary
Existing smart customer service question and answer models usually have professional field limitations, making it difficult to respond effectively in different industries, and cannot adapt to the business needs of multiple industries.
The TF-IDF algorithm and random forest model are adopted to collect entries from different industries and fields, perform data cleaning and word segmentation, calculate the maximum and average similarity values, and establish a general intelligent customer service semantic recognition model to achieve cross-domain semantic recognition.
The built general intelligent customer service semantic recognition model can perform well in multiple industry fields and has a high cost performance, and is more universal and efficient than conventional semantic recognition tools in specific fields.
Smart Images

Figure CN114722830B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of semantic recognition technology, and in particular to a method for constructing an intelligent customer service question and answer model. Background Art
[0002] In recent years, with the rapid development of natural language processing technology, traditional customer service is increasingly unable to meet current business needs. Intelligent customer service systems based on natural language technology have emerged and are widely used in various fields, such as e-commerce, games, etc. Generally speaking, the intelligent customer service question-and-answer model in each field has certain professional field limitations. For example, if the intelligent customer service in the e-commerce field is applied to the game field, it will be difficult to make an effective response to customer inquiries. Summary of the invention
[0003] Based on this, in order to solve the above technical problems, a method for constructing a general model of intelligent customer service semantic recognition and a question-answering robot are provided.
[0004] In the first aspect, a method for constructing a general model for intelligent customer service semantic recognition includes the following steps:
[0005] S1. Collect multiple entries recorded by multiple companies in different industries, each of which includes multiple test sentences with different expressions but the same meaning; set a unique target label for each entry;
[0006] S2. Perform data cleaning on all the test statements obtained;
[0007] S3, using the TF-IDF algorithm to calculate multiple candidate terms for each test sentence and give a ranking;
[0008] S4. Segment each test sentence, and based on the segmentation results, use a similarity algorithm to calculate the maximum similarity of the candidate terms and the average value of the top m most similar sentences (these m sentences may come from different terms); establish a random forest model, the input of the random forest model includes the maximum value, the average value and the ranking score of the candidate terms obtained in step S3, and the output of the random forest model is the optimal term label for the test sentence; the trained random forest model is the general model for intelligent customer service semantic recognition.
[0009] Optionally, in step S1, the collecting of multiple entries recorded by multiple companies in different industry fields is specifically: determining multiple different industry fields, selecting at least two characteristic companies in each industry field, and randomly extracting more than 200 entries based on customer statements recorded by each characteristic company.
[0010] Optionally, in step S2, the data cleaning specifically includes removing stop words and deleting greeting data.
[0011] Optionally, in step S4, each test sentence is segmented, specifically using ansj segmentation and n-gram segmentation, where n is 1-4; accordingly, the maximum value and average value of the similarity algorithm under ansj segmentation and the maximum value and average value of the similarity algorithm under n-gram segmentation are calculated respectively.
[0012] Optionally, in step S4, the similarity algorithm includes a Jaccard similarity algorithm and a bag-of-words similarity algorithm, and accordingly, the maximum value and average value of each algorithm are calculated respectively.
[0013] Optionally, in step S4, the input of the random forest model also includes the length of the test sentence.
[0014] Optionally, in step S3, 5 candidate terms are calculated for each test sentence; in step S4, the top m most similar sentences are calculated, and m is 10.
[0015] In a second aspect, a device for generating a general model for intelligent customer service semantic recognition includes:
[0016] A data collection module is used to collect multiple entries recorded by multiple companies in different industries, each of which includes multiple test sentences with different expressions but the same meaning; and to set a unique target label for each entry;
[0017] The data cleaning module is used to clean the data of all the obtained test statements;
[0018] The candidate term calculation module is used to calculate multiple candidate terms for each test sentence using the TF-IDF algorithm and give a ranking;
[0019] A data rearrangement module is used to segment each test sentence, and based on the segmentation results, a similarity algorithm is used to calculate the maximum similarity of candidate terms and the average value of the top m most similar sentences; a random forest model is established, and the input of the random forest model includes the maximum value, the average value and the ranking score of the candidate terms given by the candidate term calculation module, and the output of the random forest model is the optimal term label of the test sentence; the trained random forest model is the general model of intelligent customer service semantic recognition.
[0020] In a third aspect, a computer device includes a memory and a processor, wherein the memory stores a computer program, and the device is special in that when the processor executes the computer program, the method for constructing the above-mentioned general model of intelligent customer service semantic recognition is implemented.
[0021] In a fourth aspect, a computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the method for constructing the above-mentioned general model of intelligent customer service semantic recognition.
[0022] In the fifth aspect, a question-and-answer robot includes a memory and a processor, wherein the memory stores a computer program. The robot is special in that when the processor executes the computer program, it runs the general model of intelligent customer service semantic recognition, receives the sentences to be recognized input by the customer, and obtains the corresponding entry label; and selects an adapted response sentence from the customer service database according to the entry label and outputs it.
[0023] The present invention has at least the following beneficial effects:
[0024] The present invention collects multiple entries recorded by multiple companies in different industry fields, and after data cleaning, uses the TF-IDF algorithm to calculate multiple candidate entries for each test sentence, and gives a ranking; and, each test sentence is segmented, and the maximum similarity of the candidate entries and the average value of the most similar multiple sentences are calculated using a similarity algorithm based on the segmentation result; these features (the ranking score of the candidate entries, the maximum value calculated by the similarity algorithm, the average value, etc.) are used as input, and the optimal entry label of the test sentence is used as output, and the random forest model is trained to obtain a general intelligent customer service semantic recognition model, so as to be universally applicable to multiple industry fields. After testing, for the model constructed by collecting data from industry fields such as e-commerce, games, and education, the customer service response performance in industry fields such as e-commerce, games, and education is good; compared with conventional semantic recognition tools in specific fields, the present invention has a higher cost performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A flowchart of a method for constructing a general model for intelligent customer service semantic recognition provided by one embodiment of the present invention;
[0026] Figure 2 The figure is a schematic diagram of a specific process of data collection, data cleaning and calculation of candidate entries in one embodiment of the present invention.
[0027] Figure 3 The figure is a schematic diagram of a specific process of data rearrangement in one embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] In one embodiment, Figure 1As shown, a method for constructing a general model for intelligent customer service semantic recognition is provided, comprising the following steps:
[0030] S1. Collect multiple entries recorded by multiple companies in different industries, each entry includes multiple test sentences with different expressions but the same meaning; set a unique target label for each entry;
[0031] S2. Perform data cleaning on all the test statements obtained;
[0032] S3, using the TF-IDF algorithm to calculate multiple candidate terms for each test sentence and give a ranking;
[0033] S4. Segment each test sentence, and use a similarity algorithm based on the segmentation results to calculate the maximum similarity of the candidate terms and the average value of the top m most similar sentences; establish a random forest model, the input of the random forest model includes the maximum value, the average value and the ranking score of the candidate terms obtained in step S3, and the output of the random forest model is the optimal term label for the test sentence; the trained random forest model is the general model for intelligent customer service semantic recognition.
[0034] The general model of intelligent customer service semantic recognition obtained by the above method is applicable to multiple industries and has a high cost-effectiveness. After testing, the model constructed by collecting data from industries such as e-commerce, games, and education has good customer service response performance in these industries.
[0035] For example, a preferred specific implementation scheme of an embodiment of the present invention is as follows: Figure 2 , Figure 3 As shown, it mainly includes four links:
[0036] 1. Data Collection
[0037] Because we want to make a general intelligent customer service Q&A robot, we select as many different fields as possible in data selection, such as e-commerce, games, education, etc. In each field, we select 2-3 characteristic companies. These companies are representative companies in the field. Under each company, we randomly select more than 200 entries.
[0038] One entry covers multiple sentences with the same meaning. For example, "Why hasn't my refund arrived yet?" and "When will the refund arrive?" are both asking "when will the refund arrive?", so they are the same entry. Each entry will have more than 20 sentences with different expressions but the same meaning. Each entry has an entry name, which will be used as the label of this entry. After that, test sentences will be selected in each company. Each sentence has the entry name it should belong to as the target label.
[0039] The above data collection part is completed.
[0040] 2. Data Cleaning
[0041] Data cleaning is an essential part of every model. Without data cleaning, it is easy to have inaccurate data and large errors. In this part, this embodiment mainly removes stop words and deletes greeting data.
[0042] Stop words refer to words that appear frequently but have no practical meaning. For example: de, da, ah, you, me, le, etc. The existence of these words affects the matching results and the calculation scores. It is worth noting that according to different word segmentation algorithms, this embodiment uses two stop word libraries in step S4 word segmentation. One is used for ansj word segmentation, which is a commonly used stop word in the customer service field; the other is used for n-gram word segmentation, which is a commonly used stop word in spoken language. The second stop word list is much smaller than the first one, mainly to avoid inaccurate word segmentation.
[0043] Greetings are a type of data that cannot be avoided in question-answering systems, such as "hello", "thank you", "goodbye", etc. These sentences do not contain any practical meaning, and the performance of the model will be better if they are removed.
[0044] 3. Calculate alternative entries
[0045] The TF-IDF algorithm is used to calculate 5 candidate terms for each test sentence. It is observed that the first five candidate answers have a very high probability of having the optimal label of the sentence.
[0046] The main idea of TF-IDF is: if a word appears in an article with a high frequency TF and rarely appears in other articles, it is considered that this word or phrase has good category distinction ability and is suitable for classification.
[0047] Term frequency (TF) indicates how often a term (keyword) appears in a document. This number is usually normalized (usually the term frequency divided by the total number of words in the article) to prevent it from being biased towards long documents.
[0048]
[0049] Inverse Document Frequency (IDF): The IDF of a particular word can be obtained by dividing the total number of documents by the number of documents containing the word and then taking the logarithm of the quotient. If the fewer documents contain the term t, the larger the IDF, which means that the term has good category discrimination ability.
[0050]
[0051] A high word frequency within a particular document, and a low document frequency of that word in the entire document collection, can produce a high weighted TF-IDF. Therefore, TF-IDF tends to filter out common words and retain important words.
[0052] TF-IDF=TF*IDF
[0053] Because the TF-IDF score is not universal, after the candidate terms are introduced, this score is not used as one of the features in the subsequent random forest model. Instead, this model uses the order of the candidate answers as a feature. For example, the first-ranked term is 1.
[0054] 4. Data Rearrangement
[0055] 4.1 Word Segmentation
[0056] First, we need to perform word segmentation. This model uses two word segmentation methods: ansj word segmentation and n-gram word segmentation.
[0057] ansj is an open source Java Chinese word segmentation tool, based on the ictclas Chinese word segmentation algorithm of the Chinese Academy of Sciences, and has a higher word segmentation accuracy than other commonly used open source word segmentation tools (such as mmseg4j). However, there are still inevitable word segmentation errors, such as proper nouns in some fields. In this case, n-gram can be used to make up for this defect; here, n is 1-4.
[0058] 4.2 Calculating Distance
[0059] This model uses two algorithms to calculate distance: jaccard similarity algorithm and bag-of-words algorithm.
[0060] A. Jaccard similarity algorithm:
[0061] Given two sets A and B, the Jaccard coefficient is defined as the ratio of the size of the intersection of A and B to the size of the union of A and B, as follows:
[0062]
[0063] The larger the Jaccard coefficient value, the higher the sample similarity.
[0064] B. Bag-of-words similarity algorithm
[0065] The Bag-of-Words model (BOW) was originally used in text classification to represent documents as feature vectors. Its basic idea is to assume that for a text, its word order, grammar, and syntax are ignored, and it is only regarded as a collection of words, and each word in the text is independent. Simply put, each document is regarded as a bag (because it is filled with words, it is called a bag of words, hence the name Bag of words), and then we look at what words are in the bag and classify them. If there are more words like pig, horse, cow, sheep, valley, land, and tractor in the document, and fewer words like bank, building, car, and park, we tend to judge that it is a document describing the countryside rather than a town.
[0066] This model uses the maximum and average values in each algorithm as model features. The maximum value is the score of the sentence in the entry that is most similar to the test sentence. In order to avoid errors caused by insufficient purity of the entry, this model also adds the average value of the top 10 most similar sentences as a feature.
[0067] 4.3 Random Forest Model and Its Training
[0068] After inputting all the above features into the random forest model, the model will output the optimal term label for the sentence.
[0069] Random forest is a relatively new machine learning model (non-linear tree-based model) ensemble learning method. Random forest is a type of cluster classification model. Random forest uses a random method to build a forest. The forest consists of many decision trees, and there is no correlation between each decision tree. After obtaining the random forest model, when a new sample enters, each decision tree in the random forest makes a judgment separately. The bagging set strategy is relatively simple. For classification problems, the voting method is usually used, and the category with the most votes or one of the categories is the final model output. For regression, the simple average method is usually used, and the regression results obtained by T weak learners are arithmetic averaged to obtain the final model output.
[0070] It should be understood that, although the various steps in the above flow chart are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the figure may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0071] In one embodiment, a device for generating a general model of intelligent customer service semantic recognition is also provided, comprising the following program modules:
[0072] A data collection module is used to collect multiple entries recorded by multiple companies in different industries, each of which includes multiple test sentences with different expressions but the same meaning; and to set a unique target label for each entry;
[0073] The data cleaning module is used to clean the data of all the obtained test statements;
[0074] The candidate term calculation module is used to calculate multiple candidate terms for each test sentence using the TF-IDF algorithm and give a ranking;
[0075] A data rearrangement module is used to segment each test sentence, and based on the segmentation results, a similarity algorithm is used to calculate the maximum similarity of candidate terms and the average value of the top m most similar sentences; a random forest model is established, and the input of the random forest model includes the maximum value, the average value and the ranking score of the candidate terms given by the candidate term calculation module, and the output of the random forest model is the optimal term label of the test sentence; the trained random forest model is the general model of intelligent customer service semantic recognition.
[0076] For the specific limitations of each program module in the above-mentioned device, please refer to the limitations of the construction method of the above-mentioned intelligent customer service semantic recognition general model in the above text, which will not be repeated here.
[0077] In one embodiment, a computer device is also provided, which may be a terminal. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. When the computer program is executed by the processor, the method for constructing the above-mentioned general model of intelligent customer service semantic recognition is implemented.
[0078] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which involves all or part of the processes in the above-mentioned embodiment method.
[0079] In one embodiment, a question-and-answer robot is also provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the above-mentioned general model of intelligent customer service semantic recognition is run, and a sentence to be recognized input by a customer is received to obtain a corresponding entry label; and an adapted response sentence is selected from a customer service database according to the entry label and outputted.
[0080] The technical features of the above embodiments may be arbitrarily combined (as long as there is no contradiction in the combination of these technical features). To make the description concise, not all possible combinations of the technical features in the above embodiments are described; these embodiments that are not explicitly written should also be considered to be within the scope of this specification.
[0081] The above is a relatively specific and detailed description of the present application through general description and specific embodiments. It should be understood that, based on the technical concept of the present application, several conventional adjustments or further innovations can be made to these specific embodiments; however, as long as they do not deviate from the technical concept of the present application, the technical solutions obtained by these conventional adjustments or further innovations also fall within the scope of protection of the claims of the present application.
Claims
1. A method for constructing a general model for intelligent customer service semantic recognition, characterized in that: The following steps are involved: S1. Collect multiple entries recorded by multiple companies in different industries, each of which includes multiple test sentences with different expressions but the same meaning; set a unique target label for each entry; S2. Perform data cleaning on all the test statements obtained; S3, using the TF-IDF algorithm to calculate multiple candidate terms for each test sentence and give a ranking; S4, segmenting each test sentence, and using a similarity algorithm to calculate the maximum similarity of candidate terms and the average value of the most similar first m sentences based on the segmentation results; A random forest model is established, wherein the input of the random forest model includes the length of the test sentence, the maximum value, the average value, and the ranking score of the candidate terms obtained in step S3, and the output of the random forest model is the optimal term label of the test sentence; the trained random forest model is the general model of intelligent customer service semantic recognition.
2. The method for constructing a general model for intelligent customer service semantic recognition according to claim 1 is characterized in that: In step S1, the multiple entries recorded by multiple companies in different industry fields are collected, specifically: multiple different industry fields are determined, at least two characteristic companies are selected in each industry field, and more than 200 entries are randomly selected based on customer statements recorded by each characteristic company.
3. The method for constructing a general model for intelligent customer service semantic recognition according to claim 1, characterized in that: In step S2, the data cleaning specifically includes removing stop words and deleting greeting data.
4. The method for constructing a general model for intelligent customer service semantic recognition according to claim 1, characterized in that: In step S4, each test sentence is segmented, specifically using ansj segmentation and n-gram segmentation, where n is 1-4; accordingly, the maximum value and average value of the similarity algorithm under ansj segmentation and the maximum value and average value of the similarity algorithm under n-gram segmentation are calculated respectively.
5. The method for constructing a general model for intelligent customer service semantic recognition according to claim 4 is characterized in that: In step S4, the similarity algorithm includes a Jaccard similarity algorithm and a bag-of-words similarity algorithm, and accordingly, the maximum value and average value of each algorithm are calculated respectively.
6. The method for constructing a general model for intelligent customer service semantic recognition according to claim 4 is characterized in that: In step S3, five candidate terms are calculated for each test sentence; in step S4, the top m most similar sentences are calculated, where m is 10.
7. A device for generating a general model for intelligent customer service semantic recognition, characterized in that: include: A data collection module is used to collect multiple entries recorded by multiple companies in different industries, each of which includes multiple test sentences with different expressions but the same meaning; and to set a unique target label for each entry; The data cleaning module is used to clean the data of all the obtained test statements; The candidate term calculation module is used to calculate multiple candidate terms for each test sentence using the TF-IDF algorithm and give a ranking; The data rearrangement module is used to segment each test sentence, and based on the segmentation results, a similarity algorithm is used to calculate the maximum similarity of candidate terms and the average value of the first m most similar sentences; A random forest model is established, wherein the input of the random forest model includes the length of the test sentence, the maximum value, the average value, and the ranking score of the alternative terms given by the alternative term calculation module, and the output of the random forest model is the optimal term label of the test sentence; the trained random forest model is the general model of intelligent customer service semantic recognition.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A question-answering robot, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it runs the general model of intelligent customer service semantic recognition obtained by the method described in any one of claims 1 to 6, receives the sentence to be recognized input by the customer, and obtains the corresponding entry label; according to the entry label, it selects and outputs the adapted response sentence from the customer service database.
Citation Information
Patent Citations
Intelligent customer service response method and system
CN110162611A
Data recommendation model training method, device and equipment and storage medium
CN111104422A