Text reply method and device, electronic equipment and storage medium
By extracting the target characteristics and word segmentation characteristics of the text to be replied, combining the similarity of the candidate text and the correlation of word segmentation, the target guide content is selected, and the problem of accuracy and targeted reply in specific industry scenarios is solved, and more accurate and targeted text replies are achieved.
Patent Information
- Application Number
- CN202411297280.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-03-25
AI Technical Summary
In specific industry scenarios, it is difficult for intelligent reply systems to accurately understand the different meanings of specific words, resulting in confusion and poor accuracy of reply.
By obtaining the text to be replied, extracting its target text features, and matching the preset text features similarity to the preset text features, filtering candidate text. At the same time, word segmentation is processed for the response text, the correlation between the target word segmentation and the preset word segmentation is evaluated, and candidate word segmentation is further screened. Comprehensive the similarity of candidate text and the correlation between candidate word segmentation, determine the target guide content, and enter it into the trained text reply model to generate a reply.
Improve the accuracy of text replies, making the replies more targeted, and avoiding the problem of confusing replies.
Smart Images

Figure CN119691099A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text reply method, device, electronic device and storage medium. Background Art
[0002] With the development of artificial intelligence technology, more and more companies are actively applying models in intelligent response scenarios, using models to improve the capabilities of intelligent customer service in content understanding, text generation, and security Q&A, so as to respond to customer needs quickly and effectively and reduce labor costs.
[0003] In the related technology, in the intelligent reply scenario, the model generally matches semantic understanding through vector approximation algorithms to find the semantically closest content, which can solve most question-and-answer needs. However, it will not perform well in specific industry scenarios because the appearance of specific words represents different meanings. For example, when a user asks how to buy a product, if the description of the question is very similar to the description of the question of other products, it is easy to cause confusion in the reply, lack of keyword positioning ability, and poor accuracy of the reply. Therefore, it is urgent to provide a text reply method to solve the above technical problems. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a text reply method, device, electronic device and storage medium, which can improve the accuracy of text replies, make replies more targeted, and avoid the problem of confusing replies.
[0005] To achieve the above object, a first aspect of an embodiment of the present application proposes a text reply method, the method comprising:
[0006] Acquire the text to be replied, and extract the target text features of the text to be replied;
[0007] Determining the similarity between the target text feature and each preset text feature, and selecting a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity;
[0008] Performing word segmentation processing on the text to be replied to obtain a target word segmentation set, wherein the target word segmentation set includes a plurality of target word segmentations;
[0009] Determine a relevance score between the target word set and each preset word, and select a plurality of candidate word segments from each preset word based on the relevance score;
[0010] Based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles, the target guiding content is screened out from the plurality of candidate texts and the plurality of candidate participles;
[0011] The text to be replied and the target guidance content are input into the trained text reply model, and the reply content is output.
[0012] In some embodiments, determining the relevance score between the target word segmentation set and each preset word segmentation includes:
[0013] Obtaining the target number of characters constituting each of the target segmented words, the target number of segmented words of each of the target segmented words in the text to be replied, and the segmented word score of each preset segmented word;
[0014] Determine a relevance score between each of the target participles and each of the preset participles based on the target number of characters of each of the target participles, the corresponding number of target participles, and the participle score of each of the preset participles;
[0015] The sum of the relevance scores between each of the preset participles and a plurality of target participles included in the target participle set is calculated to obtain a relevance score between the target participle set and each of the preset participles.
[0016] In some embodiments, determining the relevance score between each target participle and each preset participle based on the target character number of each target participle, the corresponding target participle number, and the participle score of each preset participle includes:
[0017] Obtaining the product of the word segmentation score of each of the preset word segments and the preset scoring parameter to obtain a first calculation result;
[0018] Determine the sum of the number of target participles corresponding to each of the target participles and a preset value to obtain a second calculation result;
[0019] Obtaining the product of the target number of characters of each target word segment and the second calculation result to obtain a third calculation result;
[0020] The product of the third calculation result and the first calculation result is determined to obtain a correlation score between each of the target participles and each of the preset participles.
[0021] In some embodiments, the selecting target guiding content from the plurality of candidate texts and the plurality of candidate participles based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles includes:
[0022] Selecting a target similarity with the greatest similarity from the similarities of the plurality of candidate texts;
[0023] Filtering out a target relevance score with the largest relevance score from the relevance scores of the plurality of candidate word segments;
[0024] Calculating the ratio of the target relevance score to the target similarity to obtain a normalized ratio;
[0025] Normalizing the relevance scores of the plurality of candidate participles based on the normalization ratio to obtain a normalized result of each candidate participle;
[0026] Based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations, target guiding content is screened out from the plurality of candidate texts and the plurality of candidate word segmentations.
[0027] In some embodiments, the selecting target guiding content from the plurality of candidate texts and the plurality of candidate segmentations based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate segmentations includes:
[0028] Arranging the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations in descending order to obtain a sorted sequence;
[0029] The similarities and / or normalization results of the first preset number in the sorting sequence, and the corresponding candidate texts or candidate word segments are determined as target guiding content.
[0030] In some embodiments, the selecting a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity includes:
[0031] Sorting the similarities corresponding to each of the preset text features in descending order to obtain a similarity sequence;
[0032] Determine the similarities that are in the first second preset number in the similarity sequence as candidate similarities;
[0033] A candidate text feature corresponding to the candidate similarity is obtained, and a preset text corresponding to the candidate text feature is determined as the candidate text.
[0034] In some embodiments, the step of selecting a plurality of candidate participles from each of the preset participles based on the relevance score includes:
[0035] Sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence;
[0036] Determine the relevance scores that are in the first third preset number in the relevance score sequence as candidate relevance scores;
[0037] The preset participle corresponding to the candidate relevance score is obtained and determined as the candidate participle.
[0038] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a text reply device, comprising:
[0039] A first acquisition unit is used to acquire the text to be replied and extract the target text features of the text to be replied;
[0040] A first determination unit is used to determine the similarity between the target text feature and each preset text feature, and to select a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity;
[0041] A word segmentation unit is used to perform word segmentation processing on the text to be replied to, and obtain a target word segmentation set, wherein the target word segmentation set includes a plurality of target word segments;
[0042] A second determination unit is used to determine a relevance score between the target word set and each preset word, and to select a plurality of candidate word segments from each preset word based on the relevance score;
[0043] A screening unit, configured to screen out target guiding content from the plurality of candidate texts and the plurality of candidate participles based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles;
[0044] The output unit is used to input the text to be replied and the target guidance content into the trained text reply model and output the reply content.
[0045] In some embodiments, the second determining unit includes:
[0046] An acquisition subunit, used to acquire the target number of characters constituting each of the target segmented words, the target number of each of the target segmented words in the text to be replied, and the segmented word score of each preset segmented word;
[0047] A determination subunit, configured to determine a relevance score between each of the target participles and each of the preset participles based on the target number of characters of each of the target participles, the corresponding number of target participles, and the participle score of each of the preset participles;
[0048] The first calculation subunit is used to calculate the sum of the relevance scores between each of the preset participles and the multiple target participles included in the target participle set, so as to obtain the relevance score between the target participle set and each of the preset participles.
[0049] In some embodiments, a subunit is determined to:
[0050] Obtaining the product of the word segmentation score of each of the preset word segments and the preset scoring parameter to obtain a first calculation result;
[0051] Determine the sum of the number of target participles corresponding to each of the target participles and a preset value to obtain a second calculation result;
[0052] Obtaining the product of the target number of characters of each target word segment and the second calculation result to obtain a third calculation result;
[0053] The product of the third calculation result and the first calculation result is determined to obtain a correlation score between each of the target participles and each of the preset participles.
[0054] In some embodiments, the screening unit comprises:
[0055] A first screening subunit is used to screen out a target similarity with the greatest similarity from the similarities of the plurality of candidate texts;
[0056] A second screening subunit is used to screen out a target relevance score with the largest relevance score from the relevance scores of the plurality of candidate word segments;
[0057] A second calculation subunit is used to calculate the ratio of the target relevance score to the target similarity to obtain a normalized ratio;
[0058] A normalization subunit, configured to perform normalization processing on the relevance scores of the plurality of candidate participles based on the normalization ratio to obtain a normalized result of each candidate participle;
[0059] The third screening subunit is used to screen out target guiding content from the plurality of candidate texts and the plurality of candidate segmentations based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate segmentations.
[0060] In some embodiments, the third screening subunit is used to:
[0061] Arranging the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations in descending order to obtain a sorted sequence;
[0062] The similarities and / or normalization results of the first preset number in the sorting sequence, and the corresponding candidate texts or candidate word segments are determined as target guiding content.
[0063] In some embodiments, the first determining unit is configured to:
[0064] Sorting the similarities corresponding to each of the preset text features in descending order to obtain a similarity sequence;
[0065] Determine the similarities that are in the first second preset number in the similarity sequence as candidate similarities;
[0066] A candidate text feature corresponding to the candidate similarity is obtained, and a preset text corresponding to the candidate text feature is determined as the candidate text.
[0067] In some embodiments, the second determining unit is configured to:
[0068] Sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence;
[0069] Determine the relevance scores that are in the first third preset number in the relevance score sequence as candidate relevance scores;
[0070] The preset participle corresponding to the candidate relevance score is obtained and determined as the candidate participle.
[0071] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the method of the above-mentioned first aspect when executing the computer program.
[0072] To achieve the above objectives, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of the first aspect is implemented.
[0073] The text reply method, device, electronic device and storage medium proposed in the present application, which extracts the target text features of the text to be replied by acquiring the text to be replied; determines the similarity between the target text features and each preset text feature, and based on the similarity, selects multiple candidate texts from the preset text corresponding to each preset text feature; performs word segmentation processing on the text to be replied to obtain a target word segmentation set, and the target word segmentation set includes multiple target word segmentations; determines the relevance score between the target word segmentation set and each preset word segmentation, and selects multiple candidate word segmentations from each preset word segmentation based on the relevance score; selects target guidance content from multiple candidate texts and multiple candidate word segmentations based on the similarity of multiple candidate texts and the relevance score of multiple candidate word segmentations; inputs the text to be replied and the target guidance content into the trained text reply model, and outputs the reply content. In this way, by comprehensively considering the similarity of the candidate texts and the relevance score of the candidate word segmentations to select the target guidance content, the overall semantics and specific vocabulary information of the text can be fully combined to improve the accuracy of the text reply, so that the reply is more targeted and avoids the problem of reply confusion. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 is a flowchart of a text reply method provided in an embodiment of the present application;
[0075] Figure 2 yes Figure 1 Flow chart of step S104 in FIG.
[0076] Figure 3 yes Figure 2 Flow chart of step S202 in FIG.
[0077] Figure 4 yes Figure 1 Flow chart of step S105 in FIG.
[0078] Figure 5 yes Figure 4 Flow chart of step S405 in FIG.
[0079] Figure 6 yes Figure 1 Flow chart of step S102 in FIG.
[0080] Figure 7 yes Figure 1 Flow chart of step S104 in FIG.
[0081] Figure 8 is a structural diagram of a text reply device provided in an embodiment of the present application;
[0082] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0083] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0084] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0085] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0086] First, some nouns involved in this application are analyzed:
[0087] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0088] Network model: A network model is an abstract representation and mathematical description of various network systems in the real world. It usually consists of a set of nodes and edges connecting the nodes, and is used to simulate and analyze different types of network structures and their behaviors. The components include: 1. Nodes, which represent entities in the network. They can be physical entities such as computers, sensors, etc., or abstract concepts such as people, organizations, etc. Each node may have specific attributes such as name, status, function, etc. 2. Edges, which represent the relationship or connection between nodes. Edges can be directed or undirected, with or without weights. For example, in a social network, an edge can represent the relationship between people, and the weight can represent the strength of the relationship.
[0089] The functions of network models include: 1. Understanding and analyzing network structure: By analyzing the network model, we can understand the network's topological structure, connection patterns between nodes, centrality and other characteristics. This helps to discover key nodes, community structures and potential vulnerabilities in the network. 2. Predicting network behavior: Based on the network model, various predictions can be made, such as the speed of information propagation in the network, the reliability of the network, the behavioral changes of nodes, etc. This is very important for decision-making and risk management. 3. Optimizing network performance: Network models can be used to optimize the performance indicators of the network, such as improving the throughput of communication networks, reducing the congestion of traffic networks, and enhancing the information dissemination efficiency of social networks. By adjusting the network structure, node attributes or edge weights, the optimal network configuration can be found. 4. Designing and planning networks: Network models can provide guidance when designing new network systems or expanding existing networks. According to specific needs and goals, appropriate network models can be constructed, and simulations and analyses can be performed to determine the best design solution.
[0090] Knowledge point: It is a summary and conclusion of a specific content in a specific topic or field. It usually presents key information and concepts in a concise and clear way. Knowledge points can cover various disciplines, technical fields, common sense, etc.
[0091] Knowledge points have the following characteristics: 1. Independence. Each knowledge point can be studied and understood as an independent unit, and can convey certain information without relying on other knowledge points. For example, "the atomic number of hydrogen in the periodic table is 1", this knowledge point can be mastered alone. 2. Accuracy. Knowledge points are usually verified and confirmed correct information with high reliability. It expresses specific concepts, principles or facts in accurate language. 3. Generalization. Knowledge points refine and summarize complex content, remove unnecessary details, and highlight the core points. For example, "Photosynthesis is the process by which green plants use light energy to convert carbon dioxide and water into organic matter and release oxygen", which succinctly summarizes the essence of photosynthesis. 4. Accumulability. Numerous knowledge points can be interrelated and combined to form a more comprehensive and in-depth knowledge system. By continuously accumulating knowledge points, people can gradually expand their knowledge and cognitive level.
[0092] Word segmentation: It is an important technology in natural language processing. It mainly divides continuous text strings into independent word units according to certain rules. The purpose and function of word segmentation are: 1. It is convenient for text analysis. After the text is divided into words, it is more conducive to subsequent text analysis tasks, such as part-of-speech tagging, named entity recognition, sentiment analysis, etc. For example, in sentiment analysis, the sentiment tendency of each word can be determined through word segmentation, and then the sentiment of the entire text can be comprehensively judged. 2. Improve the efficiency of information retrieval. In the information retrieval system, word segmentation of text can make the retrieval more accurate and efficient. The query keywords entered by the user can be matched with the words in the text instead of the entire continuous text string. 3. Support language model training. In machine learning tasks of natural language processing, such as text classification and machine translation, the words after word segmentation can be used as input features of the model, which helps to improve the performance and accuracy of the model. For example, in the text classification task, the model can learn the distribution rules of different words in different categories of text, so as to better classify.
[0093] The word segmentation processing methods include: 1. Dictionary-based word segmentation. This method is to perform word segmentation by looking up a pre-built dictionary. If the string in the text exists in the dictionary, it will be segmented as a word. For example, for the sentence "The weather is very good today", if the dictionary contains words such as "today", "weather", "very", and "good", the sentence can be segmented into these four words. The word segmentation method based on the dictionary is simple and fast, but it has limited processing capabilities for unregistered words (words not in the dictionary) and ambiguous problems. 2. Statistical word segmentation. This method is to perform word segmentation by counting the probability of combinations between words in the text. The statistical word segmentation method can better handle unregistered words and ambiguous problems, but it requires a large amount of corpus for training and has a high computational complexity. 3. Word segmentation based on deep learning. In recent years, with the development of deep learning technology, some word segmentation methods based on deep learning have emerged. For example, a bidirectional long short-term memory network (BiLSTM) is combined with a conditional random field (CRF) for word segmentation. This method can automatically learn the characteristics of the text and improve the accuracy and robustness of word segmentation.
[0094] Based on this, the embodiments of the present application provide a text reply method, device, electronic device and storage medium, which aim to improve the accuracy of text replies, make replies more targeted, and avoid the problem of confusing replies.
[0095] The text reply method, device, electronic device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the text reply method in the embodiments of the present application is described.
[0096] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0097] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0098] The text reply method provided in the embodiment of the present application relates to the field of artificial intelligence technology. The text reply method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the text reply method, etc., but is not limited to the above forms.
[0099] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0100] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0101] Figure 1 is an optional flowchart of the text reply method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S106.
[0102] Step S101, obtaining the text to be replied, and extracting the target text features of the text to be replied.
[0103] Among them, for different text reply scenarios, the text to be replied is different. For the knowledge question and answer scenario, the text to be replied is the question that the user enters in the knowledge platform; for the conversation scenario, the text to be replied is the conversation content entered by the user. After the user enters the text to be replied, by clicking the send control in the interface, the text to be replied is sent to the electronic device, so that the electronic device obtains the text to be replied.
[0104] Specifically, the target text feature is a text feature of the text to be replied extracted by vectorizing the text to be replied. The specific vectorization processing method can be: using the trained text model to vectorize the text to be replied to obtain a text vector of a preset number of dimensions (for example, 768 dimensions).
[0105] Step S102 : determining the similarity between the target text feature and each preset text feature, and selecting a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity.
[0106] Among them, knowledge points are generally unstructured documents. In order to facilitate large-scale model retrieval, the documents need to be split into various knowledge points for storage, and text paragraphs with similar content are split into a knowledge point with a length of 200 to 500 characters. In order to combine semantically similar content, different splitting rules need to be selected for different document structures. The split documents are first placed on the splitting platform for manual review and adjustment, and finally the similar knowledge point chunks of each document are obtained.
[0107] Specifically, a pre-trained text model, such as ChatGPT or Bert model, is used to convert the above-mentioned split knowledge point blocks into feature vector Embeddings of a preset number of dimensions (for example, 768 dimensions) one by one, and maintain a one-to-one correspondence with the original text, and store them in a vector database system engine. These stored feature vectors are the preset text features, and the original text is the candidate text.
[0108] In order to determine which knowledge point is mainly involved in the text to be replied to by the user, it is necessary to determine the knowledge point involved based on the similarity by determining the similarity between the target text feature of the text to be replied and each preset text feature.
[0109] Specifically, the calculation method of similarity includes: calculating the cosine distance between the target text feature and the preset text feature to obtain a calculation result where the cosine distance is between [-1, 1]. The closer the calculation result is to 1, the closer the directions of the two vectors are, and the higher the similarity; the closer the value is to -1, the opposite the directions of the two vectors are, and the lower the similarity; a value of 0 indicates that the two vectors are orthogonal and not related. In this way, the similarity between the target text feature and the preset text feature is calculated.
[0110] Specifically, the calculation method of the cosine distance can refer to the following formula:
[0111]
[0112] where A·B represents the dot product (inner product) of vector A and vector B, ‖A‖ and ‖B‖ respectively represent the norms (lengths) of vector A and vector B, and d cos (A, B) is the cosine distance between vector A and vector B.
[0113] Thus, after determining the similarity between the target text feature and each preset text feature, multiple candidate texts can be screened from the preset texts corresponding to the preset text features according to the similarity.
[0114] Step S103: Perform word segmentation on the text to be replied to obtain a target word segmentation set, and the target word segmentation set includes multiple target word segments.
[0115] Among them, the method of performing word segmentation on the text to be replied to can be: by installing the ik_max_word word segmenter in the electronic device, and initializing the ik_max_word word segmenter according to the programming language and library used. This usually includes operations such as loading the dictionary and setting the word segmentation mode. For example, in Java, the IKAnalyzer class can be used to initialize the word segmenter and set the corresponding parameters. Thus, the text to be replied to input by the user is passed to the word segmenter for word segmentation processing. The word segmenter will split the phrase into individual target word segments according to the dictionary and word segmentation rules, thereby obtaining a target word segmentation set composed of multiple target segments. Further processing and analysis are performed on the target word segments. The target word segments can be stored in a data structure, such as an array, a list, etc., for subsequent operations. It is also possible to perform operations such as filtering and sorting on the word segmentation results to meet specific requirements. For example, stop words (such as common words like "of", "is", "in", etc. that contribute less to semantic analysis) can be removed, or sorting can be performed according to the length, frequency, etc. of the words.
[0116] For example, for the text to be replied to "The application of artificial intelligence in the financial field", the word segmentation processing may obtain target word segments such as "artificial intelligence", "financial field", "application", etc.
[0117] Step S104: determining the relevance score between the target word segmentation set and each preset word segmentation, and selecting a plurality of candidate word segmentations from each preset word segmentation based on the relevance score.
[0118] Among them, in order to improve the accuracy and pertinence of the text reply, the embodiment of the present application also performs word segmentation processing on multiple preset knowledge points in advance, and can also use the word segmenter ik_max_work to retrieve and segment the knowledge text, split the phrases according to the grammatical rules of Chinese, and then store the obtained word segmentation as an index in the electronic device, and the word segmentation stored in the electronic device is the preset word segmentation. In this way, by determining the relevance score between the target word segmentation set and each preset word segmentation, multiple candidate word segmentations with high relevance to the target word segmentation set are screened out from multiple preset word segmentations.
[0119] For example, the relevance score between the target word segmentation set and the preset word segmentation A is 90, the relevance score between the target word segmentation set and the preset word segmentation B is 70, and the relevance score between the target word segmentation set and the preset word segmentation A, the preset word segmentation B, and the preset word segmentation C is 80. Thus, candidate word segmentations can be screened out from the preset word segmentation A, the preset word segmentation B, and the preset word segmentation C through the relevance scores between the target word segmentation set and the preset word segmentation A, the preset word segmentation B, and the preset word segmentation C.
[0120] Step S105 , based on the similarities of the plurality of candidate texts and the relevance scores of the plurality of candidate word segments, select target guiding content from the plurality of candidate texts and the plurality of candidate word segments.
[0121] Among them, after multiple candidate texts are screened out in step S102 and multiple candidate participles are screened out in step S104, the similarity dimension and the relevance score dimension will be comprehensively evaluated to screen out target guidance content from the multiple candidate texts and the multiple candidate participles. The target guidance content is the candidate texts and / or candidate participles screened out from the multiple candidate texts and the multiple candidate participles.
[0122] Step S106, input the text to be replied and the target guidance content into the trained text reply model, and output the reply content.
[0123] Among them, after the target guidance content is filtered out in step S105, the text to be replied and the target guidance content can be input into the trained text reply model, so that the target guidance content can be used as the context content of the trained text reply model to reply the text to be replied, and a guided reply can be performed.
[0124] Steps S101 to S106 shown in the embodiment of the present application are as follows: by acquiring the text to be replied, extracting the target text features of the text to be replied; determining the similarity between the target text features and each preset text feature, and based on the similarity, screening out multiple candidate texts from the preset text corresponding to each preset text feature; performing word segmentation processing on the text to be replied to obtain a target word segmentation set, wherein the target word segmentation set includes multiple target word segmentations; determining the relevance score between the target word segmentation set and each preset word segmentation, and screening out multiple candidate word segmentations from each preset word segmentation based on the relevance score; based on the similarity of multiple candidate texts and the relevance score of multiple candidate word segmentations, screening out target guiding content from multiple candidate texts and multiple candidate word segmentations; inputting the text to be replied and the target guiding content into the trained text reply model, and outputting the reply content. In this way, by comprehensively considering the similarity of the candidate texts and the relevance score of the candidate word segmentations to screen the target guiding content, the overall semantics and specific vocabulary information of the text can be fully combined to improve the accuracy of the text reply, making the reply more targeted and avoiding the problem of reply confusion.
[0125] See also Figure 2 In some embodiments, step S104 may include but is not limited to steps S201 to S203:
[0126] Step S201, obtaining the target number of characters constituting each target segmentation, the target number of each target segmentation in the text to be replied, and the segmentation score of each preset segmentation.
[0127] The method for determining the relevance score between the target word segmentation set and each preset word segmentation is as follows: obtaining the target number of characters of each target word segmentation, the target number of each target word segmentation in the text to be replied, and the word segmentation score of each preset word segmentation.
[0128] For example, the text to be replied is "the application of artificial intelligence in the financial field, and the role of artificial intelligence in the financial field". After word segmentation processing, target word segments such as "artificial intelligence", "financial field", and "application" may be obtained. For the target word "artificial intelligence", the corresponding target number of words is 4, and the target number of words for "artificial intelligence" in the text to be replied is 2.
[0129] Specifically, the word segmentation score of the preset word segmentation is a score set in advance to characterize different preset word segmentations. The score can be used to evaluate the vector length of the preset word segmentation, which is not limited here.
[0130] Step S202, based on the target character quantity of each target segmentation, the corresponding target segmentation quantity, and the segmentation score of each preset segmentation, determine the correlation score between each target segmentation and each preset segmentation.
[0131] Among them, the method for determining the relevance score between the target word segmentation set and each preset word segmentation in step S201 is: after obtaining the target number of characters of each target word segmentation, the target number of each target word segmentation in the text to be replied and the word segmentation score of each preset word segmentation, the relevance score between each target word segmentation and each preset word segmentation can be determined according to the above parameters.
[0132] Step S203, calculating the sum of the relevance scores between each of the preset participles and the multiple target participles included in the target participle set, and obtaining the relevance score between the target participle set and each of the preset participles.
[0133] The relevance score between the target word set and each preset word can be calculated according to the following formula:
[0134]
[0135] Among them, Y n Indicates the total score of the preset segmentation and the nth target segmentation matched by the user input. Score keyword Score the relevance between the target segmentation and the preset segmentation. That is, calculate the sum of the relevance scores of each target segmentation and a preset segmentation in the target segmentation set to obtain the relevance score between the target segmentation set and each preset segmentation.
[0136] In this way, the correlation between the target word and the preset word can be more comprehensively evaluated through three different dimensions: the number of characters of the target word, the number of characters in the text to be replied, and the score of the preset word. The number of characters of the target word reflects its complexity or the richness of its specific meaning; the number of target words in the text to be replied can reflect its importance or frequency; the score of the preset word can measure its value or relevance potential based on some pre-set standards. The multi-dimensional consideration avoids the limitations of single-factor evaluation and improves the accuracy of relevance evaluation.
[0137] See also Figure 3 In some embodiments, step S202 may include but is not limited to steps S301 to S304:
[0138] Step S301, obtaining the product of the word segmentation score of each of the preset word segments and a preset scoring parameter to obtain a first calculation result.
[0139] The calculation method of the first calculation result may refer to the following formula:
[0140] β*x;
[0141] Among them, β represents a preset scoring parameter, which can be 10, and x represents the word segmentation score of the preset word segmentation.
[0142] Step S302, determining the sum of the number of target segmented words corresponding to each of the target segmented words and a preset value to obtain a second calculation result.
[0143] The calculation method of the second calculation result may refer to the following formula:
[0144] a+y;
[0145] Among them, a is a preset value, which can be 1, and y is the number of target segmentations corresponding to the target segmentation.
[0146] Step S303, obtaining the product of the target number of characters of each target word segment and the second calculation result to obtain a third calculation result.
[0147] The calculation method of the third calculation result may refer to the following formula:
[0148] keyword x (a+y);
[0149] Among them, keyword x is the target number of characters contained in the target word, and a+y is the second calculation result.
[0150] Step S304: determine the product of the third calculation result and the first calculation result to obtain a correlation score between each of the target participles and each of the preset participles.
[0151] The calculation method of the relevance score between the target word and each of the preset words can refer to the following formula:
[0152] Score keyword =keyword x (1+y)*(β*x);
[0153] Among them, Score keyword Score the relevance of the target word to a preset word, keyword x (1+y) is the third calculation result, and (β*x) is the first calculation result.
[0154] In this way, the relevance score is calculated by introducing multiple factors such as the number of characters in the target segmentation, the number of target segmentations, the segmentation score of the preset segmentation, and the preset score parameters. This can comprehensively evaluate the relationship between the target segmentation and the preset segmentation from different angles, thereby improving the accuracy and comprehensiveness of the relevance evaluation.
[0155] See also Figure 4 In some embodiments, step S105 may include but is not limited to steps S401 to S405:
[0156] Step S401, selecting a target similarity with the greatest similarity from the similarities of the plurality of candidate texts.
[0157] Among them, since the similarity dimension and the relevance score dimension belong to two different dimensions, the values of similarity and relevance score cannot be measured uniformly, so the two dimensions need to be unified, and since the similarity value is in the range of [0,1], the unified method is to normalize the relevance score dimension to the similarity dimension.
[0158] Specifically, before the normalization process, it is necessary to screen out the target similarity with the greatest similarity from the similarities of multiple candidate texts, for example, the target similarity is 0.9.
[0159] Step S402: Filter out a target relevance score with the largest relevance score from the relevance scores of the plurality of candidate word segmentations.
[0160] Before the normalization process, it is also necessary to screen out a target relevance score with the largest relevance score from the relevance scores of multiple candidate word segmentations, for example, a target relevance score of 90.
[0161] Step S403, calculating the ratio of the target relevance score to the target similarity to obtain a normalized ratio.
[0162] The normalization ratio required for normalization processing is determined by calculating the ratio of the target relevance score to the target similarity.
[0163] For example, if the target relevance score is 90 and the target similarity is 0.9, the normalized ratio is 90 / 0.9=100.
[0164] Step S404: normalize the relevance scores of the plurality of candidate participles based on the normalization ratio to obtain a normalized result of each candidate participle.
[0165] After the normalization ratio is determined in step S403, the relevance score of each candidate word segmentation can be normalized by the following formula:
[0166]
[0167] Among them, Y n is the relevance score of the nth candidate word, X0 is the target relevance score, Y0 is the target similarity, and Wβ is the preset weight constant, Z n is the normalized result corresponding to the relevance score of the nth candidate segmentation word. Through this formula, the relevance score of each candidate segmentation word can be normalized to obtain the corresponding normalized result.
[0168] Step S405 , based on the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segments, the target guiding content is screened out from the plurality of candidate texts and the plurality of candidate word segments.
[0169] After the relevance score is normalized to the similarity dimension in step S404, the target guiding content can be screened out from the multiple candidate texts and the multiple candidate participles according to the similarities of the multiple candidate texts and the normalized results of the multiple candidate participles.
[0170] In this way, by normalizing the relevance score dimension to the similarity dimension, the problem of difficulty in uniformly measuring data of different dimensions is solved. This makes it easier to comprehensively consider data from different sources (the similarity of candidate texts and the relevance score of candidate word segments) in subsequent processing, thereby improving the accuracy and effectiveness of data processing.
[0171] See also Figure 5 In some embodiments, step S405 may include but is not limited to steps S501 to S502:
[0172] Step S501 , arranging the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segments in descending order to obtain a sorted sequence.
[0173] Among them, since the normalized results of the multiple candidate word segmentations after normalization and the similarities of the multiple candidate texts are all between [0,1], the similarities of the multiple candidate texts and the normalized results of the multiple candidate word segmentations can be arranged in order from large to small to obtain a sorted sequence.
[0174] For example, the similarity of candidate text A is 0.7, the similarity of candidate text B is 0.75, the similarity of candidate text C is 0.8, the normalized result of candidate participle 1 is 0.6, the normalized result of candidate participle 2 is 0.85, and the normalized result of candidate participle 3 is 0.78. Then the sorting sequence is: 0.85 for candidate participle 2, 0.8 for candidate text C, 0.78 for candidate participle 3, 0.75 for candidate text B, 0.7 for candidate text A, and 0.6 for candidate participle 1.
[0175] Step S502: determining the candidate texts or candidate word segments corresponding to the similarities and / or normalization results of the first preset number in the sorting sequence as target guiding content.
[0176] Among them, a first preset number is set, and the similarities and / or normalized results of the first preset number in the sorting sequence, and the corresponding candidate texts or candidate word segments are determined as target guiding content.
[0177] For example, the sorting sequence is: 0.85 of candidate participle 2, 0.8 of candidate text C, 0.78 of candidate participle 3, 0.75 of candidate text B, 0.7 of candidate text A, and 0.6 of candidate participle 1. The first preset number is 4. Then, the candidate participle 2, candidate text C, candidate participle 3, and candidate text B, which correspond to the first 4 positions 0.85, 0.8, 0.78, and 0.75 in the sorting sequence, are determined as target guidance content.
[0178] In this way, by arranging the similarities of multiple candidate texts and the normalized results of multiple candidate word segmentations in order from large to small, the priority of each data point can be clarified. In this way, in the subsequent processing, it can be more intuitive to see which candidate texts and candidate word segmentations have a higher correlation with the text to be replied, providing a clear basis for screening the target guidance content. And the screened target guidance content is sorted and selected based on the similarity and normalization results, with high relevance and reliability. This can provide a more accurate reference for subsequent text replies and improve the accuracy and quality of replies.
[0179] See also Figure 6 In some embodiments, step S102 may include but is not limited to steps S601 to S603:
[0180] Step S601 , sorting the similarities corresponding to each of the preset text features in descending order to obtain a similarity sequence.
[0181] The method of selecting multiple candidate texts from the preset texts corresponding to each preset text feature is as follows: the similarities corresponding to each preset text feature are sorted in descending order to obtain a similarity sequence.
[0182] For example, the similarity of the preset text feature A is 0.9, the similarity of the preset text feature B is 0.85, the similarity of the preset text feature C is 0.93, and the similarity of the preset text feature D is 0.7, then the similarity sequence is: 0.93, 0.9, 0.85, 0.7.
[0183] Step S602: Determine the similarities that are in the first second preset number in the similarity sequence as candidate similarities.
[0184] A second preset number is set, and the similarities that are in the first second preset number in the similarity sequence are determined as candidate similarities.
[0185] For example, the similarity of the preset text feature A is 0.9, the similarity of the preset text feature B is 0.85, the similarity of the preset text feature C is 0.93, and the similarity of the preset text feature D is 0.7, then the similarity sequence is: 0.93, 0.9, 0.85, 0.7. The second preset number is 2, then 0.93 and 0.9, which are in the first two positions in the similarity sequence, are determined as candidate similarities.
[0186] Step S603, obtaining candidate text features corresponding to the candidate similarities, and determining the preset text corresponding to the candidate text features as the candidate text.
[0187] Since there is a mapping relationship between similarity and text features, the candidate text features corresponding to the candidate similarities are obtained, and the preset text corresponding to the candidate text features is determined as the candidate text.
[0188] In this way, the similarities in the first second preset number in the similarity sequence are determined as candidate similarities. This method can control the number of candidate texts according to actual needs, avoid interference from too many irrelevant texts, and ensure that the selected candidate texts have high similarity. By screening by a preset number, the screening efficiency can be improved while ensuring accuracy.
[0189] See also Figure 7 In some embodiments, step S104 may include but is not limited to steps S701 to S703:
[0190] Step S701, sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence.
[0191] The method of selecting multiple candidate participles from each of the preset participles is as follows: sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence.
[0192] For example, the relevance score of preset word segmentation A is 90, the relevance score of preset word segmentation B is 85, the relevance score of preset word segmentation C is 93, and the relevance score of preset word segmentation D is 70, then the relevance score sequence is: 93, 90, 85, 70.
[0193] Step S702: Determine the relevance scores that are in the first third preset number in the relevance score sequence as candidate relevance scores.
[0194] A third preset number is set, and the correlation scores that are in the first third preset number in the correlation score sequence are determined as candidate correlation scores.
[0195] For example, the relevance score of the preset word segment A is 90, the relevance score of the preset word segment B is 85, the relevance score of the preset word segment C is 93, and the relevance score of the preset word segment D is 70, then the relevance score sequence is: 93, 90, 85, 70. The third preset number is 3, then 93, 90, and 85, which are in the first two positions in the similarity sequence, are determined as candidate relevance scores.
[0196] Step S703: Obtain a preset word segment corresponding to the candidate relevance score and determine it as a candidate word segment.
[0197] Among them, since there is a mapping relationship between the relevance score and the preset participle, the preset participle corresponding to the candidate relevance score is determined as the candidate participle.
[0198] In this way, by setting the third preset number to determine the candidate relevance score, the screening process is more targeted and controllable. This avoids too many low-relevance preset word segmentations from entering the subsequent processing, improving the processing efficiency. For example, in a text reply scenario, only the most relevant preset word segmentations can be selected for further analysis according to needs, reducing unnecessary calculations.
[0199] The embodiment of the present application obtains the text to be replied, extracts the target text feature of the text to be replied; determines the similarity between the target text feature and each preset text feature, and based on the similarity, selects multiple candidate texts from the preset text corresponding to each preset text feature; performs word segmentation processing on the text to be replied, obtains a target word segmentation set, and the target word segmentation set includes multiple target word segmentations; determines the relevance score between the target word segmentation set and each preset word segmentation, and selects multiple candidate word segmentations from each preset word segmentation based on the relevance score; selects target guiding content from multiple candidate texts and multiple candidate word segmentations based on the similarity of multiple candidate texts and the relevance score of multiple candidate word segmentations; inputs the text to be replied and the target guiding content into the trained text reply model, and outputs the reply content. In this way, by comprehensively considering the similarity of the candidate texts and the relevance score of the candidate word segmentations to select the target guiding content, the overall semantics and specific vocabulary information of the text can be fully combined to improve the accuracy of the text reply, so that the reply is more targeted and the problem of reply confusion can be avoided.
[0200] See also Figure 8 The embodiment of the present application also provides a text reply device, which can implement the above-mentioned text reply method, and the device includes:
[0201] A first acquisition unit is used to acquire the text to be replied and extract the target text features of the text to be replied;
[0202] A first determining unit, configured to determine a similarity between the target text feature and each preset text feature, and to select a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity;
[0203] A word segmentation unit is used to perform word segmentation processing on the text to be replied to, and obtain a target word segmentation set, wherein the target word segmentation set includes a plurality of target word segments;
[0204] A second determination unit is used to determine a relevance score between the target word set and each preset word, and to select a plurality of candidate word segments from each preset word based on the relevance score;
[0205] A screening unit, configured to screen out target guiding content from the plurality of candidate texts and the plurality of candidate participles based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles;
[0206] The output unit is used to input the text to be replied and the target guidance content into the trained text reply model and output the reply content.
[0207] In some embodiments, the second determining unit includes:
[0208] An acquisition subunit, used to acquire the target number of characters constituting each of the target segmented words, the target number of each of the target segmented words in the text to be replied, and the segmented word score of each preset segmented word;
[0209] A determination subunit, configured to determine a relevance score between each of the target participles and each of the preset participles based on the target number of characters of each of the target participles, the corresponding number of target participles, and the participle score of each of the preset participles;
[0210] The first calculation subunit is used to calculate the sum of the relevance scores between each of the preset participles and a plurality of target participles included in the target participle set, so as to obtain the relevance score between the target participle set and each of the preset participles.
[0211] In some embodiments, a subunit is determined to:
[0212] Obtaining the product of the word segmentation score of each of the preset word segments and the preset scoring parameter to obtain a first calculation result;
[0213] Determine the sum of the number of target participles corresponding to each of the target participles and a preset value to obtain a second calculation result;
[0214] Obtaining the product of the target number of characters of each target word segment and the second calculation result to obtain a third calculation result;
[0215] The product of the third calculation result and the first calculation result is determined to obtain a correlation score between each of the target participles and each of the preset participles.
[0216] In some embodiments, the screening unit comprises:
[0217] A first screening subunit is used to screen out a target similarity with the greatest similarity from the similarities of the plurality of candidate texts;
[0218] A second screening subunit is used to screen out a target relevance score with the largest relevance score from the relevance scores of the plurality of candidate word segments;
[0219] A second calculation subunit is used to calculate the ratio of the target relevance score to the target similarity to obtain a normalized ratio;
[0220] A normalization subunit, configured to perform normalization processing on the relevance scores of the plurality of candidate participles based on the normalization ratio to obtain a normalized result of each candidate participle;
[0221] The third screening subunit is used to screen out target guiding content from the plurality of candidate texts and the plurality of candidate segmentations based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate segmentations.
[0222] In some embodiments, the third screening subunit is used to:
[0223] Arranging the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations in descending order to obtain a sorted sequence;
[0224] The similarities and / or normalization results of the first preset number in the sorting sequence, and the corresponding candidate texts or candidate word segments are determined as target guiding content.
[0225] In some embodiments, the first determining unit is configured to:
[0226] Sorting the similarities corresponding to each of the preset text features in descending order to obtain a similarity sequence;
[0227] Determine the similarities that are in the first second preset number in the similarity sequence as candidate similarities;
[0228] A candidate text feature corresponding to the candidate similarity is obtained, and a preset text corresponding to the candidate text feature is determined as the candidate text.
[0229] In some embodiments, the second determining unit is configured to:
[0230] Sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence;
[0231] Determine the first third preset number of correlation scores in the correlation score sequence as candidate correlation scores;
[0232] The preset participle corresponding to the candidate relevance score is obtained and determined as the candidate participle.
[0233] In the embodiment of the present application, the first acquisition unit acquires the text to be replied and extracts the target text feature of the text to be replied; the first determination unit determines the similarity between the target text feature and each preset text feature, and based on the similarity, selects multiple candidate texts from the preset text corresponding to each preset text feature; the word segmentation unit performs word segmentation processing on the text to be replied to obtain a target word segmentation set, and the target word segmentation set includes multiple target word segmentations; the second determination unit determines the relevance score between the target word segmentation set and each preset word segmentation, and selects multiple candidate word segmentations from each preset word segmentation based on the relevance score; the screening unit selects the target guiding content from the multiple candidate texts and the multiple candidate word segmentations based on the similarity of the multiple candidate texts and the relevance score of the multiple candidate word segmentations; the output unit inputs the text to be replied and the target guiding content into the trained text reply model, and outputs the reply content. In this way, by comprehensively considering the similarity of the candidate texts and the relevance score of the candidate word segmentations to select the target guiding content, the overall semantics and specific vocabulary information of the text can be fully combined to improve the accuracy of the text reply, so that the reply is more targeted and the problem of reply confusion can be avoided. The correlation between the target segmentation and the preset segmentation can be more comprehensively evaluated by three different dimensions: the number of characters of the target segmentation, the number of target segmentations in the text to be replied, and the score of the preset segmentation. The number of characters of the target segmentation reflects its complexity or the richness of its specific meaning; the number of target segmentations in the text to be replied can reflect its importance or frequency; the score of the preset segmentation can measure its value or relevance potential from a certain pre-set standard. The multi-dimensional consideration method avoids the limitations of single-factor evaluation and improves the accuracy of relevance evaluation. The relevance score is calculated by introducing multiple factors such as the number of characters of the target segmentation, the number of target segmentations, the segmentation score of the preset segmentation, and the preset score parameters. In this way, the relationship between the target segmentation and the preset segmentation can be comprehensively evaluated from different angles, improving the accuracy and comprehensiveness of the relevance evaluation. By normalizing the relevance score dimension to the similarity dimension, the problem of different dimensional data being difficult to measure uniformly is solved. In this way, data from different sources (the similarity of candidate texts and the relevance score of candidate segmentations) can be more conveniently considered in subsequent processing, improving the accuracy and effectiveness of data processing. By arranging the similarities of multiple candidate texts and the normalized results of multiple candidate word segmentations in descending order, the priority of each data point can be clarified. In this way, in the subsequent processing, it can be more intuitive to see which candidate texts and candidate word segmentations are more relevant to the text to be replied, providing a clear basis for screening target guidance content. In addition, the screened target guidance content is sorted and selected based on the similarity and normalization results, and has high relevance and reliability. This can provide a more accurate reference for subsequent text replies and improve the accuracy and quality of replies.The similarities in the first second preset number in the similarity sequence are determined as candidate similarities. This method can control the number of candidate texts according to actual needs, avoid the interference of too much irrelevant text, and ensure that the selected candidate texts have high similarity. By screening by preset quantity, the screening efficiency can be improved while ensuring accuracy. By setting the third preset number to determine the candidate relevance score, this makes the screening process more targeted and controllable. It avoids too many low-relevance preset word segmentations from entering subsequent processing, thereby improving processing efficiency. For example, in a text reply scenario, only the most relevant preset word segmentations can be selected for further analysis according to needs to reduce unnecessary calculations.
[0234] The specific implementation of the text reply device is basically the same as the specific implementation of the above-mentioned text reply method, and will not be repeated here.
[0235] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above text reply method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0236] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0237] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (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 the present application;
[0238] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the text reply method of the embodiment of this application;
[0239] Input / output interface 903, used to implement information input and output;
[0240] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0241] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0242] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0243] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned text reply method is implemented.
[0244] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0245] The text reply method, text reply device, electronic device and storage medium provided by the embodiment of the present application, extract the target text feature of the text to be replied by acquiring the text to be replied; determine the similarity between the target text feature and each preset text feature, and select multiple candidate texts from the preset text corresponding to each preset text feature based on the similarity; perform word segmentation processing on the text to be replied to obtain a target word segmentation set, and the target word segmentation set includes multiple target word segmentations; determine the relevance score between the target word segmentation set and each preset word segmentation, and select multiple candidate word segmentations from each preset word segmentation based on the relevance score; based on the similarity of multiple candidate texts and the relevance score of multiple candidate word segmentations, select target guiding content from multiple candidate texts and multiple candidate word segmentations; input the text to be replied and the target guiding content into the trained text reply model, and output the reply content. In this way, by comprehensively considering the similarity of the candidate texts and the relevance score of the candidate word segmentations to select the target guiding content, the overall semantics and specific vocabulary information of the text can be fully combined to improve the accuracy of the text reply, so that the reply is more targeted and the problem of reply confusion can be avoided.
[0246] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0247] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0248] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0249] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0250] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0251] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0252] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0253] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0254] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0255] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0256] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A text reply method, characterized in that: include: Acquire the text to be replied, and extract the target text features of the text to be replied; Determining the similarity between the target text feature and each preset text feature, and selecting a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity; Performing word segmentation processing on the text to be replied to obtain a target word segmentation set, wherein the target word segmentation set includes a plurality of target word segmentations; Determine a relevance score between the target word set and each preset word, and select a plurality of candidate word segments from each preset word based on the relevance score; Based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles, the target guiding content is screened out from the plurality of candidate texts and the plurality of candidate participles; The text to be replied and the target guidance content are input into the trained text reply model, and the reply content is output.
2. The text reply method according to claim 1, characterized in that: Determining the relevance score between the target word set and each preset word includes: Obtaining the target number of characters constituting each of the target segmented words, the target number of segmented words of each of the target segmented words in the text to be replied, and the segmented word score of each preset segmented word; Determine a relevance score between each target participle and each preset participle based on the target number of characters of each target participle, the corresponding target number of participles, and the participle score of each preset participle; The sum of the relevance scores between each of the preset participles and a plurality of target participles included in the target participle set is calculated to obtain a relevance score between the target participle set and each of the preset participles.
3. The text reply method according to claim 2, characterized in that: The step of determining the relevance score between each target participle and each preset participle based on the target character number of each target participle, the corresponding target participle number, and the participle score of each preset participle includes: Obtaining the product of the word segmentation score of each of the preset word segments and the preset scoring parameter to obtain a first calculation result; Determine the sum of the number of target participles corresponding to each of the target participles and a preset value to obtain a second calculation result; Obtaining the product of the target number of characters of each target word segment and the second calculation result to obtain a third calculation result; The product of the third calculation result and the first calculation result is determined to obtain a correlation score between each of the target participles and each of the preset participles.
4. The text reply method according to claim 1, characterized in that: The step of selecting target guiding content from the plurality of candidate texts and the plurality of candidate participles based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles includes: Selecting a target similarity with the greatest similarity from the similarities of the plurality of candidate texts; Filtering out a target relevance score with the largest relevance score from the relevance scores of the plurality of candidate word segments; Calculating the ratio of the target relevance score to the target similarity to obtain a normalized ratio; Normalizing the relevance scores of the plurality of candidate participles based on the normalization ratio to obtain a normalized result of each candidate participle; Based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations, target guiding content is screened out from the plurality of candidate texts and the plurality of candidate word segmentations.
5. The text reply method according to claim 4, characterized in that: The step of selecting target guiding content from the plurality of candidate texts and the plurality of candidate segmentations based on the similarity of the plurality of candidate texts and the normalized results of the plurality of candidate segmentations includes: Arranging the similarities of the plurality of candidate texts and the normalized results of the plurality of candidate word segmentations in descending order to obtain a sorted sequence; The candidate texts or candidate word segments corresponding to the similarities and / or normalization results of the first preset number in the sorting sequence are determined as target guiding content.
6. The text reply method according to any one of claims 1 to 5, characterized in that: The selecting a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity includes: Sorting the similarities corresponding to each of the preset text features in descending order to obtain a similarity sequence; Determine the similarities that are in the first second preset number in the similarity sequence as candidate similarities; A candidate text feature corresponding to the candidate similarity is obtained, and a preset text corresponding to the candidate text feature is determined as the candidate text.
7. The text reply method according to any one of claims 1 to 5, characterized in that: The step of selecting a plurality of candidate participles from each of the preset participles based on the relevance score includes: Sorting the relevance scores corresponding to each of the preset participles in descending order to obtain a relevance score sequence; Determine the first third preset number of correlation scores in the correlation score sequence as candidate correlation scores; The preset participle corresponding to the candidate relevance score is obtained and determined as the candidate participle.
8. A text reply device, characterized in that: include: A first acquisition unit is used to acquire the text to be replied and extract the target text features of the text to be replied; A first determination unit is used to determine the similarity between the target text feature and each preset text feature, and to select a plurality of candidate texts from the preset texts corresponding to each preset text feature based on the similarity; A word segmentation unit is used to perform word segmentation processing on the text to be replied to, and obtain a target word segmentation set, wherein the target word segmentation set includes a plurality of target word segments; A second determination unit is used to determine a relevance score between the target word set and each preset word, and select a plurality of candidate word segments from each preset word segment based on the relevance score; A screening unit, configured to screen out target guiding content from the plurality of candidate texts and the plurality of candidate participles based on the similarity of the plurality of candidate texts and the relevance scores of the plurality of candidate participles; The output unit is used to input the text to be replied and the target guidance content into the trained text reply model and output the reply content.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the text reply method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text reply method according to any one of claims 1 to 7 is implemented.