Intelligent dialogue service method and related device
By filtering sensitive words and custom tags in the intelligent customer service robot and calculating the similarity of recall problems, the problem of excessive load on traditional intelligent customer service robots is solved, and more efficient and safe intelligent dialogue services are achieved.
Patent Information
- Application Number
- CN202411743767.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-03-11
AI Technical Summary
When traditional intelligent customer service robots process user requests, they fail to effectively filter invalid requests, resulting in excessive load on the inference engine and affecting service effectiveness.
By obtaining user questions, we can judge whether they contain sensitive words or custom tags, and feedback the corresponding reply words based on the results; otherwise, the question will be segmented and standardized, and the similarity scores of the recall problem and the knowledge base standard problem will be calculated to generate reply words.
It reduces the load of conversation robots, improves the efficiency and security of services, and makes intelligent conversation services more practical.
Smart Images

Figure CN119597893A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an intelligent dialogue service method and related devices. Background Art
[0002] With the continuous advancement of the digital transformation of the banking industry, the banking scenarios are becoming deeper and wider, and financial scenario services are everywhere. Traditional bank branches and counters are unable to meet the massive number of user questions. How to provide good financial pre-sales, in-sales, and after-sales services has become a problem that every financial enterprise has to think about. Therefore, with the development of artificial intelligence technology, intelligent customer service robots have become the only choice to improve corporate service capabilities and customer service efficiency.
[0003] Using intelligent customer service, the process generally has the following steps:
[0004] 1. Model training: Business personnel regularly update and maintain corpus pairs and expand questions based on internal corporate documents and materials as corpus training materials for the intelligent customer service robot model.
[0005] 2. Semantic analysis: When a customer inputs a question, the intelligent customer service backend service performs data preprocessing, retrieval preprocessing, text embedding, similarity measurement and other steps in sequence to match the customer's question with the corpus trained by the model.
[0006] For traditional intelligent customer service robots, the quality of maintenance of corpus seriously affects the service effect of the model. However, considering the high threshold of professional knowledge in the financial industry, how to efficiently disassemble financial knowledge has become one of the factors restricting the development of traditional intelligent customer service robots.
[0007] The applicant's research found that when processing user requests, the intelligent customer service robot did not filter invalid requests input by users. All requests flowed directly into the conversational robot, causing the inference engine to be overloaded. Summary of the invention
[0008] In view of this, an embodiment of the present invention provides an intelligent dialogue service method and related devices to reduce the load of a dialogue robot.
[0009] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0010] An intelligent dialogue service method, comprising:
[0011] Get user questions;
[0012] Determine whether the user's question contains sensitive words or custom tags;
[0013] When the sensitive word or custom tag is included, a reply script matching the sensitive word or custom tag is obtained and fed back to the user;
[0014] When no sensitive words or custom tags are included, the user's question is segmented to obtain a set of recalled questions;
[0015] Standardizing the recall question set to obtain word vectors and BERT vectors corresponding to the recall questions in the recall question set;
[0016] The similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base are calculated using an edit distance model, recorded as a word class score;
[0017] The word vector model is used to calculate the similarity score between the word vector and the standard question in the knowledge base, which is recorded as the word vector score;
[0018] The BERT model is used to calculate the similarity score between the BERT vector and the standard question of the knowledge base, which is recorded as the neural network model score;
[0019] Calculating confidence scores of the recall questions and knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores;
[0020] Based on the confidence scores corresponding to the recalled questions and each knowledge base standard question, a response script is generated.
[0021] Optionally, in the above-mentioned intelligent dialogue service method, determining whether the user question contains sensitive words or custom tags includes:
[0022] Use sensitive word filters to determine whether the user's question contains sensitive words through the sensitive word dictionary;
[0023] When the sensitive words are not included, a punctuation filter is used to process the user question using a regular expression to filter the punctuation in the user question;
[0024] A custom tag filter is used to determine whether the user question after filtering punctuation marks contains a custom tag based on the custom tag.
[0025] Optionally, in the above intelligent dialogue service method, the user's question is segmented to obtain a set of recalled questions, including:
[0026] Preprocessing the user's question, wherein the preprocessing at least includes word segmentation processing;
[0027] Based on the word segmentation results, a rough recall is performed in the knowledge base or index to obtain a set of recalled questions that match the user's question.
[0028] Optionally, in the above intelligent dialogue service method, the confidence scores of the recall questions and the knowledge base standard questions in the recall question set are calculated based on the word class scores, word vector scores, and neural network model scores, including:
[0029] Based on the formula Y=X1×K1+ X2×K2+ X3×K3, the confidence scores Y of the recall questions and the knowledge base standard questions in the recall question set are calculated;
[0030] Among them, X1 is the word class score, K1 is the word class weight, X2 is the word vector score, K2 is the word vector weight, X3 is the neural network model score, and K3 is the neural network model weight.
[0031] Optionally, in the above intelligent dialogue service method, based on the confidence scores corresponding to the recalled questions and the standard questions in the knowledge base, generating a reply script includes:
[0032] Determine whether there is a confidence score greater than a rejection threshold among the confidence scores corresponding to each recall question and each knowledge base standard question in the recall question set; if there is a confidence score greater than the rejection threshold, determine whether there is a confidence score greater than a credible threshold among the confidence scores corresponding to each recall question and each knowledge base standard question; if there is a confidence score greater than the credible threshold, feed back to the user the reply words of the knowledge base standard question corresponding to the confidence score greater than the credible threshold; if there is no confidence score greater than the credible threshold, feed back to the user the knowledge base standard question corresponding to the confidence score between the rejection threshold and the credible threshold, so that the user can reselect the user question;
[0033] When it is recognized that the user has selected the standard question of the knowledge base, the reply words of the standard question of the knowledge base selected by the user are fed back to the user.
[0034] Optionally, in the above-mentioned intelligent dialogue service method, when there is no confidence score greater than the rejection threshold among the confidence scores corresponding to the various recall questions in the recall question set and the various knowledge base standard questions, the user question is responded to through the large model.
[0035] An intelligent dialogue service device, comprising:
[0036] A question acquisition unit, used to acquire user questions;
[0037] A screening unit, configured to determine whether the user's question contains sensitive words or custom tags; when the user's question contains sensitive words or custom tags, obtain and provide feedback to the user with a reply script that matches the sensitive words or custom tags;
[0038] The question set construction unit is used to segment the user's question sentence to obtain a recall question set when it does not contain sensitive words or custom tags;
[0039] A standardization processing unit, used for performing standardization processing on the recall question set to obtain word vectors and BERT vectors corresponding to the recall questions in the recall question set;
[0040] An edit distance model, used to calculate similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base using the edit distance model, recorded as a word class score;
[0041] A word vector model, used to calculate a similarity score between the word vector and a standard question in a knowledge base using the word vector model, recorded as a word vector score;
[0042] A BERT model is used to calculate a similarity score between the BERT vector and a standard question in the knowledge base, which is recorded as a neural network model score;
[0043] A confidence calculation unit, used to calculate the confidence scores of the recall questions and the knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores;
[0044] The reply unit is used to generate a reply script based on the confidence scores corresponding to the recall question and each knowledge base standard question.
[0045] A computer program product includes computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the above-mentioned intelligent dialogue service methods.
[0046] An electronic device comprises at least one processing device and a storage device connected to the processing device, wherein:
[0047] The storage device is used to store computer programs;
[0048] The processing device is used to execute the computer program so that the electronic device can implement the intelligent dialogue service method as described in any one of the above.
[0049] A computer storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement any of the intelligent dialogue service methods described above.
[0050] Based on the above technical solution, the above solution provided by the embodiment of the present invention, after obtaining the user's question, first use sensitive words and custom tags to filter the user's question. When the user's question includes the sensitive word or custom tag, feedback the user with the reply words matching the sensitive word or custom tag. Otherwise, the user's question is segmented to obtain a recall question set, the word vector and BERT vector of the recall question in the recall question set are calculated, and the word class score between the recall question and the knowledge base standard question, as well as the word vector score and neural network model score between the recall question and the knowledge base standard question are calculated. The confidence score of the recall question in the recall question set and the knowledge base standard question is further calculated based on the word class score, word vector score, and neural network model score; finally, the reply words are generated based on the confidence score corresponding to the recall question and each knowledge base standard question. This process filters the user's question by sensitive words or custom tags, reduces the system's traffic load, is more secure, and is more practical. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0052] Figure 1 A system framework diagram for implementing an intelligent dialogue service method provided by this application;
[0053] Figure 2 A schematic diagram of the structure of a terminal for implementing an intelligent dialogue service method provided by the present application;
[0054] Figure 3 A schematic diagram of the structure of a server for implementing an intelligent dialogue service method provided by the present application;
[0055] Figure 4 A flowchart of an intelligent dialogue service method provided in an embodiment of the present application;
[0056] Figure 5 A flowchart of an intelligent dialogue service method provided by another embodiment of the present application;
[0057] Figure 6 A detailed flow chart of generating a reply based on confidence provided in an embodiment of the present application;
[0058] Figure 7 A schematic diagram of the workflow of the generative intelligent dialogue unit provided in the embodiment of the present application;
[0059] Figure 8 A schematic diagram of the training process of the generative intelligent dialogue unit provided in an embodiment of the present application;
[0060] Fig. 9 A schematic diagram of the structure of an intelligent dialogue service device provided in an embodiment of the present application;
[0061] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] First, the professional and technical terms used in this application are explained:
[0064] Big Language Model: It is a language processing model based on deep learning technology. It has the ability to understand and generate natural language text by learning and training massive text data. Different from traditional rule-based language models, big language models have stronger generalization ability and flexibility.
[0065] Large language model fine-tuning: refers to optimizing and adjusting the existing large language model to make it better suited to specific tasks and data sets.
[0066] Large language model hallucination: The large language model will give seemingly reasonable but deviated predictions during the call process. This is because the large language model itself cannot truly understand language and knowledge, but imitates the patterns in the training data to generate predictions, which may seem reasonable but are actually unfounded.
[0067] Text embedding: It is a high-dimensional, dense vector representation of text data that can measure the semantic and syntactic similarity between different texts. It is usually created by machine learning models such as Word2Vec and Bert. These models can capture complex relationships between words and phrases, including semantics, context, and even certain aspects of grammar.
[0068] Similarity calculation: used to determine the similarity and relevance of two objects in some aspects. Commonly used text similarity calculations include edit distance algorithm and pre-similarity algorithm. The edit distance algorithm measures the minimum number of operations required to convert one text into another, such as inserting, deleting, or replacing characters. It reflects the degree of difference between two texts at the character level. Cosine similarity is a similarity measure of a vector space model. It measures similarity by representing text as vectors and calculating the cosine value of the angle between them.
[0069] Retrieval enhancement generation: It is mainly divided into two stages: indexing and responding to user needs. The indexing stage mainly collects documents for subsequent use by the large language model, divides them into appropriate blocks, and generates corresponding text embeddings. These text embeddings are stored in a dedicated vector database in preparation for subsequent queries. In the stage of responding to user needs, when a user asks a question, the large language model is used to convert the text query into a text embedding, which is used to search the vector database to adapt the most matching document block. The current chat memory and the documents retrieved from the vector database are used as context input together to generate the final answer.
[0070] With the continuous advancement of the digital transformation of the banking industry, the banking industry scenarios are constantly deepening and expanding, and financial scenario services are everywhere. Intelligent dialogue services have become the only choice for improving corporate service capabilities and customer service efficiency. Traditional intelligent dialogue services have achieved effective processing of high-frequency simple problems, but the ability to deal with medium- and low-frequency, large-scale and wide-ranging complex scenarios, such as special character recognition, multi-round dialogue, and empathetic chat, needs to be improved. At the same time, the overall service effect of traditional intelligent customer service robots is affected by the knowledge construction involved, and a large amount of manpower and energy are required to carry out operational work such as corpus splitting, similar question writing, and answer compilation. The present invention aims to solve the above problems. In terms of model training, the large model technology is first used to disassemble the knowledge source to form initial training corpora such as standard questions, extended questions, and answers for manual subsequent screening, thereby reducing the operating costs of the traditional model. In response to the "hallucination" problem of the large language model, the manually annotated corpus is used for fine-tuning to further enhance the service capabilities of the large model in the financial vertical field. In terms of semantic parsing, we first use expert rules to perform preprocessing such as special character filtering and replacement to reduce noise interference such as expressions and special characters; then use the retrieval component to perform rough recall such as word segmentation and sorting on the preprocessed data and obtain the retrieval score; for the rough recall question set, we use the similarity measurement algorithm to calculate the semantic model score again. By weighting the scores of each model, we can calculate the confidence score in a request. The confidence score is compared with the threshold access control to divide it into three states: rejection, acceptance, and trustworthiness. For the results of the rejection state, the fine-tuned large language model will be used again for secondary intent matching. If it matches the manually maintained corpus, the answer will be returned directly. If it does not match, the large language model retrieval enhancement generation technology will be used to return the result.
[0071] See also Figure 1 , Figure 1 The system architecture diagram of an intelligent dialogue service method is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 In the example, a server is included, and the server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0072] Among them, an application for implementing the intelligent dialogue service method can be installed on the terminal 100. The above application and web page can provide an interface. The terminal 100 can receive user questions input by the user on the human-computer interaction interface and send the above parameters to the server 200. The server 200 can obtain processing results based on the received user questions and return the processing results to the terminal 100.
[0073] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters by itself without the cooperation of the server, and the embodiments of the present application are not limited to this.
[0074] Next describe Figure 1 The product form of the mid-terminal 100;
[0075] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any limitation on this.
[0076] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0077] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2These are merely examples of terminals or multi-function devices and do not constitute limitations on the terminals or multi-function devices, which may include more or fewer components than those shown in the figures, or combinations of certain components, or different components.
[0078] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the portable multifunctional device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0079] Among them, the input device 132 can receive input data and the like.
[0080] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 may be used to display the user interaction interface, processing results, etc.
[0081] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0082] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0083] Among them, the memory 120 can be used to store relevant software codes for implementing the intelligent dialogue service method, the processor 170 can execute the steps of the intelligent dialogue service method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.
[0084] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0085] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.
[0086] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0087] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0088] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .
[0089] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.
[0090] Next describe Figure 1 The product form of the server 200;
[0091] Figure 3 A schematic diagram of the structure of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0092] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0093] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0094] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0095] The memory 204 may be used to store software codes related to the intelligent dialogue service method, and the processor 202 may execute the steps of the intelligent dialogue service method of the chip, and may also schedule other units to implement corresponding functions.
[0096] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0097] In order to solve the above problems, the embodiment of the present application provides an intelligent dialogue service method. The intelligent dialogue service method of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0098] Reference Figure 4 , Figure 4 A flow chart of an intelligent dialogue service method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, an intelligent dialogue service method provided by an embodiment of the present application may include steps S401 to 410, and these steps are described in detail below.
[0099] S401: Obtain user questions.
[0100] This step is for the system applying the method to obtain a user question, and the user question can be audio data or character data.
[0101] S402: Determine whether the user question contains sensitive words or custom tags.
[0102] In this step, the expert rule filtering unit can determine whether the user's question contains sensitive words or custom tags. If there are sensitive words or custom tags, the reply words that match the sensitive words or custom tags can be directly retrieved from the database. In this solution, the reply words that match the sensitive words and custom tags will be pre-configured and stored in the database. The specific content of the sensitive words and custom tags can be defined according to business needs.
[0103] In this solution, the expert rule filtering unit can determine whether the user question contains sensitive words or custom tags through a sensitive word filter, a tag symbol filter, and a custom tag filter. For details, the specific process of step S402 can be found in Figure 5 As shown:
[0104] Step S501: Determine whether the user's question contains sensitive words.
[0105] In this step, a sensitive word filter is used to determine whether the user's question contains a sensitive word through a sensitive word dictionary. If the user's question contains a sensitive word, the reply words matching the sensitive word are directly retrieved from the database and fed back to the user. Of course, the sensitive word dictionary can also directly include sensitive words and sensitive word reply words. In this case, the reply words corresponding to the sensitive words can be directly retrieved through the sensitive word dictionary.
[0106] Step S502: When the sensitive word is not included, a punctuation filter is used to process the user question using a regular expression to filter the punctuation in the user question.
[0107] When it is necessary to use a punctuation filter to filter the punctuation in the user question, the goal must be defined first. In this solution, the goal is to remove all punctuation in the user question, so that the question becomes more standardized and convenient for subsequent text processing or analysis. Then prepare a regular expression. At this time, you need to write a regular expression to match all the punctuation you want to remove. In this scenario, a pattern like [^\w\s] is usually used, where ^ represents negation, \w represents all word characters (letters, numbers, underscores), and \s represents all blank characters (spaces, tabs, newlines, etc.). Therefore, [^\w\s] matches any character that is neither a word character nor a blank character, which usually covers most punctuation. Then apply the regular expression, and apply the prepared regular expression to the user question. This is usually implemented through a regular expression library in a programming language, such as Python's re module. You can use the re.sub function, which accepts three parameters: a regular expression pattern, a replacement string, and the text to be processed (i.e., the user question). The replacement is then performed. The re.sub function finds all substrings in the user's question that match the regular expression and replaces them with the specified replacement string (in this case, the empty string). All punctuation marks are removed, leaving a normalized question containing only word characters and whitespace characters.
[0108] Step S503: using a custom tag filter to determine whether the user's question after filtering punctuation marks contains a custom tag based on the custom tag.
[0109] This application can predefine a custom tag filter. The core function of this filter is to check whether there is a string that conforms to the custom tag format in the user's question after being processed by the punctuation filter. This usually involves pattern matching of the string, such as using regular expressions to match the specific format of the custom tag. If it matches, it is determined that the user's question contains a custom tag.
[0110] S403: When the sensitive word or custom tag is included, a reply script matching the sensitive word or custom tag is obtained and fed back to the user.
[0111] S404: When no sensitive words or custom tags are included, the user's question is segmented to obtain a set of recalled questions.
[0112] In this step, a retrieval preprocessor is used to segment the user's question to obtain a set of recall questions corresponding to the user's question.
[0113] Retrieval preprocessor: a module or tool specially designed to process user input. Its main function is to preprocess user questions in order to more accurately understand and match user intentions. Preprocessing can include operations such as word segmentation. Word segmentation is a basic step in natural language processing and one of the key functions in a retrieval preprocessor. It refers to cutting the continuous text in the user's question into independent vocabulary units. These vocabulary units are the basis for subsequent processing and analysis. The effect of word segmentation directly affects the accuracy and efficiency of subsequent steps. After obtaining the user's question, the retrieval preprocessor preprocesses the user's question (word segmentation);
[0114] Recall question set: Based on the user question after word segmentation, the retrieval preprocessor will further generate a recall question set related to the user question. This set contains a series of questions that are semantically similar or related to the user question. These recall questions are retrieved from a pre-built question library, and some form of similarity calculation or matching algorithm is usually used to determine which questions are most relevant to the user question. When generating the recall question set, the user question after word segmentation is transformed into a word sequence, which represents each word in the user question. Then, based on the word segmentation results, a rough recall is performed in the knowledge base or index. Rough retrieval refers to retrieving a series of questions or information related to the user question in the knowledge base or index based on the word segmentation results. This process is usually based on some form of similarity calculation or matching algorithm, such as keyword matching, vector space model, TF-IDF, etc. The purpose of rough recall is to filter out the most relevant part of the user question from a large number of possible questions for subsequent processing and analysis. After rough recall, a recall question set matching the user question will be obtained. This collection contains a series of questions that are semantically similar or related to the user's question. These recalled questions are retrieved from the knowledge base or index and can serve as the basis for subsequent processing and analysis.
[0115] S405: Standardize the recall questions in the recall question set to obtain word vectors and BERT vectors corresponding to the recall question set.
[0116] Normalized to word vectors
[0117] Select a word vector model: First, you need to select a pre-trained word vector model, such as Word2Vec, GloVe, etc. These models can map the recall questions in the recall question set into a high-dimensional vector space, so that semantically similar words are closer in the vector space.
[0118] Obtain word vectors: For each recall question in the recall question set, after word segmentation, use the word vector model to convert each word into a corresponding word vector.
[0119] Construct question embedding: For each recall question, the word embedding of the entire recall question can be constructed by averaging, summing, concatenating, or applying more complex combination strategies.
[0120] Normalized to BERT vector
[0121] Select the BERT model: BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on the Transformer architecture that can capture the contextual relationships between words. Select a BERT model version that is suitable for the task, such as BERT-base, BERT-large, etc.
[0122] Input processing: For each question in the recall question set, appropriate input processing is required, such as adding special start and end tags ([CLS] and [SEP]), converting the text to a format accepted by the BERT model, etc.
[0123] Get BERT vector: Input the processed question into the BERT model and obtain the hidden state of each word through the forward propagation of the model. For the entire question, you can take the hidden state corresponding to the [CLS] tag as the vector representation of the question, or average or sum the hidden states of all words in the question to construct the BERT vector of the question.
[0124] S406: Using the edit distance model to calculate the similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base, recorded as the word class score.
[0125] Using the edit distance model to calculate the similarity score between the recall question set and the standard questions in the knowledge base is an effective method for handling text matching tasks. This method takes the recall question set and the standard questions in the knowledge base as input data. Subsequently, the edit distance algorithm is used to calculate the minimum number of edit operations between each recall question and each standard question in the knowledge base, which includes operations such as inserting, deleting, and replacing characters. In order to convert the edit distance into a similarity score (recorded as a word class score), a normalization formula is usually used to divide the edit distance by the maximum value of the two string lengths, invert it, and add 1, so as to obtain a score between 0 (completely different) and 1 (exactly the same), which is the similarity score, also known as the word class score.
[0126] S407: Using a word vector model, calculate a similarity score between the recall question in the word vector and the standard question in the knowledge base, which is recorded as a word vector score.
[0127] Using a word vector model to calculate the similarity score (word vector score) between word vectors and knowledge base standard questions is a text matching method based on the semantic level. This method first uses a pre-trained word vector model to convert the vocabulary in the text (including recall questions and knowledge base standard questions) into a high-dimensional vector representation, and then evaluates the semantic similarity between the texts by calculating the similarity between these word vectors (such as cosine similarity). The word vector score reflects the semantic proximity between the vocabulary in the recall question and the vocabulary in the knowledge base standard question, and can be used to support natural language processing tasks such as question-answering systems and information retrieval, and improve the accuracy and reliability of matching.
[0128] S408: Using the BERT model, calculate the similarity score between the BERT vector and the standard question in the knowledge base, which is recorded as the neural network model score.
[0129] This step uses the BERT model to calculate the similarity score between the BERT vector and the knowledge base standard question (denoted as the neural network model score). This process can be understood as an advanced text matching method. This method first uses the BERT model to encode the text (including the recall question and the knowledge base standard question) into a high-dimensional, context-rich BERT vector. Subsequently, the semantic similarity between the texts is evaluated by calculating the similarity between these BERT vectors (such as cosine similarity or the inverse measure of Euclidean distance). The neural network model score reflects the closeness between the recall questions in the recall question set and the knowledge base standard question at the deep semantic level. This score can be applied to natural language processing tasks such as question-answering systems and information retrieval to improve the accuracy and reliability of matching. With its powerful semantic understanding ability, the BERT model makes this deep learning-based text matching method have higher accuracy and generalization ability than traditional methods.
[0130] S409: Calculate confidence scores of the recall questions and knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores.
[0131] This step performs weighted calculation on the scores corresponding to each recall question in each recall question set calculated by the word class model, word vector model, and BERT model to obtain the confidence score between each recall question and the standard question of the knowledge base. Specifically, the process can be completed based on the formula: Y=X1×K1+ X2×K2+ X3×K3, where Y is the confidence score of the recall question in the recall question set and the standard question of the knowledge base, X1 is the word class score, K1 is the word class weight, X2 is the word vector score, K2 is the word vector weight, X3 is the neural network model score, and K2 is the neural network model weight. Among them, K1, K2, and K3 are preset coefficients. Based on this formula, the confidence score between each recall question in the recall question set and each knowledge base standard question can be obtained.
[0132] S410: Generate a reply script based on the confidence scores corresponding to the recalled question and each knowledge base standard question.
[0133] After determining the confidence scores between each recall question in the recall question set and each knowledge base standard question, a knowledge base standard question can be selected based on the size of these confidence scores, and a response script corresponding to the selected knowledge base standard question can be generated.
[0134] The above scheme disclosed in the present application, after obtaining the user's question, first uses sensitive words and custom tags to filter the user's question. When the user's question includes the sensitive word or custom tag, the user is fed back with a reply that matches the sensitive word or custom tag. Otherwise, the user's question is segmented to obtain a recall question set, the word vector and BERT vector of the recall question in the recall question set are calculated, and the word class score between the recall question and the knowledge base standard question, as well as the word vector score and neural network model score between the recall question and the knowledge base standard question are calculated. The confidence score of the recall question in the recall question set and the knowledge base standard question is further calculated based on the word class score, word vector score, and neural network model score; finally, the reply is generated based on the confidence score corresponding to the recall question and each knowledge base standard question. This process filters the user's question by sensitive words or custom tags, reduces the system's traffic load, is more secure, and is more practical.
[0135] See also Figure 6 This embodiment also discloses a specific solution of "generating a reply script based on the confidence scores corresponding to the recall question and each knowledge base standard question", which includes:
[0136] Step S601: Determine whether there is a confidence score greater than a rejection threshold among the confidence scores corresponding to each recall question in the recall question set and each knowledge base standard question.
[0137] After obtaining the confidence scores corresponding to each recall question in the recall question set and each knowledge base standard question, each confidence score is compared with a preset rejection threshold to determine whether there is a confidence score greater than the rejection threshold among the confidence scores.
[0138] When there is no confidence score greater than the rejection threshold, the generative intelligent dialogue unit is called to respond to the user question through the large model.
[0139] The generative intelligent dialogue unit conducts generative intelligent dialogue for user questions that are not recognized by the search-based intelligent dialogue unit. It mainly includes: indexing module, answer generator, and semi-automatic corpus trainer. The generative intelligent dialogue unit specifically includes:
[0140] Indexing module, see Figure 7 ,The indexing module is used to collect documents used by the large language model application (loading data), and ,divides the documents into suitable blocks through units such as data preprocessing, ,embedding model wrapper, and data converter, converts the data into vectors (data conversion ,vectors), and stores the vectors in the vector database (vector ,repository).
[0141] Generate an answer output to obtain user questions, convert them into text embeddings using a large language model, and use them to search the vector database to adapt the best matching document block. A generative model is used to take the current chat memory and the document blocks retrieved from the vector database as context input to generate the final answer.
[0142] Semi-automatic corpus trainer, see Figure 8 It uses the information extraction capability of the big model to obtain the original corpus, automatically disassembles the original corpus according to the source of knowledge, and forms initial training corpus such as standard questions, extended questions, and answers for manual annotation and subsequent screening, feeding back to the traditional model, thereby reducing the operating costs of the traditional model; then uses the fine-tuning capability of the big model to fine-tune the instructions, and uses the manually annotated corpus to strengthen the big model's knowledge reserve in the financial field, and further enhance the big model's service capabilities in the financial vertical field.
[0143] Step S602: When there is a confidence score greater than the rejection threshold, it is determined whether there is a confidence score greater than the trust threshold among the confidence scores corresponding to each recall question and each knowledge base standard question.
[0144] The trust threshold is greater than the rejection threshold. When the confidence scores corresponding to the various recall questions in the recall question set and the various knowledge base standard questions have confidence scores greater than the rejection threshold, continue to compare these confidence scores greater than the rejection threshold with the trust threshold to determine whether any of these confidence scores have confidence scores greater than the trust threshold.
[0145] Step S603: If there is a confidence score greater than the trust threshold, the reply words of the standard question of the knowledge base corresponding to the confidence score greater than the trust threshold are fed back to the user.
[0146] In this step, if only one confidence score is greater than the trust threshold, the reply words of the standard question of the knowledge base corresponding to the confidence score greater than the trust threshold are directly fed back to the user.
[0147] If there are multiple confidence scores greater than the trust threshold, the knowledge base standard questions corresponding to the confidence scores greater than the trust threshold can be fed back to the user, and corresponding reply words can be generated based on the knowledge base standard questions selected by the user.
[0148] Step S604: If there is no confidence score greater than the credible threshold, a knowledge base standard question corresponding to a confidence score between the rejection threshold and the credible threshold is fed back to the user so that the user can reselect a user question.
[0149] When there is no confidence score greater than the trust threshold, the knowledge base standard questions corresponding to the confidence scores between the rejection threshold and the trust threshold can also be fed back to the user, and then the corresponding reply words are generated based on the knowledge base standard questions selected by the user.
[0150] Step S605: When it is identified that the user has selected the standard knowledge base question, a reply to the standard knowledge base question selected by the user is fed back to the user.
[0151] This embodiment discloses an intelligent dialogue service device. For the specific working contents of each unit in the device, please refer to the contents of the above method embodiment.
[0152] The following describes an intelligent dialogue service device provided by an embodiment of the present invention. The intelligent dialogue service device described below and the intelligent dialogue service method described above can be referenced to each other.
[0153] See also Fig. 9 , the intelligent dialogue service device includes:
[0154] A question acquisition unit 10, used to acquire a user's question;
[0155] The screening unit 20 is used to determine whether the user's question contains sensitive words or custom tags; when the sensitive words or custom tags are contained, obtain and feed back to the user a reply script that matches the sensitive words or custom tags;
[0156] The question set construction unit 30 is used to segment the user's question sentence when it does not contain sensitive words or custom tags, and obtain a recall question set;
[0157] A standardization processing unit 40 is used to perform standardization processing on the recall question set to obtain word vectors and BERT vectors corresponding to the recall questions in the recall question set;
[0158] An edit distance model 50, used to calculate similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base using the edit distance model, recorded as word class scores;
[0159] A word vector model 60, used to calculate a similarity score between the word vector and a standard question in a knowledge base using the word vector model, recorded as a word vector score;
[0160] A BERT model 70, used to calculate a similarity score between the BERT vector and a standard question in a knowledge base, recorded as a neural network model score;
[0161] A confidence calculation unit 80, used to calculate the confidence scores of the recall questions and the knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores;
[0162] The reply unit 90 is used to generate a reply script based on the confidence scores corresponding to the recall question and each knowledge base standard question.
[0163] The present application also provides an electronic device in an embodiment. Fig.10 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Fig.10 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0164] like Fig.10As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes of the intelligent dialogue service method according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0165] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0166] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the intelligent dialogue service methods provided in the embodiments of the present application.
[0167] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any intelligent dialogue service method provided in the embodiment of the present application.
[0168] For the convenience of description, the above system is described as being divided into various modules according to their functions. Of course, when implementing the present invention, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0169] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.
[0170] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0171] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0172] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0173] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An intelligent dialogue service method, characterized in that: include: Get user questions; Determine whether the user's question contains sensitive words or custom tags; When the sensitive word or custom tag is included, a reply script matching the sensitive word or custom tag is obtained and fed back to the user; When no sensitive words or custom tags are included, the user's question is segmented to obtain a set of recalled questions; Standardizing the recall question set to obtain word vectors and BERT vectors corresponding to the recall questions in the recall question set; The similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base are calculated using an edit distance model, recorded as a word class score; The word vector model is used to calculate the similarity score between the word vector and the standard question in the knowledge base, which is recorded as the word vector score; The BERT model is used to calculate the similarity score between the BERT vector and the standard question of the knowledge base, which is recorded as the neural network model score; Calculating confidence scores of the recall questions and knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores; Based on the confidence scores corresponding to the recalled questions and each knowledge base standard question, a response script is generated.
2. The intelligent dialogue service method according to claim 1, characterized in that: Determining whether the user question contains sensitive words or custom tags includes: Use sensitive word filters to determine whether the user's question contains sensitive words through the sensitive word dictionary; When the sensitive words are not included, a punctuation filter is used to process the user question using a regular expression to filter the punctuation in the user question; A custom tag filter is used to determine whether the user question after filtering punctuation marks contains a custom tag based on the custom tag.
3. The intelligent dialogue service method according to claim 1, characterized in that: Segment the user's question to obtain a set of recalled questions, including: Preprocessing the user's question, wherein the preprocessing at least includes word segmentation processing; Based on the word segmentation results, a rough recall is performed in the knowledge base or index to obtain a set of recalled questions that match the user's question.
4. The intelligent dialogue service method according to claim 1, characterized in that: Calculating confidence scores of the recall questions and knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores, including: Based on the formula Y=X1×K1+ X2×K2+ X3×K3, the confidence scores Y of the recall questions and the knowledge base standard questions in the recall question set are calculated; Among them, X1 is the word class score, K1 is the word class weight, X2 is the word vector score, K2 is the word vector weight, X3 is the neural network model score, and K3 is the neural network model weight.
5. The intelligent dialogue service method according to claim 1, characterized in that: Based on the confidence scores of the recall question and each knowledge base standard question, a reply script is generated, including: Determine whether there is a confidence score greater than a rejection threshold among the confidence scores corresponding to each recall question and each knowledge base standard question in the recall question set; if there is a confidence score greater than the rejection threshold, determine whether there is a confidence score greater than a credible threshold among the confidence scores corresponding to each recall question and each knowledge base standard question; if there is a confidence score greater than the credible threshold, feed back to the user the reply words of the knowledge base standard question corresponding to the confidence score greater than the credible threshold; if there is no confidence score greater than the credible threshold, feed back to the user the knowledge base standard question corresponding to the confidence score between the rejection threshold and the credible threshold, so that the user can reselect the user question; When it is recognized that the user has selected the standard knowledge base question, the response words of the standard knowledge base question selected by the user are fed back to the user.
6. The intelligent dialogue service method according to claim 5, characterized in that: When there is no confidence score greater than the rejection threshold among the confidence scores corresponding to the various recall questions in the recall question set and the various knowledge base standard questions, the fine-tuned large model generates a speech to respond to the user question.
7. An intelligent dialogue service device, characterized in that: include: A question acquisition unit, used to acquire user questions; A screening unit, used to determine whether the user's question contains sensitive words or custom tags; When the sensitive word or custom tag is included, a reply script matching the sensitive word or custom tag is obtained and fed back to the user; The question set construction unit is used to segment the user's question sentence to obtain a recall question set when it does not contain sensitive words or custom tags; A standardization processing unit, used for performing standardization processing on the recall question set to obtain word vectors and BERT vectors corresponding to the recall questions in the recall question set; An edit distance model, used to calculate similarity scores between the recall questions in the recall question set and the standard questions in the knowledge base using the edit distance model, recorded as a word class score; A word vector model, used to calculate a similarity score between the word vector and a standard question in a knowledge base using the word vector model, recorded as a word vector score; A BERT model is used to calculate a similarity score between the BERT vector and a standard question in the knowledge base, which is recorded as a neural network model score; A confidence calculation unit, used to calculate the confidence scores of the recall questions and the knowledge base standard questions in the recall question set based on the word class scores, word vector scores, and neural network model scores; The reply unit is used to generate a reply script based on the confidence scores corresponding to the recall question and each knowledge base standard question.
8. A computer program product, characterized in that It includes computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the intelligent dialogue service method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that: The method comprises at least one processing device and a storage device connected to the processing device, wherein: The storage device is used to store computer programs; The processing device is used to execute the computer program so that the electronic device can implement the intelligent dialogue service method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the intelligent dialogue service method as described in any one of claims 1 to 6.