Text matching method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202310066272.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-12
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-01-12
AI Technical Summary
[0006]本申请提供一种文本匹配方法、装置、存储介质以及电子设备,以解决相关技术中通过将文本输入单一模型进行相似度判断的准确性低的问题
[0017]通过本申请,采用以下步骤:获取用户发送的初始文本内容,并获取数据库中的任意一个对象文本内容和对象文本内容的应用场景;在应用场景下判断初始文本内容是否存在错误,在初始文本内容不存在错误的情况下,将初始文本内容和对象文本内容依次输入模型集群中的每个模型中,得到每个模型输出的相似度分数,其中,模型集群中存在多个机器学习模型,每个机器学习模型用于确定初始文本内容和对象文本内容的相似度分数;将多个相似度分数输入逻辑回归模型中,得到初始文本内容和对象文本内容的相似度确定结果,并根据相似度确定结果确定初始文本内容和对象文本内容是否匹配。解决了相关技术中通过将文本输入单一模型进行相似度判断的准确性低的问题。通过先对需要进行对比的文本内容进行内容正确与否的确定,在文本内容无误的情况下,通过多个模型依次对初始文本内容与对象文本内容进行判断,得到多个相似度结果,并通过多个相似度结果综合进行判断,进而达到了准确的判断两个文本内容是否匹配的效果。
Smart Images

Figure CN116028626B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more specifically, to a text matching method, apparatus, storage medium, and electronic device. Background Technology
[0002] Text matching is a fundamental task in natural language processing, widely used in intelligent question-answering systems and information retrieval. Given two sentences of text, a matching model or system needs to determine whether the two sentences have the same semantic meaning, a typical binary classification task. Early text matching methods were mostly based on statistical learning methods, such as BM25, but due to the lack of feature modeling at the semantic level of the text, their performance in practical applications was often poor. In recent years, with the rapid development of deep learning, a series of text matching methods based on static word vectors have emerged and are used to determine whether texts match.
[0003] In the era of deep learning, current mainstream text matching methods can be broadly categorized into two types: representation-based methods and interaction-based methods. Most representation-based methods employ Siamese network architectures, such as Siamese-LSTM, using metric learning to extract high-level features from two sentences, and then determining text similarity through distance calculation. These matching methods generally perform poorly due to a lack of consideration for the semantic relevance of the two sentences. Interaction-based methods, on the other hand, typically use attention mechanisms in their model structure to facilitate feature interaction between the two sentences, thus achieving better matching results. Most popular pre-trained models fall into the second category when applied to text matching tasks, and often possess capabilities far exceeding those of non-pre-trained methods.
[0004] The various text matching methods mentioned above, including traditional methods, all have one thing in common: they directly input the two texts to be compared into a single text matching model, and the model directly determines whether the two texts are the same without preprocessing the texts. This results in a decrease in the accuracy of the model's recognition and judgment after the texts are input into the model.
[0005] There is currently no effective solution to the problem of low accuracy in similarity judgment by inputting text into a single model in related technologies. Summary of the Invention
[0006] This application provides a text matching method, apparatus, storage medium, and electronic device to solve the problem of low accuracy in related technologies when similarity judgment is performed by inputting text into a single model.
[0007] According to one aspect of this application, a text matching method is provided. The method includes: obtaining initial text content sent by a user, and obtaining arbitrary object text content and the application scenario of the object text content from a database; determining whether the initial text content contains errors within the application scenario; if the initial text content does not contain errors, sequentially inputting the initial text content and the object text content into each model in a model cluster to obtain a similarity score output by each model, wherein the model cluster contains multiple machine learning models, each machine learning model being used to determine the similarity score between the initial text content and the object text content; inputting the multiple similarity scores into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content, and determining whether the initial text content and the object text content match based on the similarity determination result.
[0008] Optionally, determining whether the initial text content contains errors in the application scenario includes: segmenting the initial text content into words to obtain segmentation results, wherein the segmentation results include multiple words; retrieving historical word correction records for the application scenario from a dictionary database, and determining whether any of the multiple words exist in the historical word correction records to obtain a judgment result; if the judgment result indicates that at least one of the multiple words exists in the historical word correction records, determining that the initial text content contains errors; if the judgment result indicates that none of the multiple words exist in the historical word correction records, determining that the initial text content does not contain errors.
[0009] Optionally, the model cluster includes a word matching model. The initial text content and the target text content are input into the word matching model to obtain the similarity score output by the model. This process includes: segmenting the initial text content according to a first granularity and a second granularity to obtain a first segmentation result and a second segmentation result, where the first granularity is smaller than the second granularity; segmenting the target text content according to the first granularity and the second granularity to obtain a third segmentation result and a fourth segmentation result; inputting the first and third segmentation results with the same granularity into the word matching model to obtain a first similarity value; inputting the second and fourth segmentation results with the same granularity into the word matching model to obtain a second similarity value; and determining the similarity score output by the word matching model based on the first and second similarity values.
[0010] Optionally, the model cluster includes a relationship determination model. Inputting the initial text content and the object text content into the relationship determination model to obtain the similarity score output by the model includes: inputting the initial text content and the object text content into the relationship determination model to obtain a determination result, wherein the determination result is used to determine whether there is an inclusion relationship between the initial text content and the object text content; if the determination result indicates that there is an inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a first score; if the determination result indicates that there is no inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a second score, wherein the second score is less than the first score.
[0011] Optionally, the model cluster includes a first comparison model. Inputting the initial text content and the target text content into the first comparison model to obtain the similarity score output by the first comparison model includes: segmenting the initial text content and the target text content according to sentence components to obtain two sets of fifth segmentation results; inputting the two sets of fifth segmentation results into the first comparison model to obtain a first comparison result, wherein the first comparison model is used to determine whether there are antonyms among words with the same sentence components in the initial text content and the target text content, and the first comparison result includes the number of antonyms; obtaining the number of antonyms from the first comparison result, and determining the similarity score output by the first comparison model based on the number of antonyms.
[0012] Optionally, the model cluster includes a second comparison model. The initial text content and the target text content are input into the second comparison model to obtain the similarity score output by the second comparison model. This includes: determining the keywords in the initial text content through a dictionary to obtain the first keyword; determining the keywords in the target text content through a dictionary to obtain the second keyword; inputting the first keyword and the second keyword into the second comparison model to obtain the second comparison result, wherein the second comparison model is used to determine the similarity of the keywords in the text content; and determining the second comparison result as the similarity score output by the second comparison model.
[0013] Optionally, before determining the keywords in the initial text content through the dictionary to obtain the first keyword, the method further includes: determining whether both the initial text content and the object text content contain keywords through the dictionary; if neither the initial text content nor the object text content contains keywords, determining the similarity score output by the second comparison model as the second score; if neither the initial text content nor the object text content contains keywords, determining the similarity score output by the second comparison model as the first score.
[0014] According to another aspect of this application, a text matching apparatus is provided. The apparatus includes: an acquisition unit, configured to acquire initial text content sent by a user, and acquire any object text content and an application scenario of the object text content from a database; an input unit, configured to determine whether the initial text content contains errors in the application scenario, and if the initial text content does not contain errors, sequentially input the initial text content and the object text content into each model in a model cluster to obtain a similarity score output by each model, wherein the model cluster contains multiple machine learning models, and each machine learning model is used to determine the similarity score between the initial text content and the object text content; and a first determination unit, configured to input the multiple similarity scores into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content, and determine whether the initial text content and the object text content match based on the similarity determination result.
[0015] According to another aspect of the present invention, a computer storage medium is also provided for storing a program, wherein the program, when running, controls the device where the computer storage medium is located to execute a text matching method.
[0016] According to another aspect of the present invention, an electronic device is also provided, comprising one or more processors and a memory; the memory stores computer-readable instructions, and the processor is configured to execute the computer-readable instructions, wherein the computer-readable instructions execute a text matching method when they are executed.
[0017] This application employs the following steps: obtaining initial text content sent by a user, and acquiring any object text content and its application scenario from a database; determining whether the initial text content contains errors within the application scenario; if the initial text content is error-free, sequentially inputting the initial text content and object text content into each model in a model cluster to obtain a similarity score output by each model. The model cluster contains multiple machine learning models, each used to determine the similarity score between the initial text content and the object text content; inputting these multiple similarity scores into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content; and determining whether the initial text content and the object text content match based on the similarity determination result. This solves the problem of low accuracy in similarity judgments achieved by inputting text into a single model in related technologies. By first determining the correctness of the text content to be compared, and if the text content is error-free, multiple models sequentially judge the initial text content and the object text content to obtain multiple similarity results. These multiple similarity results are then combined for a comprehensive judgment, thereby achieving an accurate determination of whether two text contents match. Attached Figure Description
[0018] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0019] Figure 1 This is a flowchart of a text matching method provided according to an embodiment of this application;
[0020] Figure 2 This is a flowchart of the steps for determining the correctness of initial text according to an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of a text matching device provided according to an embodiment of this application;
[0022] Figure 4 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0023] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties. For example, this system has an interface with the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent from the aforementioned user or organization.
[0027] It should be noted that the text matching method, apparatus, storage medium and electronic device defined in this disclosure can be used in the field of artificial intelligence, or in any field other than artificial intelligence. The application fields of the text matching method, apparatus, storage medium and electronic device defined in this disclosure are not limited.
[0028] According to an embodiment of this application, a text matching method is provided.
[0029] Figure 1 This is a flowchart of a text matching method provided according to an embodiment of this application. For example... Figure 1 As shown, the method includes the following steps:
[0030] Step S101: Obtain the initial text content sent by the user, and obtain any object text content and the application scenario of the object text content from the database.
[0031] It should be noted that the comparison text content can be preset text with a pre-defined result. After obtaining the initial text content sent by the user, it is necessary to determine the information the user wants to obtain or the request the user wants to execute based on the initial text content. Then, the initial text content is compared with each comparison text content stored in the database in turn to determine the text information that is closest to the initial text content, and the preset result corresponding to that text is determined as the user's preset result.
[0032] Specifically, during text matching, the process begins by acquiring the initial text content sent by the user. This initial text content can represent the user's needs and can be input via voice or typing. After acquiring the initial text content, any one of the existing object text contents is selected to determine the similarity, or matching degree, between the initial text content and the object text content. After confirming the similarity between the initial text content and each object text content in turn, the object text content with the highest similarity is selected as the text content corresponding to the initial text content, and this information is then fed back to the user.
[0033] It should be added that after determining the content of the object text, the application scenario of the object text content should be determined first. Since the words that are prone to being misspelled are different in different scenarios, and the words used in different scenarios are different, word A may be an incorrect word in some scenarios, while word A is a correct word in other scenarios. Therefore, it is necessary to determine whether there are errors in the initial text content in the application scenario.
[0034] Step S102: Determine whether there is an error in the initial text content under the application scenario. If there is no error in the initial text content, input the initial text content and the object text content into each model in the model cluster in sequence to obtain the similarity score output by each model. There are multiple machine learning models in the model cluster, and each machine learning model is used to determine the similarity score between the initial text content and the object text content.
[0035] Specifically, assuming the initial text content is error-free, the initial text content and the target text content need to be input into multiple pre-trained machine learning models. In this way, the similarity scores between the initial text content and the target text content can be determined from multiple perspectives through multiple models, and thus the similarity between the initial text content and the target text content can be evaluated from multiple perspectives.
[0036] Step S103: Input multiple similarity scores into the logistic regression model to obtain the similarity determination results between the initial text content and the object text content, and determine whether the initial text content and the object text content match based on the similarity determination results.
[0037] Specifically, after obtaining multiple similarity scores, a logistic regression model can be used to classify and determine the multiple scoring results. The multiple similarity scores are used as features of different dimensions and are input into a binary logistic regression model to predict the final matching result, thereby determining whether the initial text content and the object text content are consistent. In determining whether they are consistent, the multiple similarity scores obtained above can be processed by the logistic regression model, and logistic regression calculation can be performed based on the multiple similarity scores to obtain a similarity score. The object text content with the highest similarity score among the initial text content and the multiple object text contents can be determined as the text most similar to the initial text content.
[0038] The text matching method provided in this application obtains initial text content sent by a user, and acquires any object text content and its application scenario from a database. Within the application scenario, it determines whether the initial text content contains errors. If the initial text content is error-free, it sequentially inputs the initial text content and the object text content into each model in a model cluster, obtaining a similarity score output by each model. The model cluster contains multiple machine learning models, each used to determine the similarity score between the initial text content and the object text content. These multiple similarity scores are then input into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content. Based on this similarity determination result, it is determined whether the initial text content and the object text content match. This method solves the problem of low accuracy in related technologies where similarity judgment is performed by inputting text into a single model. By first determining the correctness of the text content to be compared, and then, if the text content is error-free, using multiple models to sequentially judge the initial text content and the object text content, multiple similarity results are obtained. Finally, by combining these multiple similarity results, an accurate judgment is achieved regarding whether two pieces of text content match.
[0039] Optionally, Figure 2 This is a flowchart of the steps for determining the correctness of initial text according to an embodiment of this application, such as... Figure 2 As shown, in the text matching method provided in this application embodiment, step S102, determining whether there are errors in the initial text content under the application scenario, includes:
[0040] Step S201: Segment the initial text content into words to obtain segmentation results, wherein the segmentation results include multiple words; Step S202: Obtain historical word correction records for the application scenario from the dictionary database, and determine whether multiple words exist in the historical word correction records to obtain a judgment result; Step S203: If the judgment result indicates that at least one of the multiple words exists in the historical word correction records, determine that the initial text content has an error; Step S204: If the judgment result indicates that none of the multiple words exist in the historical word correction records, determine that the initial text content has no error.
[0041] Specifically, the correctness of the same word varies in different linguistic contexts. For example, in a school setting, the word "steel" is more likely to be incorrect, and the correct word is "just now." However, in a construction site setting, the word "steel" is correct.
[0042] Optionally, in the text matching method provided in this application embodiment, the model cluster includes a word matching model. Inputting the initial text content and the target text content into the word matching model to obtain the similarity score output by the word matching model includes: segmenting the initial text content according to a first granularity and a second granularity to obtain a first segmentation result and a second segmentation result, wherein the first granularity is smaller than the second granularity; segmenting the target text content according to the first granularity and the second granularity to obtain a third segmentation result and a fourth segmentation result; inputting the first segmentation result and the third segmentation result with the same granularity into the word matching model to obtain a first similarity value; inputting the second segmentation result and the fourth segmentation result with the same granularity into the word matching model to obtain a second similarity value; and determining the similarity score output by the word matching model based on the first similarity value and the second similarity value.
[0043] Specifically, word matching models can determine the similarity between two text contents by the degree of similarity between words. To improve the accuracy of word matching models, the initial text content can be segmented into words according to a first granularity and a second granularity, and the target text content can also be segmented into words according to a first granularity and a second granularity. This allows for word segmentation at two different granularities. For example, the first granularity segments each character once, while the second granularity segments every two characters once. This allows for comparison of the same text content at different granularities, thereby improving the accuracy of the similarity score.
[0044] Optionally, in the text matching method provided in this application embodiment, the model cluster includes a relationship determination model. Inputting the initial text content and the object text content into the relationship determination model to obtain the similarity score output by the relationship determination model includes: inputting the initial text content and the object text content into the relationship determination model to obtain a determination result, wherein the determination result is used to determine whether there is an inclusion relationship between the initial text content and the object text content; if the determination result indicates that there is an inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a first score; if the determination result indicates that there is no inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a second score, wherein the second score is less than the first score.
[0045] It should be noted that the relationship determination model can be trained using the first sample data. The first sample information can include multiple sets of text content with an inclusion relationship and multiple sets of text content without an inclusion relationship. After training the relationship determination model, the model can determine whether there is an inclusion relationship between two pieces of text content.
[0046] Specifically, after inputting the initial text content and the object text content into the relationship determination model and obtaining the determination result, if the determination result indicates that there is an inclusion relationship between the initial text content and the object text content, it can be determined that there is a large similarity between the initial text content and the object text content. Therefore, the similarity score can be determined as the first score. Similarly, if there is no inclusion relationship, the lower second score can be determined as the similarity score. However, this does not indicate that the similarity between the initial text content and the object text content is low. Other dimensions still need to be judged to determine the similarity between the initial text content and the object text content.
[0047] Optionally, in the text matching method provided in this application embodiment, the model cluster includes a first comparison model. Inputting the initial text content and the target text content into the first comparison model to obtain the similarity score output by the first comparison model includes: segmenting the initial text content and the target text content according to sentence components to obtain two sets of fifth segmentation results; inputting the two sets of fifth segmentation results into the first comparison model to obtain a first comparison result, wherein the first comparison model is used to determine whether there are antonyms among words with the same sentence components in the initial text content and the target text content, and the first comparison result includes the number of antonyms; obtaining the number of antonyms from the first comparison result, and determining the similarity score output by the first comparison model based on the number of antonyms.
[0048] Specifically, since comparing only words has low accuracy, the initial and target text content can also be segmented according to sentence components. That is, the two text contents are segmented according to the subject-verb-object sentence components, and the segmentation results are input into the first comparison model for comparison. This allows the existence of antonyms, i.e., opposing relationships, to be determined at the dimension of sentence components. For example, the initial text content can be "The weather is very good today," and the target text content can be "The weather is not good today." When determining similarity solely through word segmentation, the two sentences may be misjudged as having high similarity because they contain many identical words, even though they are not actually similar. By segmenting according to sentence components and identifying and detecting antonyms, and then, after determining the existence of multiple sets of antonyms, the similarity score can be scored according to the logarithm of the antonyms, thereby improving the accuracy of determining the similarity between the initial and target text content.
[0049] Optionally, in the text matching method provided in this application embodiment, the model cluster includes a second comparison model. Inputting the initial text content and the target text content into the second comparison model to obtain the similarity score output by the second comparison model includes: determining the keywords in the initial text content through a dictionary to obtain a first keyword; determining the keywords in the target text content through a dictionary to obtain a second keyword; inputting the first keyword and the second keyword into the second comparison model to obtain a second comparison result, wherein the second comparison model is used to determine the similarity of the keywords in the text content; and determining the second comparison result as the similarity score output by the second comparison model.
[0050] Specifically, the dictionary also stores multiple keywords, which can be important entity words, such as place names, personal names, proper nouns, etc. Keywords can be obtained from the initial text content and the target text content respectively, and multiple keywords are input into the second comparison model for comparison. In this way, the similarity score between the initial text content and the target text content is determined by determining the similarity between the keywords.
[0051] Optionally, in the text matching method provided in this application embodiment, before determining the keywords in the initial text content through the dictionary to obtain the first keyword, the method further includes: determining whether both the initial text content and the object text content contain keywords through the dictionary; if neither the initial text content nor the object text content contains keywords, determining the similarity score output by the second comparison model as the second score; if neither the initial text content nor the object text content contains keywords, determining the similarity score output by the second comparison model as the first score.
[0052] Specifically, when determining keywords, there may be cases where keywords do not exist. If either the initial text content or the target text content does not contain keywords, but the other text content does, the similarity score is determined as the second score, for example, 0.5 points. If neither the initial text content nor the target text content contains keywords, the similarity score is determined as the first score, for example, 1 point. Thus, when a similarity score cannot be determined through the second comparison model, the similarity score of the second comparison model is determined, ensuring the accuracy of subsequent calculations using similarity scores across multiple dimensions.
[0053] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0054] This application also provides a text matching device. It should be noted that the text matching device of this application can be used to execute the text matching method provided in this application. The text matching device provided in this application is described below.
[0055] Figure 3 This is a schematic diagram of a text matching device provided according to an embodiment of this application. For example... Figure 3 As shown, the device includes: an acquisition unit 31, an input unit 32, and a first determination unit 33.
[0056] The acquisition unit 31 is used to acquire the initial text content sent by the user, and to acquire any object text content and the application scenario of the object text content in the database.
[0057] Input unit 32 is used to determine whether there are errors in the initial text content in the application scenario. If there are no errors in the initial text content, the initial text content and the object text content are sequentially input into each model in the model cluster to obtain the similarity score output by each model. There are multiple machine learning models in the model cluster, and each machine learning model is used to determine the similarity score between the initial text content and the object text content.
[0058] The first determining unit 33 is used to input multiple similarity scores into the logistic regression model to obtain the similarity determination results between the initial text content and the object text content, and to determine whether the initial text content and the object text content match based on the similarity determination results.
[0059] The text matching device provided in this application embodiment acquires the initial text content sent by the user through the acquisition unit 31, and acquires any object text content and the application scenario of the object text content from the database. The input unit 32 determines whether there is an error in the initial text content under the application scenario. If there is no error in the initial text content, the initial text content and the object text content are sequentially input into each model in the model cluster to obtain the similarity score output by each model. The model cluster contains multiple machine learning models, and each machine learning model is used to determine the similarity score between the initial text content and the object text content. The first determination unit 33 inputs the multiple similarity scores into the logistic regression model to obtain the similarity determination result between the initial text content and the object text content, and determines whether the initial text content and the object text content match based on the similarity determination result. This solves the problem of low accuracy in similarity judgment by inputting text into a single model in related technologies. By first determining whether the text content to be compared is correct, and if the text content is correct, multiple models sequentially judge the initial text content and the object text content to obtain multiple similarity results. The judgment is then made by combining the multiple similarity results, thereby achieving the effect of accurately judging whether the two text contents match.
[0060] Optionally, in the text matching device provided in this application embodiment, the input unit 32 includes: a first word segmentation module, used to segment the initial text content into words to obtain a word segmentation result, wherein the word segmentation result includes multiple words; a first judgment module, used to obtain historical word correction records in the application scenario from a dictionary database, and to determine whether multiple words exist in the historical word correction records to obtain a judgment result; a first determination module, used to determine that the initial text content has an error when the judgment result indicates that at least one of the multiple words exists in the historical word correction records; and a second determination module, used to determine that the initial text content does not have an error when the judgment result indicates that none of the multiple words exist in the historical word correction records.
[0061] Optionally, in the text matching device provided in this application embodiment, the model cluster includes a word matching model, and the input unit 32 includes: a second word segmentation module, used to segment the initial text content according to a first granularity and a second granularity to obtain a first word segmentation result and a second word segmentation result, wherein the first granularity is smaller than the second granularity; a third word segmentation module, used to segment the object text content according to the first granularity and the second granularity to obtain a third word segmentation result and a fourth word segmentation result; a first input module, used to input the first word segmentation result and the third word segmentation result with the same granularity into the word matching model to obtain a first similarity value; a second input module, used to input the second word segmentation result and the fourth word segmentation result with the same granularity into the word matching model to obtain a second similarity value; and a third determination module, used to determine the similarity score output by the word matching model through the first similarity value and the second similarity value.
[0062] Optionally, in the text matching device provided in this application embodiment, the model cluster includes a relationship determination model, and the input unit 32 includes: a third input module, used to input the initial text content and the object text content into the relationship determination model to obtain a determination result, wherein the determination result is used to determine whether there is an inclusion relationship between the initial text content and the object text content; a fourth determination module, used to determine the similarity score output by the relationship determination model as a first score when the determination result indicates that there is an inclusion relationship between the initial text content and the object text content; and a fifth determination module, used to determine the similarity score output by the relationship determination model as a second score when the determination result indicates that there is no inclusion relationship between the initial text content and the object text content, wherein the second score is less than the first score.
[0063] Optionally, in the text matching device provided in this application embodiment, the model cluster includes a first comparison model, and the input unit 32 includes: a fourth word segmentation module, used to segment the initial text content and the object text content according to sentence components to obtain two sets of fifth word segmentation results; a fourth input module, used to input the two sets of fifth word segmentation results into the first comparison model to obtain a first comparison result, wherein the first comparison model is used to determine whether there are antonyms among words with the same sentence components in the initial text content and the object text content, and the first comparison result includes the number of antonyms; and a sixth determination module, used to obtain the number of antonyms from the first comparison result and determine the similarity score output by the first comparison model based on the number of antonyms.
[0064] Optionally, in the text matching device provided in this application embodiment, the model cluster includes a second comparison model, and the input unit 32 includes: a seventh determining module, used to determine the keywords in the initial text content through a dictionary to obtain a first keyword; an eighth determining module, used to determine the keywords in the object text content through a dictionary to obtain a second keyword; a fifth input module, used to input the first keyword and the second keyword into the second comparison model to obtain a second comparison result, wherein the second comparison model is used to determine the similarity of the keywords in the text content; and a ninth determining module, used to determine the second comparison result as the similarity score output by the second comparison model.
[0065] Optionally, in the text matching apparatus provided in this application embodiment, before determining the keywords in the initial text content through a dictionary to obtain the first keyword, the apparatus further includes: a second determining unit, used to determine whether both the initial text content and the object text content contain keywords through a dictionary; a third determining unit, used to determine the similarity score output by the second comparison model as the second score when neither the initial text content nor the object text content contains keywords; and a fourth determining unit, used to determine the similarity score output by the second comparison model as the first score when neither the initial text content nor the object text content contains keywords.
[0066] The aforementioned text matching device includes a processor and a memory. The aforementioned acquisition unit 31, input unit 32, first determination unit 33, etc., are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0067] The processor contains a kernel, which retrieves the corresponding program unit from memory. One or more kernels can be configured, and adjusting kernel parameters addresses the low accuracy problem in related technologies where similarity assessments are performed by inputting text into a single model.
[0068] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0069] This invention provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the text matching method.
[0070] This invention provides a processor for running a program, wherein the program executes the text matching method during runtime.
[0071] like Figure 4As shown, this embodiment of the invention provides an electronic device 40, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: obtaining initial text content sent by a user, and obtaining any object text content and its application scenario from a database; determining whether the initial text content contains errors within the application scenario; if the initial text content does not contain errors, sequentially inputting the initial text content and the object text content into each model in a model cluster to obtain a similarity score output by each model. The model cluster contains multiple machine learning models, each used to determine the similarity score between the initial text content and the object text content; inputting the multiple similarity scores into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content, and determining whether the initial text content and the object text content match based on the similarity determination result. The device in this article can be a server, PC, PAD, mobile phone, etc.
[0072] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: obtaining initial text content sent by a user, and obtaining any object text content and the application scenario of the object text content from a database; determining whether the initial text content has errors in the application scenario; if the initial text content has no errors, sequentially inputting the initial text content and the object text content into each model in a model cluster to obtain a similarity score output by each model, wherein the model cluster contains multiple machine learning models, each machine learning model is used to determine the similarity score between the initial text content and the object text content; inputting the multiple similarity scores into a logistic regression model to obtain a similarity determination result between the initial text content and the object text content, and determining whether the initial text content and the object text content match based on the similarity determination result.
[0073] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0074] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0075] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0076] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0077] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0078] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0079] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0080] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0081] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A text matching method, characterized in that, include: Get the initial text content sent by the user, and get any object text content in the database and the application scenario of the object text content; In the application scenario, it is determined whether the initial text content has errors. If the initial text content has no errors, the initial text content and the object text content are sequentially input into each model in the model cluster to obtain the similarity score output by each model. The model cluster contains multiple machine learning models, and each machine learning model is used to determine the similarity score between the initial text content and the object text content. Multiple similarity scores are input into a logistic regression model to obtain the similarity determination result between the initial text content and the object text content, and the similarity determination result is used to determine whether the initial text content and the object text content match. The model cluster includes a word matching model. Inputting the initial text content and the target text content into the word matching model to obtain the similarity score output by the word matching model includes: segmenting the initial text content into words according to a first granularity and a second granularity to obtain a first segmentation result and a second segmentation result, wherein the first granularity is smaller than the second granularity; segmenting the target text content into words according to the first granularity and the second granularity to obtain a third segmentation result and a fourth segmentation result; inputting the first segmentation result and the third segmentation result with the same granularity into the word matching model to obtain a first similarity value; inputting the second segmentation result and the fourth segmentation result with the same granularity into the word matching model to obtain a second similarity value; and determining the similarity score output by the word matching model based on the first similarity value and the second similarity value. The model cluster includes a relationship determination model. Inputting the initial text content and the object text content into the relationship determination model to obtain a similarity score output by the model includes: inputting the initial text content and the object text content into the relationship determination model to obtain a determination result, wherein the determination result is used to determine whether there is an inclusion relationship between the initial text content and the object text content; if the determination result indicates that there is an inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a first score; if the determination result indicates that there is no inclusion relationship between the initial text content and the object text content, the similarity score output by the relationship determination model is determined as a second score, wherein the second score is less than the first score. The model cluster includes a first comparison model. Inputting the initial text content and the object text content into the first comparison model to obtain the similarity score output by the first comparison model includes: segmenting the initial text content and the object text content according to sentence components to obtain two sets of fifth segmentation results; inputting the two sets of fifth segmentation results into the first comparison model to obtain a first comparison result, wherein the first comparison model is used to determine whether there are antonyms among words with the same sentence components in the initial text content and the object text content, and the first comparison result includes the number of antonyms; obtaining the number of antonyms from the first comparison result, and determining the similarity score output by the first comparison model based on the number of antonyms.
2. The method according to claim 1, characterized in that, Determining whether the initial text content contains errors in the application scenario includes: The initial text content is segmented into words to obtain segmentation results, wherein the segmentation results include multiple words; The historical word correction records for the application scenario are obtained from the dictionary database, and it is determined whether any of the multiple words exist in the historical word correction records to obtain the judgment result; If the judgment result indicates that at least one of the multiple words exists in the historical word correction record, it is determined that the initial text content contains an error; If the judgment result indicates that none of the multiple words exist in the historical word correction record, it is determined that the initial text content is free of errors.
3. The method according to claim 1, characterized in that, The model cluster includes a second comparison model. The initial text content and the object text content are input into the second comparison model, and the similarity score output by the second comparison model includes: The first keyword is obtained by identifying keywords in the initial text content using a dictionary. The second keyword is obtained by identifying keywords in the object text content using the dictionary database. The first keyword and the second keyword are input into the second comparison model to obtain a second comparison result, wherein the second comparison model is used to determine the similarity of keywords in the text content; The second comparison result is determined as the similarity score output by the second comparison model.
4. The method according to claim 3, characterized in that, Before determining the keywords in the initial text content through a dictionary to obtain the first keyword, the method further includes: The dictionary is used to determine whether the keyword exists in both the initial text content and the object text content. If the keyword is not present in the initial text content or the object text content, the similarity score output by the second comparison model is determined as the second score; If the keyword is not present in either the initial text content or the object text content, the similarity score output by the second comparison model is determined as the first score.
5. A text matching device, characterized in that, include: The acquisition unit is used to acquire the initial text content sent by the user, and to acquire any object text content in the database and the application scenario of the object text content; An input unit is used to determine whether the initial text content has errors in the application scenario. If the initial text content has no errors, the initial text content and the object text content are sequentially input into each model in the model cluster to obtain the similarity score output by each model. The model cluster contains multiple machine learning models, and each machine learning model is used to determine the similarity score between the initial text content and the object text content. The first determining unit is used to input multiple similarity scores into a logistic regression model to obtain the similarity determination result between the initial text content and the object text content, and to determine whether the initial text content and the object text content match based on the similarity determination result; The model cluster includes a word matching model. The input units include: a second word segmentation module, used to segment the initial text content according to a first granularity and a second granularity, obtaining a first word segmentation result and a second word segmentation result, where the first granularity is smaller than the second granularity; a third word segmentation module, used to segment the object text content according to a first granularity and a second granularity, obtaining a third word segmentation result and a fourth word segmentation result; a first input module, used to input the first and third word segmentation results of the same granularity into the word matching model to obtain a first similarity value; a second input module, used to input the second and fourth word segmentation results of the same granularity into the word matching model to obtain a second similarity value; and a third determination module, used to determine the similarity score output by the word matching model based on the first and second similarity values. The model cluster includes a relationship determination model. The input units include: a third input module, used to input the initial text content and the object text content into the relationship determination model to obtain a determination result, wherein the determination result is used to determine whether an inclusion relationship exists between the initial text content and the object text content; a fourth determination module, used to determine the similarity score output by the relationship determination model as a first score if the determination result indicates that an inclusion relationship exists between the initial text content and the object text content; and a fifth determination module, used to determine the similarity score output by the relationship determination model as a second score if the determination result indicates that no inclusion relationship exists between the initial text content and the object text content, wherein the second score is less than the first score. The model cluster includes a first comparison model, and the input units include: a fourth word segmentation module, which segments the initial text content and the target text content according to sentence components to obtain two sets of fifth word segmentation results; a fourth input module, which inputs the two sets of fifth word segmentation results into the first comparison model to obtain a first comparison result, wherein the first comparison model is used to determine whether there are antonyms among words with the same sentence components in the initial text content and the target text content, and the first comparison result includes the number of antonyms; and a sixth determination module, which obtains the number of antonyms from the first comparison result and determines the similarity score output by the first comparison model based on the number of antonyms.
6. A computer storage medium, characterized in that, The computer storage medium is used to store a program, wherein the program, when running, controls the device where the computer storage medium is located to execute the text matching method according to any one of claims 1 to 4.
7. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the text matching method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Intelligent voice calling-out method, apparatus, computer device and storage medium
CA3140472A1
Information correction method and device, electronic equipment and storage medium
CN110738997A