Interaction method and related equipment
By generating and processing enhanced query text, combined with multiple data modules, intelligent customer service robots can more accurately understand user intentions and provide more comprehensive answers, solving the problem that the existing technology cannot effectively integrate and utilize a wide range of knowledge resources.
Patent Information
- Application Number
- CN202411852312.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-05-06
AI Technical Summary
Existing intelligent customer service robots are unable to effectively integrate and utilize a wider range of knowledge resources, resulting in the inability to give accurate and comprehensive answers when dealing with problems that require cross-domain knowledge or in-depth expertise.
By obtaining the natural language query statement input by the user, a keyword list is formed and the first enhanced query text is generated. The first enhanced query text is processed using the preset model to generate the candidate reply text. Then, a second enhanced query text is generated using vectorization processing technology, and a target reply text is generated based on a plurality of preset data modules.
It realizes that intelligent customer service robots can understand user intentions more accurately, provide answers that are more in line with user needs, and can give more accurate and comprehensive answers when dealing with cross-domain knowledge or in-depth professional knowledge.
Smart Images

Figure CN119938824A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an interaction method and related equipment. Background Art
[0002] In today's information age, intelligent customer service robots have become an important bridge of communication between enterprises and customers. They can quickly respond to user queries and provide 24-hour uninterrupted service, greatly improving the user experience. Existing intelligent customer service robots have limitations in knowledge acquisition and utilization. They can usually only access limited data sources, such as predefined answer libraries, simple database queries, or pre-trained single large models, and cannot effectively integrate and utilize a wider range of knowledge resources. As a result, they are often unable to give accurate and comprehensive answers when dealing with problems that require cross-domain knowledge or deep expertise. Summary of the invention
[0003] In view of this, the purpose of the present disclosure is to provide an interaction method and related devices.
[0004] Based on the above objectives, the present disclosure provides an interaction method, including:
[0005] Acquire and form a keyword list based on a query statement input by a user; wherein the query statement is a natural language;
[0006] Generate a first enhanced query text according to the keyword list and the query statement;
[0007] Processing the first enhanced query text using at least one preset model to generate candidate answer texts;
[0008] Generate a second enhanced query text using vectorization processing technology based on the candidate answer text;
[0009] Based on at least one preset data module, a target reply text of the second enhanced query text is generated and outputted.
[0010] Based on the same inventive concept, an embodiment of the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, an interaction method as described in any one of the above is implemented.
[0011] Based on the same inventive concept, an embodiment of the present disclosure further provides a computer program product, including computer program instructions. When the computer program instructions are executed on a computer, the computer executes any of the above-mentioned interaction methods.
[0012] From the above, it can be seen that the interactive method and related devices provided by the embodiments of the present disclosure obtain and form a keyword list based on the query statement input by the user; wherein the query statement is a natural language; based on the keyword list and the query statement, a first enhanced query text is generated to improve the accuracy and relevance of the query; further, the first enhanced query text is processed using at least one preset model to generate a candidate reply text; based on the candidate reply text, a second enhanced query text is generated using vectorization processing technology, so that the customer service robot can more accurately understand the user's intention and provide answers that are more in line with the user's needs; finally, based on at least one preset data module, a target reply text for the second enhanced query text is generated and output, so as to integrate multiple preset data modules and enrich the knowledge base of the customer service robot, so that it can give more accurate and comprehensive answers when dealing with cross-domain knowledge or deep professional knowledge problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0014] Figure 1 A flow chart showing an interactive method provided by an embodiment of the present disclosure is shown;
[0015] Figure 2 A schematic diagram of a process for generating a first enhanced query text provided by an embodiment of the present disclosure is shown;
[0016] Figure 3 A schematic diagram of a process for generating candidate reply texts provided by an embodiment of the present disclosure is shown;
[0017] Figure 4 A schematic diagram of a process for generating a second enhanced query text provided by an embodiment of the present disclosure is shown;
[0018] Figure 5 A code for generating a second enhanced query text provided by an embodiment of the present disclosure is shown;
[0019] Figure 6 A schematic diagram showing a process of generating a target answer text of the second enhanced query text provided by an embodiment of the present disclosure;
[0020] Figure 7 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0021] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0022] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0023] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0024] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0025] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0026] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0027] As described in the background technology section, intelligent customer service robots of related technologies are unable to effectively integrate and utilize a wider range of knowledge resources, resulting in them often being unable to provide accurate and comprehensive answers when dealing with issues that require cross-domain knowledge or deep expertise.
[0028] In view of this, the embodiment of the present disclosure provides an interactive method and related devices. The interactive method uses a customer robot to obtain and form a keyword list based on a query statement input by a user; wherein the query statement is a natural language; a first enhanced query text is generated based on the keyword list and the query statement to improve the accuracy and relevance of the query; further, the first enhanced query text is processed using at least one preset model to generate a candidate reply text; based on the candidate reply text, a second enhanced query text is generated using vector processing technology, so that the customer service robot can more accurately understand the user's intention, thereby providing an answer that is more in line with the user's needs; finally, based on at least one preset data module, a target reply text of the second enhanced query text is generated and output, so as to achieve the integration of multiple preset data modules, enrich the knowledge base of the customer service robot, and enable it to give more accurate and comprehensive answers when dealing with cross-domain knowledge or deep professional knowledge problems.
[0029] In order to make the technical solution of the present disclosure clearer and easier to understand, the interaction method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0030] See also Figure 1 The flow chart of the interaction method shown is as follows. The interaction method can be applied to a customer service robot, and specifically includes:
[0031] S101: Acquire and form a keyword list based on a query statement input by a user; wherein the query statement is a natural language.
[0032] Here, the user can input a query statement through the interactive interface, such as "I want to find a Chinese restaurant in Beijing that is moderately priced and well-reviewed". It should be noted that the query statement can be input in text form or in voice form. If it is input in voice form, the voice can be converted into text by means of a voice conversion algorithm, which is not limited in the present disclosure.
[0033] In some embodiments, the method of forming a keyword list based on a query statement includes:
[0034] First, the query is preprocessed, which may be performed using natural language processing (NLP) tools (such as Natural Language Toolkit, TextBlob, etc.), and may specifically include removal of stop words, punctuation normalization, and spelling correction.
[0035] Next, a word segmentation algorithm is used to segment the preprocessed query statement to form at least one word segment. Using the word segmentation algorithm, a continuous text string can be split into independent words or phrases.
[0036] It should be noted that those skilled in the art can select a suitable word segmentation algorithm, such as the forward maximum matching method, the backward maximum matching method, etc., and the present disclosure does not limit this.
[0037] Then, according to the preset part-of-speech tagging method, the part of speech of each word segment is determined; here, the purpose of part-of-speech tagging is to determine the grammatical role of each word segment in the sentence, such as noun, verb, adjective, etc. The preset part-of-speech tagging method can be a dictionary matching method, a hidden Markov model (HMM), a recurrent neural network (RNN), etc., and the present disclosure does not limit this.
[0038] By determining the part of speech of each word segment, it helps to identify the word segments with key parts of speech.
[0039] Finally, according to each of the word segments and their parts of speech, a keyword extraction algorithm, such as the TF-IDF algorithm, is used to screen and obtain keywords and form a keyword list. It should be understood that the keywords are representative and can reflect the user's query intention.
[0040] In some embodiments, forming the keyword list may include optimization steps, such as removing duplicate keywords, merging synonyms, and adjusting the weights of keywords according to the context, etc., and finally generating the keyword list.
[0041] To facilitate the understanding of those skilled in the art of the above method for forming the keyword list, the present disclosure takes the query statement "I want to find a Chinese restaurant located in Beijing, with moderate prices and good reviews." as an example and illustrates as follows:
[0042] Using natural language processing tools to preprocess the received query statement, including removing stop words (such as "I", "of", "want", etc.), punctuation normalization (such as replacing Chinese commas with English commas, etc.) and spelling correction (such as correcting typos, etc.). The processed query statement may become: "Find a Chinese restaurant located in Beijing with moderate prices and good reviews".
[0043] Next, a word segmentation algorithm is used to segment the preprocessed query statement. A rule-based word segmentation algorithm or a machine learning-based word segmentation algorithm can be used. For the above processed query statement, the word segmentation result may be: "Find / Located / In Beijing / Price / Moderate / Evaluation / Good / Chinese restaurant".
[0044] Then, based on the word segmentation results, the part-of-speech tagging method is used to tag each word and identify the keyword type. For the above word segmentation results, the part-of-speech tagging may be: "Find a Chinese restaurant / n with a location / vBeijing / n moderate price / n good review / n". Among them, "n" represents a noun, "v" represents a verb, and "a" represents an adjective.
[0045] Next, a keyword extraction algorithm is used to filter out keywords from the segmented text. A statistical keyword extraction algorithm, such as TF-IDF, or a machine learning-based keyword extraction algorithm can be used. For the above text after part-of-speech tagging, the results of keyword extraction may be: "Beijing", "moderate price", "good reviews", and "Chinese restaurant".
[0046] Finally, the keywords are further optimized, including removing duplicate keywords (if any), merging synonyms (such as merging "restaurant" and "restaurant" into the same keyword), and adjusting the weight of keywords according to the context. For the results of the above keyword extraction, since there are no duplicate keywords or synonyms, the weight of the keywords is adjusted directly according to the context. For example, according to the user's query intent, "Chinese restaurant" may be the most important keyword, so it can be given the highest weight; the optimized keyword list may be: "Chinese restaurant (highest weight)", "Beijing", "moderately priced", and "good reviews".
[0047] S103: Generate a first enhanced query text according to the keyword list and the query statement.
[0048] In some embodiments, the keyword list and the query statement are combined to generate a first enhanced query text, which includes the original information of the user's query and the extracted keywords, and helps the subsequent model to understand the user's intention more accurately.
[0049] Exemplarily, the method of fusing the keyword list and the query statement may be a simple string concatenation, a template-based fusion or a semantic fusion method, which is not limited in the present disclosure.
[0050] Figure 2 FIG. 2 is a flow chart of generating a first enhanced query text provided by an embodiment of the present disclosure. Figure 2 As shown, the step of generating the first enhanced query text includes:
[0051] S201: Determine the weight of each keyword in the keyword list according to a preset algorithm.
[0052] Exemplarily, the preset algorithm is the TF-IDF algorithm, and the weight is the TF-IDF value. TF represents the frequency of the keyword in the query text, and IDF represents the inverse document frequency of the keyword in the entire corpus. The TF-IDF value of each keyword is calculated by the following formula:
[0053]
[0054] Among them, ω represents the keyword, TF(ω) represents the frequency of the keyword ω in the query text, N represents the total number of documents in the corpus, and DF(ω) represents the number of documents containing the keyword ω.
[0055] S203: Determine at least one core keyword in the keyword list according to the weight and the preset rule. Here, the preset rule may be to select N keywords with higher ranking as core keywords. Here, N may be 1, 2, 3, 4, etc., which is specifically determined by the preset rule and is not limited in the present disclosure.
[0056] Exemplarily, the keywords are sorted according to the calculated TF-IDF values, and the top three keywords with higher weights are selected as core keywords.
[0057] S205: Generate the first enhanced query text according to the at least one core keyword and the query statement.
[0058] Exemplarily, the core keywords are integrated with the query statement. The specific integration method may include: inserting the core keywords into the corresponding position of the query statement in an appropriate manner, or splicing the core keywords with the query statement to form an enhanced query text containing the core keywords; performing grammatical and semantic checks on the enhanced query text, and after the check is completed, outputting a first enhanced query text.
[0059] This disclosure continues to use the query sentence "I want to find a Chinese restaurant located in Beijing with moderate prices and good reviews" as an example to illustrate the method of generating the first enhanced query text:
[0060] Based on S101, according to “I want to find a Chinese restaurant located in Beijing that is moderately priced and well-reviewed”, the keyword list is determined to be [“Beijing”, “moderately priced”, “well-reviewed”, “Chinese restaurant”].
[0061] Calculate the TF-IDF value for each keyword in the keyword list.
[0062] For example, assume that there are 1000 documents in the corpus and the DF value of each keyword has been calculated. The specific calculation is as follows:
[0063] For the keyword "Beijing", assuming that it appears once in the query statement and there are 200 documents containing it in the entire corpus, then TF(Beijing) = 1, DF(Beijing) = 200, N = 1000, so TF-IDF(Beijing) = 1×log(1000 / 200) = 1×log(5)≈0.693.
[0064] Similarly, the TF-IDF values of other keywords can be calculated. Assume that the results are: TF-IDF (reasonable price) = 0.5, TF-IDF (good reviews) = 0.7, and TF-IDF (Chinese restaurant) = 0.8.
[0065] Sort the keywords according to the calculated TF-IDF value, and select the top N keywords with higher weights as core keywords; assuming N = 3, the core keywords are ["Chinese restaurant", "good reviews", "Beijing"] (sorted from high to low by TF-IDF value).
[0066] The core keywords are integrated with the query statement. The specific integration methods include: inserting the core keywords into the corresponding position of the query statement in an appropriate manner, or splicing the core keywords with the query statement to form an enhanced query text containing the core keywords; in order to maintain the naturalness of the query, the insertion method is selected, and the order and context of the keywords are taken into consideration. The integrated query text is: "I want to find a Chinese restaurant in Beijing with good reviews and moderate prices." The enhanced query text is checked for syntax and semantics. After the check is completed, the first enhanced query text is output.
[0067] S105: Processing the first enhanced query text using at least one preset model to generate candidate answer texts. It should be understood that the candidate answer texts may include one answer text or multiple answer texts.
[0068] In some embodiments, at least one preset model includes a classification model, a first large model, and a second large model.
[0069] Here, the classification model can be used to identify the category of user queries, such as sub-classification according to the category or intent of the query, so as to facilitate calling different downstream models to answer based on the query category, which helps to generate answers more accurately. This model uses a multi-classification algorithm to achieve high-precision category recognition by training and learning the features of different query categories.
[0070] The first large model can be a pre-trained general open source large language model, which is used to capture the semantic information of the query, is responsible for processing general question-answering tasks, and can directly generate reasonable answers. This model is built on the general large language model. Through the training of a large corpus, it has extensive knowledge coverage and strong semantic understanding capabilities. When the user query belongs to the category of general knowledge, the first large model can directly parse the query intent and output the corresponding answer. For example, when a user asks "What's the weather like today?", the basic large model can directly answer "Today's weather is sunny and the temperature is 25 degrees" based on pre-trained knowledge and context understanding.
[0071] The second large model may be a NL2SQL large model, which may convert natural language queries into SQL queries in order to retrieve relevant information from a database.
[0072] Exemplarily, the NL2SQL large model adopts a sequence-to-sequence architecture and combines the attention mechanism to encode a natural language query (such as the first enhanced query text mentioned above) into an intermediate representation and then decode it into a SQL statement. The specific process includes:
[0073] Encoding stage: The first recurrent neural network (RNN) model is used to encode the natural language query into a hidden state sequence. Here, the first RNN model reads the query text word by word, integrates the information of each word into the hidden state, and forms a hidden state sequence that contains all the information of the query text. This process ensures that the model can fully understand the semantics and context of the query text.
[0074] Decoding stage: According to the hidden state sequence, the second RNN model is used to gradually generate various parts of the SQL statement, including the SELECT clause, FROM clause, and WHERE clause. Here, the second RNN model gradually outputs various parts of the SQL statement based on the information in the hidden state sequence to form a complete SQL query statement, ensuring that the generated SQL statement conforms to the grammatical specifications and can accurately express the query intent.
[0075] Attention mechanism: During the decoding process, the attention mechanism is introduced to enable the model to focus on the key information in the query text that is related to the currently generated part. Here, the attention mechanism provides additional contextual information to the model by calculating the correlation between each state in the hidden state sequence and the currently generated part, which helps the model to more accurately reference the key information in the query text when generating SQL statements, thereby improving the accuracy and completeness of SQL statements.
[0076] Based on the above preset model, Figure 3 FIG. 2 is a flow chart showing a process of generating candidate reply texts provided by an embodiment of the present disclosure. Figure 3As shown, the steps of generating candidate reply texts specifically include:
[0077] S301: Based on the classification model, identify the type of the first enhanced query text; here, the type can be a first-category query, such as general question and answer; or a second-category query, such as a database query.
[0078] S303: In response to determining that the first enhanced query text is a first type of query, such as a general question and answer, calling the first large model (such as a pre-trained general open source large language model) to generate the candidate reply text.
[0079] S305: In response to determining that the first enhanced query text is a second type of query, such as a database query, calling the second large model (such as the NL2SQL large model) to generate the candidate reply text.
[0080] Taking the user query "Query the product with the highest sales" as an example, the system first identifies that the query belongs to the database query category through the classification model. Subsequently, the NL2SQL large model is called for processing. In the encoding stage, the NL2SQL large model uses the first RNN model to encode the query text into a hidden state sequence. In the decoding stage, according to the hidden state sequence, the various parts of the SQL statement are gradually generated, such as "SELECT product name, sales FROM sales records WHERE sales = (SELECT MAX (sales) FROM sales records)". During the generation process, the attention mechanism helps the model focus on the key information "highest sales" in the query text to ensure that the generated SQL statement is accurate. Finally, the system executes the generated SQL statement and returns the product information with the highest sales as the answer.
[0081] S107: Generate a second enhanced query text based on the candidate answer text using vector processing technology. Rewriting the candidate answer text using vector processing technology (such as sentence encoding technology) helps optimize the query expression and improve the accuracy of subsequent retrieval.
[0082] Figure 4 A schematic diagram of a process for generating a second enhanced query text provided by an embodiment of the present disclosure is shown. Figure 5 A code for generating a second enhanced query text provided by an embodiment of the present disclosure is shown. Figure 4 and Figure 5 As shown, the step of generating the second enhanced query text includes:
[0083] S401: Preprocess the candidate reply text; here, preprocessing can be to remove irrelevant information and redundant content, including removing stop words, punctuation marks, special characters, etc.
[0084] S403: Using vectorization processing technology, convert the preprocessed candidate reply text into a vector representation; illustratively, using word embedding technology, such as Word2Vec, to map each word into a high-dimensional vector space. Word embedding technology can be used to convert text data into a numerical form that can be understood by a computer. Here, each candidate reply in the candidate reply text is converted into a vector representation.
[0085] S405: Perform cluster analysis on the vector representation to obtain at least one topic, where the topic can be either a main topic or a subtopic. Exemplarily, the clustering algorithm can select a K-means algorithm to divide the candidate reply text into different clusters according to the similarity between the vectors. Each cluster represents a topic or a subtopic, and the main topic and subtopic in the candidate reply text can be identified through cluster analysis.
[0086] S407: Generate corresponding query rewriting statements based on the at least one topic;
[0087] For example, query rewriting statements can be generated by template matching or rule generation. First, a set of query rewriting templates or rules are defined, and then the templates are filled or the rules are applied to generate query rewriting statements based on the content of each topic and subtopic. The generated query rewriting statements should be able to accurately reflect the core content of the topic and subtopic and conform to the habits of natural language queries.
[0088] S409: verifying the query rewriting statement, and using the verified query rewriting statement as the second enhanced query text.
[0089] Here, validation can include syntax validation and semantic validation. Syntax validation mainly checks whether the sentence structure of the query rewriting statement conforms to grammatical rules, such as whether the subject, predicate and object are complete, whether the tense is correct, etc. Semantic validation checks whether the query rewriting statement can accurately express the intent of the query statement and whether there is any ambiguity or misunderstanding.
[0090] The query rewrite statement that passes the verification is used as the second enhanced query text for subsequent data module recall and optimal answer selection.
[0091] Figure 5 The Python code for generating the second enhanced query text is shown. It should be noted that the above Python code is a simplified example for showing the process of how to generate the second enhanced query text, which specifically includes:
[0092] Data preparation: An example candidate answer list candidate_answers (corresponding to the candidate response text of the present disclosure) is provided.
[0093] S401 Preprocessing: A preprocess function is defined to clean the text, including removing punctuation marks, special characters and stop words, and the preprocess function is used to process each candidate answer to obtain a cleaned answer list preprocessed_answers.
[0094] S403 vectorization: Use TfidfVectorizer to convert the cleaned answers into TF-IDF vector representation. This is a common text vectorization method that can take into account word frequency and inverse document frequency to better reflect the importance of words.
[0095] S405 Clustering Analysis: Use the KMeans clustering algorithm to divide the vectorized answers into several clusters. Assume that there are 2 clusters, so n_clusters is set to 2. After clustering, each answer is assigned a cluster label to indicate which cluster it belongs to.
[0096] S407 Query Rewriting: Select an answer from each cluster as a query rewriting question. In actual applications, more complex logic is required to generate query rewriting questions, which will not be listed here.
[0097] S409 Finally, output the generated second enhanced query text.
[0098] S109: Based on at least one preset data module, generate and output a target response text for the second enhanced query text.
[0099] In some embodiments, the at least one preset data module includes a system database module, a document vector database module and a business knowledge graph module.
[0100] The system database module stores the basic information and business data of the enterprise. It should be understood that different enterprises correspond to different system database modules, and the present disclosure does not limit this.
[0101] The document vector database module stores vector representations of unstructured documents for fast retrieval.
[0102] The business knowledge graph module stores knowledge such as entities, relationships, and attributes in the domain. By retrieving information related to the second enhanced query text in these data modules, a set of more accurate and comprehensive candidate answers can be generated.
[0103] The business knowledge graph module can collect information from multiple data sources and use natural language processing technology to identify entities in the data and the relationships between entities; through entity connections, the identified entities are associated with the entities in the initial knowledge graph, and an association network between entities is constructed to form an updated knowledge graph, thereby continuously improving the knowledge graph.
[0104] Optionally, the business knowledge graph can be stored in a graph database, where nodes represent entities and edges represent relationships between entities. Each node and edge can contain rich attribute information, such as the name, type, description, etc. of the entity, as well as the type and weight of the relationship, etc. The storage structure of the graph database makes it easy to traverse the knowledge graph and find entities and relationships related to the query.
[0105] Exemplarily, the process of building a business knowledge graph includes:
[0106] First, collect information from multiple data sources, including internal business systems, external data providers, public databases and documents. Collect relevant information into the system through data crawling, API interface calls or data purchase.
[0107] Next, natural language processing technology is used to process the collected data to identify entities in the data, such as product name, customer name, business type, etc., as well as the relationships between entities, such as the product belongs to a certain category, the customer purchased a certain product, etc.
[0108] Then, after identifying the entities and relationships, the identified entities are associated with the entities in the initial knowledge graph through entity connection technology. If the entity does not exist in the initial knowledge graph, it is added to the knowledge graph as a new node, and based on the identified relationships, an association network between entities is constructed in the knowledge graph to form a complete knowledge graph.
[0109] Taking e-commerce business as an example, the business knowledge graph module can build a knowledge graph containing entities such as products, customers, and orders. By collecting data from the e-commerce system, entities such as product name, customer name, order number, and relationships such as a product belongs to a certain category and a customer purchased a certain product can be identified. Then, these entities and relationships are added to the knowledge graph to form a knowledge graph for e-commerce business. When a user queries questions related to e-commerce business, such as "which products a certain customer purchased", the business knowledge graph module can traverse the knowledge graph, find order and product information related to the customer, and generate corresponding answers. In this way, the business knowledge graph module can provide more accurate and comprehensive business information, and improve the response quality and user satisfaction of the intelligent customer service robot.
[0110] Based on the above data modules, Figure 6 FIG. 2 is a flow chart showing a method of generating a target answer text of the second enhanced query text provided by an embodiment of the present disclosure. Figure 6 As shown, the steps of generating the target response text include:
[0111] S601: Calling the at least one preset data module to process the second enhanced query text to generate at least one pre-selected reply text.
[0112] It should be noted that each data module contains different data types and contents, and parses and processes the query text respectively, and can generate multiple pre-selected reply texts.
[0113] Exemplarily, the system database module: retrieves relevant information from the database based on the keywords in the second enhanced query text, and generates a pre-selected reply text.
[0114] Document vector database module: uses vector search technology to search for documents similar to the second enhanced query text in the document library, and extracts information from them to generate a pre-selected response text.
[0115] Business knowledge graph module: Utilizes the entities and relationships in the knowledge graph to perform semantic understanding and reasoning on the second enhanced query text, and generates pre-selected response text based on the knowledge graph.
[0116] It should be understood that the at least one preset data module includes but is not limited to a system database module, a document vector database module and a business knowledge graph module.
[0117] S602: Score the at least one pre-selected reply text, and select a pre-selected reply text from the at least one pre-selected reply text as the target reply text based on the score.
[0118] In order to select the best answer from multiple pre-selected answer texts, the pre-selected answer text generated by each data module can be scored.
[0119] In some embodiments, the scoring mechanism includes at least one of a probability mechanism and a similarity mechanism.
[0120] The probability mechanism refers to using the probability distribution of the model output to select the reply text with the highest probability as the target reply text.
[0121] The similarity mechanism is to calculate the similarity between the vector representation of the pre-selected answer text and the second enhanced query text. The higher the similarity, the more relevant the pre-selected answer text is to the question and the more likely it is to be the correct answer; the answer with the highest similarity is selected as the target answer text.
[0122] Comprehensive score: Combine probability and similarity to give a weighted score to the pre-selected reply. For example, you can set a weight coefficient to weight the probability and similarity scores to get a comprehensive score.
[0123] In some embodiments, the step of scoring the at least one pre-selected reply text and selecting a pre-selected reply text from the at least one pre-selected reply text as the target reply text based on the score specifically includes:
[0124] In response to determining that the scoring mechanism is a probability mechanism, determining the probability of each pre-selected reply text using a preset probability model, and selecting the pre-selected reply text with the highest probability as the target reply text;
[0125] In response to determining that the scoring mechanism is a similarity mechanism, calculating the similarity between each pre-selected answer text and the vector representation of the second enhanced query text, and selecting the pre-selected answer text with the highest similarity as the target answer text;
[0126] In response to determining that the scoring mechanism is a probability mechanism and a similarity mechanism, the probability and similarity of each pre-selected reply text are calculated, and the pre-selected reply text with the highest weighted score of probability and similarity is selected as the target reply text.
[0127] The target reply text is output to the user (such as interface display, voice playback, etc.), and the user's further query statements can be received, thereby realizing a closed loop of interaction with the user, enabling the intelligent customer service robot to continuously and accurately respond to the user's query needs.
[0128] It can be seen that the interactive method provided by the embodiment of the present disclosure breaks the limitation that the traditional intelligent customer service robot only relies on limited data sources. By integrating multiple data modules such as system database, document vector database and business knowledge graph, it realizes the effective integration and utilization of a wide range of knowledge resources, which not only greatly enriches the knowledge base of the robot, but also enables it to give more accurate and comprehensive answers when dealing with cross-domain knowledge or deep professional knowledge. The user query is segmented and keyword extracted by natural language processing tools, and the first enhanced query text is generated in combination with the query statement, which improves the accuracy and relevance of the query. Further, the candidate reply text is rewritten by vectorization technology, the query expression is optimized, and the second enhanced query text is generated, which helps the robot to understand the user's intention more accurately, thereby providing answers that are more in line with user needs. The interactive method disclosed in the present disclosure also has flexible question rewriting and query optimization capabilities, and can dynamically adjust the query strategy according to user feedback and context information, significantly improving the fluency and accuracy of the interaction. By calling the basic large model, classification model and NL2SQL large model to process the enhanced query text, high-quality candidate answers can be quickly generated. Combined with the recall and comparison screening mechanism of multiple data modules, it ensures that the best answer is ultimately provided to users, thus improving the accuracy of the answer.
[0129] It should be noted that the method of the embodiment of the present disclosure can be performed by a single device, such as a computer or a server. The method of the present embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present disclosure, and the multiple devices will interact with each other to complete the described method.
[0130] It should be noted that the above describes some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0131] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides an interaction method.
[0132] refer to Figure 1 , the interaction method is applied to a customer service robot, including:
[0133] S101: Obtaining and forming a keyword list based on a query statement input by a user; wherein the query statement is a natural language;
[0134] S103: Generate a first enhanced query text according to the keyword list and the query statement;
[0135] S105: Processing the first enhanced query text using at least one preset model to generate candidate answer texts;
[0136] S107: Generate a second enhanced query text using vectorization processing technology according to the candidate answer text;
[0137] S109: Based on at least one preset data module, generate and output a target response text for the second enhanced query text.
[0138] In some embodiments, the step of forming a keyword list based on the query statement input by the user specifically includes:
[0139] Preprocessing the query statement;
[0140] Using a word segmentation algorithm to segment the preprocessed query sentence to form at least one word segmentation;
[0141] Determine the part of speech of each word according to the preset part-of-speech tagging method;
[0142] According to each of the segmented words and their parts of speech, a keyword extraction algorithm is used to screen out keywords and form a keyword list.
[0143] In some embodiments, Figure 2 As shown, the step of generating a first enhanced query text according to the keyword list and the query statement specifically includes:
[0144] S201: Determine the weight of each keyword in the keyword list according to a preset algorithm;
[0145] S203: Determine at least one core keyword in the keyword list according to the weight and preset rules;
[0146] S205: Generate the first enhanced query text according to the at least one core keyword and the query statement.
[0147] In some embodiments, the at least one preset model includes a classification model, a first large model, and a second large model; Figure 3 As shown, the processing of the first enhanced query text by using at least one preset model to generate candidate answer texts specifically includes:
[0148] S301: The classification model identifies the type of the first enhanced query text;
[0149] S303: In response to determining that the first enhanced query text is a first-category query, calling the first large model to generate the candidate answer text;
[0150] S305: In response to determining that the first enhanced query text is a second-category query, calling the second large model to generate the candidate answer text.
[0151] In some embodiments, Figure 4 As shown, the step of generating a second enhanced query text using vectorization processing technology based on the candidate answer text specifically includes:
[0152] S401: Preprocessing the candidate reply text;
[0153] S403: using vectorization processing technology, converting the pre-processed candidate reply text into a vector representation;
[0154] S405: performing cluster analysis on the vector representation to obtain at least one theme;
[0155] S407: Generate corresponding query rewriting statements based on the at least one topic;
[0156] S409: verifying the query rewriting statement, and using the verified query rewriting statement as the second enhanced query text.
[0157] In some embodiments, Figure 6 As shown, the step of generating and outputting the target answer text of the second enhanced query text based on at least one preset data model specifically includes:
[0158] S601: calling the at least one preset data module to process the second enhanced query text to generate at least one pre-selected answer text;
[0159] S602: Score the at least one pre-selected reply text, and select a pre-selected reply text from the at least one pre-selected reply text as the target reply text based on the score.
[0160] In some embodiments, the scoring mechanism includes at least one of a probability mechanism and a similarity mechanism;
[0161] The step of scoring the at least one pre-selected answer text and selecting a pre-selected answer text from the at least one pre-selected answer text as the target answer text based on the score specifically includes:
[0162] In response to determining that the scoring mechanism is a probability mechanism, determining the probability of each pre-selected reply text using a preset probability model, and selecting the pre-selected reply text with the highest probability as the target reply text;
[0163] In response to determining that the scoring mechanism is a similarity mechanism, calculating the similarity between each pre-selected answer text and the vector representation of the second enhanced query text, and selecting the pre-selected answer text with the highest similarity as the target answer text;
[0164] In response to determining that the scoring mechanism is a probability mechanism and a similarity mechanism, the probability and similarity of each pre-selected reply text are calculated, and the pre-selected reply text with the highest weighted score of probability and similarity is selected as the target reply text.
[0165] In some embodiments, the at least one preset data module includes a system database module, a document vector database module and a business knowledge graph module.
[0166] The interactive method of the above embodiment has the beneficial effects of the above method embodiments, which will not be described in detail here.
[0167] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the interaction method described in any of the above embodiments is implemented.
[0168] Figure 7 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0169] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0170] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0171] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0172] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0173] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0174] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0175] The electronic device of the above embodiment is used to implement the corresponding interaction method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0176] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present disclosure also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the interactive method described in any of the above embodiments.
[0177] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0178] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute the interactive method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0179] Based on the same inventive concept, corresponding to the interaction method described in any of the above embodiments, the present disclosure also provides a computer program product, which includes computer program instructions. In some embodiments, the computer program instructions can be executed by one or more processors of a computer so that the computer and / or the processor executes the interaction method. Corresponding to the execution subject corresponding to each step in each embodiment of the interaction method, the processor that executes the corresponding step may belong to the corresponding execution subject.
[0180] The computer program product of the above embodiment is used to enable the computer and / or the processor to execute the interaction method described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0181] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Based on the concept of the present disclosure, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present disclosure as described above, which are not provided in detail for the sake of simplicity.
[0182] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present disclosure difficult to understand, the known power / ground connections to the integrated circuit (IC) chips and other components may or may not be shown in the provided figures. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present disclosure difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present disclosure will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present disclosure, it is apparent to those skilled in the art that the embodiments of the present disclosure can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0183] Although the present disclosure has been described in conjunction with specific embodiments of the present disclosure, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0184] The embodiments of the present disclosure are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. An interactive method, characterized in that: include: Acquire and form a keyword list based on a query statement input by a user; wherein the query statement is a natural language; Generate a first enhanced query text according to the keyword list and the query statement; Processing the first enhanced query text using at least one preset model to generate candidate answer texts; Generate a second enhanced query text using vectorization processing technology based on the candidate answer text; Based on at least one preset data module, a target reply text of the second enhanced query text is generated and outputted.
2. The interactive method according to claim 1, characterized in that: The step of forming a keyword list based on the query statement input by the user specifically includes: Preprocessing the query statement; Using a word segmentation algorithm to segment the preprocessed query sentence to form at least one word segmentation; Determine the part of speech of each word according to the preset part-of-speech tagging method; According to each of the segmented words and their parts of speech, a keyword extraction algorithm is used to screen out keywords and form a keyword list.
3. The interactive method according to claim 1, characterized in that: The step of generating a first enhanced query text according to the keyword list and the query statement specifically includes: Determine the weight of each keyword in the keyword list according to a preset algorithm; Determine at least one core keyword in the keyword list according to the weight and preset rules; The first enhanced query text is generated according to the at least one core keyword and the query statement.
4. The interactive method according to claim 1, characterized in that: The at least one preset model includes a classification model, a first large model, and a second large model; the step of processing the first enhanced query text using the at least one preset model to generate a candidate answer text specifically includes: Based on the classification model, identifying the type of the first enhanced query text; In response to determining that the first enhanced query text is a first-category query, calling the first large model to generate the candidate answer text; In response to determining that the first enhanced query text is a second-category query, the second large model is called to generate the candidate answer text.
5. The interactive method according to claim 1, characterized in that: The step of generating a second enhanced query text using a vectorization processing technology based on the candidate answer text specifically includes: Preprocessing the candidate reply text; Using vectorization processing technology, the pre-processed candidate reply text is converted into a vector representation; Performing cluster analysis on the vector representation to obtain at least one theme; Based on the at least one topic, respectively generate corresponding query rewrite statements; The query rewriting statement is verified, and the verified query rewriting statement is used as the second enhanced query text.
6. The interactive method according to claim 1, characterized in that: The step of generating and outputting a target answer text of the second enhanced query text based on at least one preset data model specifically includes: Calling the at least one preset data module to process the second enhanced query text to generate at least one pre-selected answer text; The at least one pre-selected reply text is scored, and a pre-selected reply text is selected from the at least one pre-selected reply text as the target reply text based on the score.
7. The interactive method according to claim 6, characterized in that: The scoring mechanism includes at least one of a probability mechanism and a similarity mechanism; The step of scoring the at least one pre-selected answer text and selecting a pre-selected answer text from the at least one pre-selected answer text as the target answer text based on the score specifically includes: In response to determining that the scoring mechanism is a probability mechanism, determining the probability of each pre-selected reply text using a preset probability model, and selecting the pre-selected reply text with the highest probability as the target reply text; In response to determining that the scoring mechanism is a similarity mechanism, calculating the similarity between each pre-selected answer text and the vector representation of the second enhanced query text, and selecting the pre-selected answer text with the highest similarity as the target answer text; In response to determining that the scoring mechanism is a probability mechanism and a similarity mechanism, the probability and similarity of each pre-selected reply text are calculated, and the pre-selected reply text with the highest weighted score of probability and similarity is selected as the target reply text.
8. The interactive method according to claim 1, characterized in that: The at least one preset data module includes a system database module, a document vector database module and a business knowledge graph module.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, characterized in that: The processor implements the interaction method according to any one of claims 1 to 8 when executing the computer program.
10. A computer program product, characterized in that The method comprises computer program instructions, which, when executed on a computer, enable the computer to execute the interactive method according to any one of claims 1 to 8.
Citation Information
Cited By
Query statement generation method and system and storage medium
CN120162428A