Intelligent reply method and terminal
By combining joint word vector encoding and target topic knowledge graph, the accuracy problem of intelligent replies to long texts is solved, and efficient intelligent replies are achieved in app and customer service scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAMEN MEIYA PICO INFORMATION CO LTD
- Filing Date
- 2022-07-22
- Publication Date
- 2026-07-31
AI Technical Summary
Existing intelligent reply methods struggle to achieve accurate intelligent replies when faced with large amounts of text, especially in app and customer service scenarios. The end-to-end models are rigid, and natural language models cannot generate effective replies.
The joint word vector encoding is determined by using a preset external word vector model and a preset local word vector model. Combined with the trained classification model and the target topic knowledge graph, the response content is generated by extracting keywords.
It improves the accuracy and precision of long text processing, enabling the generation of effective responses to large blocks of text. It is suitable for app and customer service scenarios, providing a professional and user-friendly interactive experience.
Smart Images

Figure CN115329037B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to an intelligent reply method and terminal. Background Technology
[0002] Intelligent responses are generally generated based on question-and-answer systems, using a question-and-answer format to accurately pinpoint the user's required knowledge and provide personalized information services through interaction. However, their application scenarios are limited. In scenarios such as apps and customer service where users input large amounts of text, or where responses are generated based on large amounts of text, they often fail to achieve the desired results. Existing intelligent responses are mainly divided into two categories: one is an end-to-end model based on deep learning, trained on historical corpora to respond promptly to dialogue text; however, due to stiff dialogue, the human-computer interaction experience is poor, and open dialogue cannot be achieved. The other is based on natural language models, using LSTM (Long Short-Term Memory) or BERT (Bidirectional Encoder Representation from Transformers) models to achieve human-computer dialogue according to context. Compared to end-to-end models, natural language models can achieve human-computer interaction, but they still cannot generate intelligent responses based on large amounts of text. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide an intelligent reply method and terminal that can accurately and intelligently reply to large text segments.
[0004] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0005] A smart reply method includes the following steps:
[0006] Obtain the text to be replied to, and use a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to;
[0007] The joint word vector encoding is input into the trained classification model, and the output is the text topic corresponding to the text to be replied to.
[0008] Based on the text to be replied to, keywords are extracted to obtain the second keyword;
[0009] Determine the target topic knowledge graph corresponding to the text topic, and determine the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword.
[0010] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows:
[0011] A smart response terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps:
[0012] Obtain the text to be replied to, and use a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to;
[0013] The joint word vector encoding is input into the trained classification model, and the output is the text topic corresponding to the text to be replied to.
[0014] Based on the text to be replied to, keywords are extracted to obtain the second keyword;
[0015] Determine the target topic knowledge graph corresponding to the text topic, and determine the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword.
[0016] The beneficial effects of this invention are as follows: by using a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the obtained text to be replied to, it is beneficial to improve the processing accuracy of subsequent tasks related to natural language processing. At the same time, the trained classification model is used to obtain the text topic corresponding to the text to be replied to. Compared with the BERT model, it performs better in processing long texts and improves the accuracy of text topic acquisition. In addition, the corresponding reply content is determined based on the target topic knowledge graph according to the second keyword. By combining the knowledge graph with the task-oriented dialogue model, effective replies can be generated for large text segments, and it can be ported to scenarios such as apps and customer service, thereby achieving accurate and intelligent replies for large text segments. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the steps of an intelligent response method according to an embodiment of the present invention;
[0018] Figure 2 This is a schematic diagram of the structure of an intelligent reply terminal according to an embodiment of the present invention;
[0019] Figure 3 This is a flowchart of the intelligent reply method in an embodiment of the present invention. Detailed Implementation
[0020] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.
[0021] Please refer to Figure 1This invention provides an intelligent response method, including the following steps:
[0022] Obtain the text to be replied to, and use a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to;
[0023] The joint word vector encoding is input into the trained classification model, and the output is the text topic corresponding to the text to be replied to.
[0024] Based on the text to be replied to, keywords are extracted to obtain the second keyword;
[0025] Determine the target topic knowledge graph corresponding to the text topic, and determine the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword.
[0026] As can be seen from the above description, the beneficial effects of the present invention are as follows: by using a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the obtained text to be replied to, it is beneficial to improve the processing accuracy of subsequent tasks related to natural language processing. At the same time, the training classification model is used to obtain the text topic corresponding to the text to be replied to. Compared with the BERT model, it performs better in processing long texts and improves the accuracy of text topic acquisition. In addition, the corresponding reply content is determined based on the target topic knowledge graph according to the second keyword. By combining the knowledge graph with the task-oriented dialogue model, effective replies can be generated for large text segments, and it can be ported to scenarios such as apps and customer service, thereby achieving accurate and intelligent replies for large text segments.
[0027] Furthermore, the steps prior to obtaining the text to be replied to include:
[0028] Various types of comment data are collected from the Internet and categorized according to themes to obtain categorized comment data;
[0029] Generate a corresponding first text summary based on the categorized comment data;
[0030] The first keyword is obtained by extracting keywords from the first text summary.
[0031] The first keyword is constructed as an entity, and the categorized comment data is used to construct the relationships between the entities;
[0032] A topic knowledge graph is constructed based on the entities and relationships, and the topic knowledge graph is stored using the Arangodb graph database.
[0033] As described above, different topic knowledge graphs are constructed based on the collected comment data of different types. This facilitates accurate retrieval of corresponding reply content from the topic knowledge graph. Furthermore, the topic knowledge graph is stored using the Arangodb graph database, which differs from the traditional neo4j graph database. The Arangodb graph database can combine different data models in a single query, making its display more intuitive and aesthetically pleasing. It also has more flexible scalability, higher fault tolerance, large storage capacity, and lower cost.
[0034] Furthermore, the step of obtaining the text to be replied to also includes:
[0035] A preset local word vector model is obtained by training based on the various types of comment data using a vector conversion tool.
[0036] As described above, simply using existing word vector models may not be suitable for the current corpus. There may be some words without corresponding word vectors, and noise may be introduced, which will greatly reduce the effectiveness of subsequent tasks. Therefore, vector conversion tools are used to train based on the various types of comment data to obtain a preset local word vector model, which can then be reliably jointly represented with a preset external word vector model.
[0037] Furthermore, the step of determining the joint word vector encoding corresponding to the text to be replied to using a preset external word vector model and a preset local word vector model includes:
[0038] The text to be replied to is input into a preset external word vector model, and the external word vector representation is output.
[0039] The text to be replied to is input into a preset local word vector model, and the local word vector representation is output.
[0040] Obtain the first weight corresponding to the preset external word vector model and the second weight corresponding to the preset local word vector model;
[0041] The external word vector representation and the local word vector representation are weighted and averaged according to the first weight and the second weight to obtain the joint word vector encoding corresponding to the text to be replied to.
[0042] As described above, due to the difference in data scale between external and local corpora, word vector models trained from the two data sources will also differ in semantic expression capabilities. Therefore, by weighting the external word vector representation and the preset local word vector representation according to the first and second weights, a joint word vector encoding corresponding to the text to be replied to can be obtained, which can achieve a more comprehensive and accurate word vector representation.
[0043] Furthermore, the step of obtaining the text to be replied to also includes:
[0044] The various types of comment data are cleaned to obtain cleaned comment data;
[0045] The cleaned comment data is segmented into words to obtain segmented comment data, and the segmented comment data is converted into a preset format to obtain format-converted comment data.
[0046] Training data is generated based on the format-converted comment data, and the training data is used to train the classification model to obtain the trained classification model.
[0047] As described above, training data is generated based on the format-converted comment data, and the training data is used to train the classification model to obtain the trained classification model. The classification model trained in this way has a more accurate text topic extraction effect.
[0048] Furthermore, the second keyword obtained by extracting keywords from the text to be replied to includes:
[0049] A second text summary is generated based on the text to be replied to, and keywords are extracted from the second text summary to obtain the second keywords.
[0050] As described above, a second text summary is first generated based on the text to be replied to, and then keywords are extracted from the second text summary. In this way, the extracted keywords can more accurately reflect the key content of the long text, which is conducive to improving the accuracy of intelligent replies.
[0051] Furthermore, generating a second text summary based on the text to be replied to includes:
[0052] The text to be replied to is input into the summary extraction model, and multiple candidate text summaries are output.
[0053] A semantic matching model is used to perform semantic matching between the multiple candidate text summaries and the text to be replied to, and a matching score is obtained for each candidate text summary.
[0054] Based on the matching score, the target candidate text summary with the highest matching score is determined from each of the candidate text summaries, and the target candidate text summary is determined as the second text summary.
[0055] As described above, the text to be replied to is input into the summary extraction model, and multiple candidate text summaries are output. The semantic matching model is used to determine the target candidate text summary with the highest matching score from the multiple candidate text summaries as the second text summary. The text summary extracted in this way has the best semantic matching with the source document, thus improving the accuracy of text summary acquisition.
[0056] Furthermore, the second keyword extraction from the second text summary yields the following second keywords:
[0057] The second text summary was analyzed using HanLP technology to extract keywords, resulting in the second set of keywords.
[0058] As described above, using HanLP technology to extract keywords from the second text summary can accurately and efficiently extract keywords from the text, facilitating subsequent queries.
[0059] Furthermore, determining the response content corresponding to the text to be responded to based on the second keyword and the target topic knowledge graph includes:
[0060] The target entity is determined from the target topic knowledge graph based on the second keyword;
[0061] The target relationship is determined based on the target entity, and the comment data corresponding to the target relationship is determined as the reply content corresponding to the text to be replied to.
[0062] As described above, by determining the target relationship based on the target entity and identifying the comment data corresponding to the target relationship as the reply content corresponding to the text to be replied to, accurate and effective intelligent replies can be achieved even for long texts.
[0063] Please refer to Figure 2 Another embodiment of the present invention provides an intelligent response terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements each step of the above-described intelligent response method.
[0064] The intelligent reply method and terminal described above are applicable to scenarios such as apps and customer service that require intelligent replies to large amounts of text. The following detailed implementation methods illustrate these methods:
[0065] Example 1
[0066] Please refer to Figure 1 and Figure 3 The intelligent reply method of this embodiment includes the following steps:
[0067] S1. Collect various types of comment data from the Internet, and classify the various types of comment data according to the topic to obtain classified comment data;
[0068] Specifically, data collection technology is used to collect various types of comment data from the Internet, and the various types of comment data are classified according to the topic to obtain classified comment data;
[0069] S2. Generate a corresponding first text summary based on the categorized comment data;
[0070] Specifically, the BertSum model (an extractive text summarization model based on the BERT model) is used to generate the corresponding first text summary based on the classified comment data;
[0071] S3. Extract keywords from the first text summary to obtain the first keyword;
[0072] Specifically, the Hanlp technique is used to extract keywords from the first text summary to obtain the first keyword. The Hanlp parameter is set to 5, meaning that 5 keywords are extracted from each text summary.
[0073] S4. Construct the first keyword as an entity, and construct the relationship between the classified comment data as the relationship between the entities;
[0074] S5. Construct a topic knowledge graph based on the entities and relationships, and store the topic knowledge graph using the Arangodb graph database, such as... Figure 3 As shown;
[0075] Unlike traditional Neo4j graph databases, Arangodb graph databases are characterized by their ability to combine different data models in a single query, making their presentation more intuitive. They offer more flexible scalability, higher fault tolerance, larger storage capacity, and lower cost than other databases. Arangodb's most prominent feature is Foxx, a data-centric JavaScript framework for writing databases.
[0076] S6. Use a vector conversion tool to train a preset local word vector model based on the various types of comment data;
[0077] The vector conversion tool is word2vec, which sets the vector dimension during training to N dimensions, and it is recommended that the value of N not exceed 300.
[0078] S7. Perform data cleaning on the various types of comment data to obtain cleaned comment data;
[0079] S8. The cleaned comment data is segmented into words to obtain segmented comment data, and the segmented comment data is converted into a preset format to obtain format-converted comment data.
[0080] The preset format is the fastText text format;
[0081] S9. Generate training data based on the format-converted comment data, and use the training data to train the classification model to obtain the trained classification model, such as... Figure 3 As shown;
[0082] In one optional implementation, the classification model is trained using the training data to obtain an initial classification model; the initial classification model is then evaluated for performance, optimized, and predicted sequentially to obtain a trained classification model.
[0083] The classification model is the fastText model. Compared with the existing BERT model, the fastText model performs better in long texts, and it often achieves accuracy comparable to deep networks, while requiring less training time.
[0084] S10. Obtain the text to be replied to, and use a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to, such as... Figure 3 As shown, it specifically includes:
[0085] S101. Obtain the text to be replied to;
[0086] S102. Input the text to be replied to into a preset external word vector model and output the external word vector representation.
[0087] The preset external word vector model is either Word2Vec or GloVe (Global Vectors);
[0088] S103. Input the text to be replied to into a preset local word vector model and output the local word vector representation.
[0089] S104. Obtain the first weight corresponding to the preset external word vector model and the second weight corresponding to the preset local word vector model;
[0090] The first weight and the second weight can be flexibly set according to the actual situation;
[0091] S105. The external word vector representation and the local word vector representation are weighted and averaged according to the first weight and the second weight to obtain the joint word vector encoding corresponding to the text to be replied to.
[0092] Suppose that the external word vector of a word w is represented by g(w), the local word vector is represented by l(w), and b is the first weight. Then the second weight is (1-b). Therefore, the joint word vector encoding is calculated by weighting algorithm as r(w) = b*g(w) + (1-b)*l(w).
[0093] S11. Input the joint word vector encoding into the trained classification model, and output the text topic corresponding to the text to be replied to.
[0094] S12. Based on the text to be replied to, extract keywords to obtain the second keyword, specifically including:
[0095] S121. Generate a second text summary based on the text to be replied to, specifically including:
[0096] S1211. Input the text to be replied to into the summary extraction model and output multiple candidate text summaries;
[0097] The abstract extraction model is the BertSum model.
[0098] S1212. Use a semantic matching model to perform semantic matching between the multiple candidate text summaries and the text to be replied to, and obtain a matching score corresponding to each candidate text summary;
[0099] The semantic matching model is the Roberta model.
[0100] S1213. Determine the target candidate text summary with the highest matching score from each candidate text summary based on the matching score, and determine the target candidate text summary as the second text summary;
[0101] S122. Extract keywords from the second text summary to obtain the second keywords;
[0102] Specifically, HanLP technology is used to extract keywords from the second text summary to obtain the second keywords;
[0103] The HanLP parameter is set to 5.
[0104] S13. Determine the target topic knowledge graph corresponding to the text topic, and determine the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword, specifically including:
[0105] S131. Determine the target topic knowledge graph corresponding to the text topic;
[0106] S132. Determine the target entity from the target topic knowledge graph based on the second keyword;
[0107] S133. Determine the target relationship based on the target entity, and determine the comment data corresponding to the target relationship as the reply content corresponding to the text to be replied to;
[0108] The above intelligent reply method can be applied to real-world scenarios as follows:
[0109] (1) Construct a topic knowledge graph in advance;
[0110] (2) Obtain agricultural articles input by the user;
[0111] (3) The text topic of the agricultural article is agriculture;
[0112] (4) Generate a text summary;
[0113] (5) Keyword extraction was performed on the text abstract, and the keywords were: "agricultural resource protection and utilization", "green development", "completion of quantitative indicators", "building a green and low-carbon agricultural industry chain" and "improving resource utilization level".
[0114] (6) Input these keywords into the corresponding topic knowledge graphs. Based on the correspondence between entities in the topic knowledge graphs, determine the correspondence between the keywords: The keywords “agricultural resource protection and utilization”, “green development”, “completion of quantitative indicators”, “building a green and low-carbon agricultural industry chain” and “improving resource utilization” correspond to the entities in the topic knowledge graphs as: “agricultural resources”, “green”, “indicators”, “agricultural industry chain” and “resources”.
[0115] (7) Output the content corresponding to the relationship of the entity found in the topic knowledge graph to achieve intelligent reply: For example, the entity corresponding to "agricultural resource protection and utilization" is "agricultural resources". The relationship corresponding to the subgraph structure of "agricultural resources" stored in the knowledge graph is "adhere to sustainable development". Therefore, the intelligent reply output in the above example is "adhere to sustainable development, adhere to the protection of the ecological environment, strive to achieve the goal, realize the industrial chain, and improve the efficient utilization of resources".
[0116] Example 2
[0117] Please refer to Figure 2 This embodiment of an intelligent response terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the intelligent response method in Embodiment 1.
[0118] In summary, the intelligent reply method and terminal provided by this invention acquires the text to be replied to and uses a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to; inputs the joint word vector encoding into a trained classification model to output the text topic corresponding to the text to be replied to; extracts keywords based on the text to be replied to to obtain a second keyword; determines a target topic knowledge graph corresponding to the text topic, and determines the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword. Compared with the BERT model, it performs better in processing long texts and improves the accuracy of text topic acquisition. In addition, by determining the corresponding reply content based on the target topic knowledge graph according to the second keyword, the combination of knowledge graph and task-oriented dialogue model can generate corresponding effective replies for large texts and can be ported to scenarios such as apps and customer service, thereby achieving accurate intelligent replies for large texts, making intelligent replies more intelligent and professional, and providing customers with a more professional and humanized interactive experience.
[0119] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. An intelligent reply method, characterized by, Including the following steps: Obtain the text to be replied to, and use a preset external word vector model and a preset local word vector model to determine the joint word vector encoding corresponding to the text to be replied to; The joint word vector encoding is input into the trained classification model, and the output is the text topic corresponding to the text to be replied to. Based on the text to be replied to, keywords are extracted to obtain the second keyword. This includes inputting the text to be replied to into a summary extraction model to output multiple candidate text summaries; using a semantic matching model to perform semantic matching between the multiple candidate text summaries and the text to be replied to, obtaining a matching score corresponding to each candidate text summary; determining the target candidate text summary with the highest matching score from each candidate text summary based on the matching score, and determining the target candidate text summary as the second text summary; and extracting keywords from the second text summary to obtain the second keyword. Determine the target topic knowledge graph corresponding to the text topic, and determine the reply content corresponding to the text to be replied to based on the target topic knowledge graph according to the second keyword.
2. The method of claim 1, wherein, The steps before obtaining the text to be replied to include: Various types of comment data are collected from the Internet and categorized according to themes to obtain categorized comment data; Generate a corresponding first text summary based on the categorized comment data; The first keyword is obtained by extracting keywords from the first text summary. The first keyword is constructed as an entity, and the categorized comment data is used to construct the relationships between the entities; A topic knowledge graph is constructed based on the entities and relationships, and the topic knowledge graph is stored using the Arangodb graph database.
3. The method of claim 2, wherein, Before obtaining the text to be replied to, the following steps are also included: A preset local word vector model is obtained by training based on the various types of comment data using a vector conversion tool.
4. The method of claim 1, wherein, The step of determining the joint word vector encoding corresponding to the text to be replied to using a preset external word vector model and a preset local word vector model includes: The text to be replied to is input into a preset external word vector model, and the external word vector representation is output. The text to be replied to is input into a preset local word vector model, and the local word vector representation is output. Obtain the first weight corresponding to the preset external word vector model and the second weight corresponding to the preset local word vector model; The external word vector representation and the local word vector representation are weighted and averaged according to the first weight and the second weight to obtain the joint word vector encoding corresponding to the text to be replied to.
5. The method of claim 2, wherein, Before obtaining the text to be replied to, the following steps are also included: The various types of comment data are cleaned to obtain cleaned comment data; The cleaned comment data is segmented into words to obtain segmented comment data, and the segmented comment data is converted into a preset format to obtain format-converted comment data. Training data is generated based on the format-converted comment data, and the training data is used to train the classification model to obtain the trained classification model.
6. The method of claim 1, wherein, The keyword extraction from the second text summary yields the following second keywords: The second text summary was analyzed using HanLP technology to extract keywords, resulting in the second set of keywords.
7. The method of claim 2, wherein, The step of determining the response content corresponding to the text to be responded to based on the second keyword and the target topic knowledge graph includes: The target entity is determined from the target topic knowledge graph based on the second keyword; The target relationship is determined based on the target entity, and the comment data corresponding to the target relationship is determined as the reply content corresponding to the text to be replied to.
8. A smart response terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements each step of the intelligent response method according to any one of claims 1 to 7.