Method and device for identifying text match, electronic device and storage medium
By searching for synonymous text pairs in the matching text pair library and utilizing vector transformation and fully connected networks, the problem of low recognition accuracy caused by inconsistent names of different treatments for the same disease was solved, achieving higher text matching accuracy.
Patent Information
- Application Number
- CN202211460830.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-11-17
AI Technical Summary
In existing technologies, the disease names of different treatments for the same disease are inconsistent, resulting in low accuracy of manual text matching and insufficient labeled data affecting the model training effect.
By searching for synonymous text pairs in a matching text pair library, and utilizing vector transformation and a fully connected network, the system indirectly determines whether the first text and the second text match, thereby improving recognition accuracy.
It improves the accuracy of text matching, avoids the problem of low recognition accuracy due to insufficient labeled data, and enhances the accuracy of identifying the same disease.
Smart Images

Figure CN115757700B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device and storage medium for recognizing text matching. Background Technology
[0002] Currently, claims processing requires identifying multiple treatments for the same disease to calculate the claim amount. However, doctors may diagnose different diseases at different treatments for the same illness, resulting in inconsistent disease names on medical records. Current technologies typically rely on manual identification to determine if two different disease names refer to the same disease, but this method has low accuracy. Therefore, developing a text matching method that improves accuracy has become a pressing technical problem. Summary of the Invention
[0003] The main objective of this application is to propose a method, apparatus, electronic device, and storage medium for identifying text matching, which can improve the accuracy of identifying text matching.
[0004] To achieve the above objectives, a first aspect of this application proposes a method for identifying text matching, the method comprising:
[0005] Obtain a first text pair, which includes a first text and a second text;
[0006] The first text is searched in the matching text pair library to obtain the second text pair, wherein the second text pair is a matching text pair in the matching text pair library, the second text pair includes the third text and the fourth text, and the third text is a synonym of the first text;
[0007] The first text pair is transformed into a vector to obtain a first vector, and the second text pair is transformed into a vector to obtain a second vector;
[0008] Based on the matching degree of the first vector and the second vector, the matching relationship between the second text and the fourth text is determined;
[0009] Based on the matching relationship between the second text and the fourth text, it is determined whether the first text and the second text match.
[0010] In some embodiments, the step of searching the matching text pair library based on the first text to obtain the second text pair includes:
[0011] Obtain the search keywords from the first text;
[0012] The search is performed in the matching text pair library according to the search keywords to obtain the third text containing the search keywords;
[0013] The third text pair containing the search keyword is filtered from the matching text pairs in the matching text pair library to obtain the second text pair.
[0014] In some embodiments, the matching text pairs include candidate texts, and the matching text pair library further includes candidate keywords of the candidate texts. The step of searching the matching text pair library based on the search keywords of the first text to obtain the third text containing the search keywords includes:
[0015] Based on the search keywords, a matching word judgment is performed on each candidate keyword in the matching text pair library to obtain the judgment result;
[0016] Based on the judgment result, the candidate texts are filtered to obtain the third text containing the search keywords.
[0017] In some embodiments, the matching text pair includes candidate text, the candidate text including at least one second text segment, and the step of searching the matching text pair library based on the first text to obtain the second text pair includes:
[0018] The first text is segmented into words to obtain at least one segment of the first text.
[0019] For each candidate text, the same word segment is obtained by comparing the first text segmentation and the second text segmentation;
[0020] The text matching degree between the first text and the candidate text is determined based on the number of words with the same word segmentation.
[0021] Based on the text matching degree, the candidate texts are filtered to obtain the third text;
[0022] The matching text pair of the third text in the matching text pair library is taken as the second text pair.
[0023] In some embodiments, determining the text matching degree between the first text and the candidate text based on the number of words with the same word segmentation includes:
[0024] Obtain the word weight for each identical word segment, whereby the word weight is used to characterize the importance of the identical word segment;
[0025] In each of the same word segments, the word matching degree of the same word segment is determined according to the word weight and the number of words;
[0026] The text matching degree is determined based on the word matching degree.
[0027] In some embodiments, before determining the matching relationship between the second text and the fourth text based on the matching degree of the first vector and the second vector, the method further includes:
[0028] The first vector and the second vector are input into a preset fully connected network, and the first vector and the second vector are numerically mapped through the fully connected network to obtain a vector matching score;
[0029] Based on the vector matching score, the matching degree between the first vector and the second vector is determined.
[0030] In some embodiments, the method further includes, before inputting the first vector and the second vector into a preset fully connected network:
[0031] Pre-training the fully connected network includes:
[0032] Obtain the first sample text pair and obtain the original matching score of the first sample text pair; the first sample text pair includes the first sample text and the second sample text.
[0033] The first sample text is searched in the matching text pair library to obtain the second sample text pair, wherein the second sample text pair is a matching text pair in the matching text pair library, the second sample text pair includes the third sample text and the fourth sample text, and the third sample text is a synonym of the first sample text;
[0034] The first sample text pair is vectorized to obtain a first sample vector, and the second sample text pair is vectorized to obtain a second sample vector;
[0035] The first sample vector and the second sample vector are input into the fully connected network, and the first sample vector and the second sample vector are numerically mapped through the fully connected network to obtain the target matching score.
[0036] The loss value of the fully connected network is determined based on the target matching score and the original matching score.
[0037] The parameters of the fully connected network are adjusted based on the loss value to obtain the trained fully connected network.
[0038] To achieve the above objectives, a second aspect of this application provides an apparatus for recognizing text matching, the apparatus comprising:
[0039] A text acquisition module is used to acquire a first text pair, wherein the first text pair includes a first text and a second text;
[0040] The text search module is used to search in the matching text pair library based on the first text to obtain a second text pair, wherein the second text pair is a matching text pair in the matching text pair library, the second text pair includes a third text and a fourth text, and the third text is a synonym of the first text;
[0041] The text conversion module is used to perform vector conversion on the first text pair to obtain a first vector, and to perform vector conversion on the second text pair to obtain a second vector;
[0042] The preliminary matching module is used to determine the matching relationship between the second text and the fourth text based on the matching degree between the first vector and the second vector;
[0043] The target matching module is used to determine whether the first text and the second text match based on the matching relationship between the second text and the fourth text.
[0044] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.
[0045] To achieve the above objectives, a fourth aspect of the present application provides a storage medium, which is a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.
[0046] This application proposes a method, apparatus, electronic device, and storage medium for identifying text matching. The method includes: acquiring a first text pair, the first text pair comprising a first text and a second text; searching a matching text pair library based on the first text to obtain a second text pair; performing vector transformation on the first text pair to obtain a first vector, and performing vector transformation on the second text pair to obtain a second vector; determining a matching relationship between the second text and a fourth text based on the matching degree of the first vector and the second vector; and determining whether the first text and the second text match based on the matching relationship of the second text and the fourth text. This application's embodiments transform the identification of whether the first text and the second text match into the identification of whether the first text and the second text match by searching for the second text pair using the first text. Because it utilizes pre-annotated matching text pairs, it improves the accuracy of identifying text matching. Attached Figure Description
[0047] Figure 1 This is a schematic diagram of the system architecture for performing a method for identifying text matching provided in an embodiment of this application;
[0048] Figure 2 This is a flowchart of the text matching recognition method provided in the embodiments of this application;
[0049] Figure 3 yes Figure 2 The flowchart of step S102 in the document;
[0050] Figure 4 yes Figure 3 The flowchart of step S203 in the process;
[0051] Figure 5 yes Figure 2 The flowchart of step S102 in the document;
[0052] Figure 6 This is a flowchart of a method for recognizing text matching provided in another embodiment of this application;
[0053] Figure 7 This is a flowchart of a method for recognizing text matching provided in another embodiment of this application;
[0054] Figure 8 This is a block diagram of the module structure of the text matching recognition device provided in the embodiments of this application;
[0055] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0057] It should be noted that although functional modules are divided in the device schematic diagram and a 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 aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0059] First, let's analyze some of the terms used in this application:
[0060] Artificial intelligence (AI) is a new branch of computer science that studies, develops, and applies theories, methods, technologies, and systems to simulate, extend, and expand human intelligence. It aims to understand the essence of intelligence and produce intelligent machines that can react in a way similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thought. Furthermore, AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results.
[0061] Natural Language Processing (NLP): NLP uses computers to process, understand, and utilize human language (such as Chinese and English). NLP is a branch of artificial intelligence and an interdisciplinary field of computer science and linguistics, often referred to as computational linguistics. NLP includes syntactic analysis, semantic analysis, and discourse understanding. It is commonly used in machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information and image processing, information extraction and filtering, text classification and clustering, sentiment analysis, and opinion mining. It involves data mining, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computation.
[0062] In claims processing, customers often undergo multiple treatments for the same illness. Identifying these multiple treatments for the same illness is crucial for calculating the claim amount. However, the diagnoses from different doctors for the same illness may differ, resulting in inconsistent wording on medical records. Current technologies typically rely on manual identification to determine if two different disease names refer to the same illness, but this method suffers from low accuracy. Alternatively, text matching models can be used to match the disease names from multiple treatments; a match indicates the same disease, otherwise different diseases. However, text matching requires extensive labeled reference data for model training. Labeling data is complex and manual, resulting in insufficient labeled pairs of identical disease names for training, further contributing to low accuracy. Furthermore, the relatively short length of disease names increases the difficulty of existing text matching models, further hindering accuracy. Therefore, providing a method for improving text matching accuracy has become a pressing technical challenge.
[0063] Based on this, the main objective of this application is to propose a method, apparatus, electronic device, and storage medium for identifying text matching. The aim is to transform the identification of whether first and second texts match into the identification of whether first text pairs match second text pairs by searching for second text pairs using first text. By utilizing pre-annotated matching text pairs, the accuracy of text matching is improved. Furthermore, this application avoids the technical problem of low accuracy in text matching due to insufficient annotated data.
[0064] The text matching method provided in this application can be applied to a server, or it can be software running on a terminal or server. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, 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 matching method, but is not limited to the above forms.
[0065] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include server computers, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions that are 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. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0066] This application provides a method for identifying text matching, as well as an apparatus, electronic device, and storage medium for identifying text matching. The specific implementation details are provided in the following embodiments. First, the method for identifying text matching in this application is described.
[0067] Reference Figure 1 The text matching method of this application embodiment can be executed by the target server 400 alone, or by the first terminal 100, the second terminal 200 or the third terminal 300 alone, or by the first terminal 100, the second terminal 200, the third terminal 300 and the target server 400 together.
[0068] Figure 2 This is an optional flowchart of the text matching identification method provided in the embodiments of this application, which may include, but is not limited to, steps S101 to S105.
[0069] Step S101: Obtain the first text pair, which includes the first text and the second text;
[0070] Step S102: Search the matching text pair library according to the first text to obtain the second text pair, wherein the second text pair is a matching text pair in the matching text pair library, the second text pair includes the third text and the fourth text, and the third text is a synonym of the first text;
[0071] Step S103: Perform vector transformation on the first text pair to obtain the first vector, and perform vector transformation on the second text pair to obtain the second vector;
[0072] Step S104: Based on the matching degree of the first vector and the second vector, determine the matching relationship between the second text and the fourth text;
[0073] Step S105: Based on the matching relationship between the second text and the fourth text, determine whether the first text and the second text match.
[0074] In steps S101 to S105 of this embodiment, before determining whether the first text and the second text match, a matching text pair is searched in the matching text pair library based on the first text. The third text in both the first and second text pairs is a synonym, and the third text and the fourth text constitute a matching text pair in the matching text pair library. Vector transformations are performed on the first and second text pairs to obtain a first vector and a second vector. The matching degree of the first and second vectors is then used to determine whether they match. Since the first text in the first vector and the third text in the second vector are synonyms, the matching relationship between the second and fourth texts can be determined based on the matching degree of the first and second vectors. Finally, the matching relationship between the second and fourth texts is used to determine whether the first and fourth texts match. In summary, this embodiment transforms the method of identifying whether the first and second texts match into identifying whether the first text pair matches the second text pair by searching for the second text pair using the first text. By utilizing pre-annotated matching text pairs, the accuracy of identifying text matching is improved. Furthermore, the embodiments of this application avoid the technical problem of low accuracy in text matching due to insufficient labeled data.
[0075] It should be noted that existing text matching algorithms generally determine whether a match exists based on the text similarity between a first text and a second text. However, if the first and second texts are too short, text similarity alone cannot accurately identify whether they match, resulting in low accuracy. In this embodiment, instead of directly matching the first and second texts, the algorithm searches for a second text pair associated with the first text in a matching text pair database. The match is then indirectly determined by comparing the first and second text pairs. This avoids the low accuracy problem caused by short text lengths and, by utilizing pre-annotated matching text pairs, significantly improves the accuracy of text matching.
[0076] In step S101 of some embodiments, a first text pair is obtained, which includes a first text and a second text. The text matching method of this application can be applied to the medical field, such as in medical claims services, so the first text and the second text can be disease names. The text matching method of this application can also be applied to the financial field, such as the categorized sale of goods, so the first text and the second text can also be product names.
[0077] In this embodiment, we will use the example where both the first text and the second text are disease names. For example, the first text might be "intracranial space-occupying lesion, highly probable inflammatory lesion," and the second text might be "intracranial lesion, highly probable ischemic lesion." As can be seen from the above, although both the first text and the second text are disease names, their descriptions of the diseases differ. To determine whether they refer to the same disease, it is necessary to identify whether the first text and the second text match.
[0078] In actual claims processing, the target group (user) includes multiple treatment records, each corresponding to a disease name. If the disease names are the same, the treatment records will be combined for claims. Therefore, it is necessary to determine whether different disease names refer to the same disease. In one example, multiple treatment records of the target group are obtained; text recognition is performed on each treatment record to obtain the disease name text containing disease keywords; any two disease name texts are combined to obtain the first text pair. For example, the first text (disease name text 1) appears in treatment record 1, and the second text (disease name text 2) appears in treatment record 2. Combining the first text and the second text yields the first text pair.
[0079] Specifically, each treatment record includes the disease name, treatment plan, and other text. Therefore, text recognition of the treatment record yields multiple candidate texts. These candidate texts are then filtered based on disease keywords to obtain the candidate text containing those keywords, i.e., the disease name text containing the disease keywords. It should be noted that text recognition of the treatment record can be performed using an optical character recognition model or other text recognition models (such as a CRNN model). Disease keywords include words such as "disease," "lesion," and "occupying lesion," which are not specifically limited in this embodiment.
[0080] In actual claims processing, the same disease name can be divided into multiple sub-disease names. Therefore, even if the disease names on different insurance policies are different, claims can still be processed uniformly. Thus, before purchasing insurance, a target can check whether two similar but not identical disease names belong to the same disease to select the appropriate insurance. In another example, the system receives the target's input text and obtains the first text pair. It should be noted that the input text must contain at least two disease names. If the input text contains two disease names, the first text pair is obtained based on the input text. If the input text contains three or more disease names, pairings are performed based on the input text to obtain at least two first text pairs.
[0081] The matching text pair library of this application stores multiple matching text pairs. Each matching text pair includes a first candidate text and a second candidate text, and the first candidate text and the second candidate text match each other. However, in practical applications, it has been found that in the matching text pair library, there may be matching relationships between any two first candidate texts, between any two second candidate texts, or between first candidate texts and second candidate texts located in different matching text pairs. Therefore, in order to further discover more matching text pairs, the matching text pair library needs to be reorganized. Specifically, in another example, text is randomly selected from any matching text pair to obtain a third text; text is randomly selected from other matching text pairs to obtain a fourth text; the third text and the fourth text are combined to obtain a first text pair. It should be noted that the matching text pair library stores multiple matching text pairs. The first text pair obtained by random selection in this example is not an original matching text pair in the matching text pair library, but a combination of different matching text pairs. For example, the first text pair in this example may include the first candidate text of matching text pair A and the first candidate text of matching text pair B. The first text pair in this example may also include the first candidate text matching text pair A and the second candidate text matching text pair B.
[0082] In step S102 of some embodiments, the matching text pair library is a text database that stores multiple matching text pairs. Each matching text pair includes two candidate texts, specifically a first candidate text and a second candidate text. A search is performed in the matching text pair library based on the first text to obtain candidate texts that are synonyms of the first text (this candidate text can be either the first or the second candidate text), and this candidate text is used as the third text. Since the candidate texts are stored as matching text pairs in the matching text pair library, the other text in the matching text pair is used as the fourth text, ultimately resulting in a second text pair consisting of the third and fourth texts.
[0083] In one example, step S102 specifically includes:
[0084] The text similarity between the first text and the candidate texts in the matching text pair library is calculated to obtain the similarity score.
[0085] If the similarity is greater than the preset similarity threshold, the candidate text is taken as the third text, and the corresponding matching text pair is determined based on the third text. The other candidate text of the matching text pair is taken as the fourth text.
[0086] The second text pair is obtained from the third and fourth texts.
[0087] Specifically, in this embodiment, whether the similarity of the text is higher than the similarity threshold is used as the judgment condition for synonymous texts, which can ensure the synonymous degree between the third text and the first text, and help improve the accuracy of subsequent recognition of whether the first text and the second text match.
[0088] It should be noted that calculating the text similarity between the first text and the candidate texts in the matching text pair library to obtain the similarity specifically includes:
[0089] Converting the first text into a vector to obtain a third vector, and converting the candidate text into a vector to obtain a fourth vector;
[0090] Calculating the cosine distance or Euclidean distance based on the third vector and the fourth vector to obtain the similarity.
[0091] In one example, a second text pair is obtained from the third text and the fourth text, and the second text pair is composed of the third text and the fourth text. In another example, the third text and the third text can be filtered, and the second text pair includes the filtered third text and the filtered fourth text. This filtering process can be to filter out some meaningless word segmentations, such as: "de", "di", "de", and other word segmentations.
[0092] In one example, step S102 specifically includes:
[0093] Calculating the text similarity between the first text and the candidate texts in the matching text pair library to obtain the similarity;
[0094] Arranging the candidate similar texts in order according to the similarity to obtain a sorting result; screening the candidate texts according to the sorting result to obtain a third text, and determining the corresponding matching text pair according to the third text, and taking the other candidate text of the matching text pair as the fourth text;
[0095] Obtaining a second text pair from the third text and the fourth text.
[0096] Specifically, select the top 5 candidate texts according to the sorting result as the third text, and take the matching text of the third text as the fourth text.
[0097] In some embodiments, the matching text pair includes candidate texts, and the candidate texts include at least one second text word segmentation. Refer to Figure 3 , step S102 specifically includes but is not limited to steps S201 to S205:
[0098] Step S201, segment the first text to obtain at least one first text word segmentation;
[0099] Step S202, for each candidate text, obtain the same word segmentations according to the comparison between the first text word segmentations and the second text word segmentations;
[0100] Step S203: Determine the text matching degree between the first text and the candidate text based on the number of words with the same word segmentation;
[0101] Step S204: Based on text matching degree, filter the candidate texts to obtain the third text;
[0102] Step S205: Use the matching text pair of the third text in the matching text pair library as the second text pair.
[0103] In steps S201 to S205 of this embodiment, before determining the third text, the identical word segments between the first text and the candidate text are identified, and the number of identical word segments is counted. The text matching degree is determined based on the number of words. The higher the text matching degree, the more closely the first text and the candidate text match. The candidate text is then filtered based on the text matching degree to obtain the third text. The third text can be the candidate text with the highest text matching degree. The third text can also be a candidate text with a text matching degree higher than a preset matching degree threshold. Finally, the matching text pair is determined based on the third text, and the other candidate text of the matching text pair is taken as the fourth text. Then, the third text and the fourth text are combined to obtain the second text pair.
[0104] For example, the first text is "intracranial space-occupying lesion with a high probability of inflammatory lesion," and the candidate text is "intracranial lesion with a high probability of ischemic lesion." The same word segmentation includes at least "intracranial," "intracranial," "lesion," and "high probability." The corresponding word count is 1 for each of these, resulting in a total of 4 words. In one example, a lookup table can be used to obtain the text matching degree corresponding to the word count. For example, if the word count is 4, the text matching degree is 80; if the word count is 3, the text matching degree is 60. In another example, the text matching degree can be obtained by comparing the word count with the length of the first text (which refers to the total number of words in the first text). For example, if the word count is 4 and the length of the first text is 10, the text matching degree is 80 (200*4 / 10) according to the formula: coefficient * word count / length; if the word count is 3 and the length of the first text is 10, the text matching degree is 60 (200*3 / 10) according to the formula: coefficient * word count / length. The coefficients can be set according to actual needs, and this application embodiment does not impose specific limitations.
[0105] In some embodiments, see Figure 4 Step S203 specifically includes, but is not limited to, steps S301 to S303:
[0106] Step S301: Obtain the word weight of each identical word segment. The word weight is used to characterize the importance of identical word segments.
[0107] Step S302: In each identical segment, determine the word matching degree of the identical segment according to the word weight and the number of words.
[0108] Step S303: Determine the text matching degree according to the word matching degree.
[0109] For steps S301 to S303 illustrated in the embodiments of the present application, for different first text segments, even if the number of words in the candidate segments that have the same segments as some first text segments is large, these identical segments may be meaningless and will affect the calculation of the text matching degree between the first text and the candidate text, resulting in a low accuracy rate of the text matching degree. For example, identical segments such as "de", "di", "de" (structural particles in Chinese), even if the number of words is large, the text matching degree obtained based on these identical segments cannot truly represent the matching relationship between the first text and the candidate text. Therefore, in the embodiments of the present application, word weights are set for identical segments, and identical segments with a lower degree of importance have lower word weights. For example, identical segments such as "de", "di", "de" that are irrelevant to the disease name may have a word weight of zero. Identical segments with a higher degree of importance have higher word weights. For example, identical segments related to the disease name such as "lesion", "high pressure", "low pressure", etc. may have a word weight of 0.6 or 0.7, etc. Finally, the word matching degree can be obtained according to the product of the number of words and the word weight of each identical segment, and the text matching degree can be obtained by summing up all the word matching degrees. The embodiments of the present application further consider the word weight on the basis of considering the number of words, improving the accuracy of the matching between the first text and the candidate text.
[0110] In some embodiments, refer to Figure 5 , step S102 specifically includes but is not limited to steps S401 to S403:
[0111] Step S401: Obtain the search keywords of the first text.
[0112] Step S402: Search in the matching text pair library according to the search keywords to obtain a third text containing the search keywords.
[0113] Step S403: Screen the matching text pairs in the matching text pair library with the third text containing the search keywords to obtain a second text pair.
[0114] For steps S401 to S403 illustrated in the embodiments of the present application, specifically, the embodiments of the present application use whether the third text contains the keywords of the first text as the judgment condition for synonymous texts. If the third text contains the search keywords, it means that the third text and the first text are synonymous texts. In addition, using the search keywords for matching during the search process can improve the search efficiency.
[0115] In one example, the matching text pair includes candidate text, and the candidate text includes at least one second text tokenization. Step S402 specifically includes but is not limited to:
[0116] Perform the same-word judgment on each second text tokenization in the matching text pair library according to the search keyword, and obtain a judgment result;
[0117] If the judgment result is that the words are the same, obtain a third text including the search keyword according to the candidate text including the second text tokenization.
[0118] It should be noted that the above example obtains a third text including the search keyword according to the search keyword, which improves the efficiency compared with directly searching according to text similarity. Also considering that some second text tokenizations in the candidate text are actually not necessary for judgment, such as the second text tokenizations of "de", "di", "de", etc., these second text tokenizations will reduce the search efficiency. Therefore, in addition to extracting keywords from the first text to obtain the search keyword, keywords can also be extracted from the candidate text to obtain candidate keywords, and according to whether the search keyword is the same as the candidate keyword, obtain the candidate text including the candidate keyword, so as to obtain the third text including the search keyword.
[0119] Specifically, in some embodiments, the matching text pair includes candidate text, and the matching text pair library further includes candidate keywords of the candidate text. Step S402 specifically includes but is not limited to:
[0120] Perform the same-word judgment on each candidate keyword in the matching text pair library according to the search keyword, and obtain a judgment result;
[0121] Based on the judgment result, screen the candidate text to obtain a third text including the search keyword.
[0122] Specifically, the judgment on whether the first text and the candidate text are synonymous texts is transformed into the judgment on whether the search keyword and the candidate keyword are the same words, which greatly improves the efficiency of searching for the second text pair.
[0123] It should be noted that for most texts, using whether the search keyword is the same as the candidate keyword to replace the text similarity between the first text and the third text will have some impact on the accuracy of judging text synonymy. However, since the first text pair and the second text pair in the embodiments of the present application are both disease names, and the inclusion of the same keyword in the disease names is sufficient to indicate that the texts are synonymous with each other. Therefore, the embodiments of the present application can not only effectively improve the text search efficiency, but also improve the accuracy of identifying whether the first text and the second text match.
[0124] In step S103 of some embodiments, the first text pair is vectorized to obtain a first vector, and the second text pair is vectorized to obtain a second vector.
[0125] In one example, the first and second texts in the first text pair are concatenated to obtain the first concatenated text; the first concatenated text is then vector-encoded using an encoding model to obtain the first vector. Similarly, the third and fourth texts in the second text pair are concatenated to obtain the second concatenated text; the second concatenated text is then vector-encoded using the same encoding model to obtain the second vector. It should be noted that the encoding model can be any BERT-like model, such as the RoBERTa model, DeBERTa model, etc.
[0126] In another example, the first text in the first text pair is vector-encoded using an encoding model to obtain a first intermediate vector; the second text in the first text pair is vector-encoded using an encoding model to obtain a second intermediate vector; the first and second intermediate vectors are concatenated to obtain a first vector; the third text in the second text pair is vector-encoded using an encoding model to obtain a third intermediate vector; the fourth text in the second text pair is vector-encoded using an encoding model to obtain a fourth intermediate vector; and the third and fourth intermediate vectors are concatenated to obtain a second vector.
[0127] Specifically, in some other embodiments, see [reference]. Figure 6 Before step S104, the method for identifying text matching specifically includes, but is not limited to, steps S501 to S502:
[0128] Step S501: Input the first vector and the second vector into a preset fully connected network, and perform numerical mapping on the first vector and the second vector through the fully connected network to obtain the vector matching score;
[0129] Step S502: Determine the matching degree of the first vector and the second vector based on the vector matching score.
[0130] Steps S501 and S502, as illustrated in this embodiment, involve numerically mapping the first vector and the second vector using a fully connected network to obtain a vector matching score. The vector matching score characterizes the probability that the first vector and the second vector are similar. The degree of matching between the first vector and the second vector is determined based on the vector matching score.
[0131] In other embodiments, see Figure 7 Before step S501, the methods for identifying text matching include, but are not limited to: a pre-trained fully connected network, specifically including:
[0132] Step S601: Obtain the first sample text pair and obtain the original matching score of the first sample text pair; the first sample text pair includes the first sample text and the second sample text.
[0133] Step S602: Search the matching text pair library according to the first sample text to obtain the second sample text pair. The second sample text pair is a matching text pair in the matching text pair library. The second sample text pair includes the third sample text and the fourth sample text, and the third sample text is a synonym of the first sample text.
[0134] Step S603: Perform vector transformation on the first sample text pair to obtain the first sample vector, and perform vector transformation on the second sample text pair to obtain the second sample vector;
[0135] Step S604: Input the first sample vector and the second sample vector into the fully connected network, and perform numerical mapping on the first sample vector and the second sample vector through the fully connected network to obtain the target matching score;
[0136] Step S605: Determine the loss value of the fully connected network based on the target matching score and the original matching score;
[0137] Step S606: Adjust the parameters of the fully connected network according to the loss value to obtain the trained fully connected network.
[0138] In steps S601 to S606 of this embodiment, during the training of the fully connected network, the training data is expanded by utilizing a second sample text pair in addition to the first sample text pair. Furthermore, the second sample text pair is obtained by searching the matching text pair library based on the first sample text, and the third sample text in the second sample text pair is a synonym of the first sample text. This expansion of the training data maintains its accuracy. The original matching score is the original label of the first and second sample texts, and the target matching score is the target label obtained after data expansion and numerical mapping by the fully connected network. The matching difference can be calculated based on the original and target matching scores to determine the loss value. This loss value represents the performance of the fully connected network. By adjusting the parameters of the fully connected network using this loss value, the performance of the fully connected network can be optimized, causing the loss value to converge, resulting in the trained fully connected network.
[0139] It should be noted that both untrained and trained fully connected networks can receive at least two vectors and output a matching score. However, the trained fully connected network in this embodiment achieves higher accuracy when mapping the values of the first and second vectors. It is also more suitable for the first and second texts in this embodiment, which are primarily based on disease names.
[0140] It should also be noted that, in addition to obtaining the matching score through numerical mapping using a fully connected network, the matching degree between the first and second vectors can be obtained by calculating the cosine similarity. Furthermore, other methods of calculating the similarity between the first and second vectors can also be used to determine the matching degree, which will not be elaborated upon here.
[0141] In step S104 of some embodiments, the matching relationship between the second text and the fourth text is determined based on the matching degree of the first vector and the second vector.
[0142] Specifically, if the matching degree of the first vector and the second vector is greater than the preset matching degree threshold, then the matching relationship between the second text and the fourth text is a match; if the matching degree of the first vector and the second vector is less than or equal to the preset matching degree threshold, then the matching relationship between the second text and the fourth text is a mismatch.
[0143] Step S105: Based on the matching relationship between the second text and the fourth text, determine whether the first text and the second text match.
[0144] Specifically, if the second text and the fourth text are matched, then the first text and the second text are matched; if the second text and the fourth text are not matched, then the first text and the second text are not matched.
[0145] Please see Figure 8 This application also provides an apparatus for recognizing text matching, which can implement the above-described method for recognizing text matching. Figure 8 The present application provides a module structure block diagram of a text matching recognition device. The device includes: a text acquisition module 701, a text search module 702, a text conversion module 703, a preliminary matching module 704, and a target matching module 705. Specifically, the text acquisition module 701 acquires a first text pair, which includes a first text and a second text; the text search module 702 searches a matching text pair library based on the first text to obtain a second text pair, where the second text pair is a matching text pair in the library, and includes a third text and a fourth text, with the third text being a synonym of the first text; the text conversion module 703 performs vector conversion on the first text pair to obtain a first vector, and performs vector conversion on the second text pair to obtain a second vector; the preliminary matching module 704 determines the matching relationship between the second text and the fourth text based on the matching degree of the first and second vectors; and the target matching module 705 determines whether the first text and the second text match based on the matching relationship between the second text and the fourth text.
[0146] It should be noted that the specific implementation of the text matching recognition device is basically the same as the specific implementation of the text matching recognition method described above, and will not be repeated here.
[0147] This application also provides an electronic device, which includes: a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for communication between the processor and the memory. When the program is executed by the processor, it implements the aforementioned method for identifying text matching. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0148] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:
[0149] The processor 801 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0150] The memory 802 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 802 and is called and executed by the processor 801 to execute the text matching method of the embodiments of this application.
[0151] The 803 input / output interface is used to implement information input and output.
[0152] The communication interface 804 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0153] Bus 805 transmits information between various components of the device (e.g., processor 801, memory 802, input / output interface 803, and communication interface 804);
[0154] The processor 801, memory 802, input / output interface 803, and communication interface 804 are connected to each other within the device via bus 805.
[0155] This application embodiment also provides a storage medium, which is a computer-readable storage medium for computer-readable storage. The storage medium stores one or more programs, which can be executed by one or more processors to implement the above-described method for identifying text matching.
[0156] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0157] The method, apparatus, electronic device, and storage medium for identifying text matching provided in this application include: before determining whether a first text and a second text match, searching for a matching text pair in a matching text pair library based on the first text, where the third text in the first text and the second text pair are synonyms, and the third text and the fourth text constitute a matching text pair in the matching text pair library. Vector transformation is performed on the first text pair and the second text pair respectively to obtain a first vector and a second vector. The matching degree of the first vector and the second vector is then used to determine whether the first vector and the second vector match. Since the first text in the first vector and the third text in the second vector are synonyms, the matching relationship between the second text and the fourth text can be determined based on the matching degree of the first vector and the second vector. Finally, the matching relationship between the second text and the fourth text is used to determine whether the first text and the fourth text match. In summary, this application embodiment transforms the method of identifying whether a first text and a second text match into identifying whether a first text pair and a second text pair match by searching for a second text pair based on the first text. By utilizing pre-annotated matching text pairs, the accuracy of identifying text matching is improved. Furthermore, the embodiments of this application avoid the technical problem of low accuracy in text matching due to insufficient labeled data.
[0158] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0159] It will be understood by those skilled in the art that Figure 2-7 The technical solutions shown do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0160] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0161] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0162] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification 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 so that the embodiments of this application described herein can be implemented in orders other than those illustrated or 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.
[0163] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0164] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0165] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0166] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0167] If the integrated unit is implemented as 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 this application, in essence, 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. This computer software product is stored in a storage medium and includes multiple instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0168] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method of identifying a text match, characterized by, The method comprises: obtaining a first text pair, the first text pair comprising a first text and a second text; obtaining a search keyword of the first text; searching in a matching text pair library according to the search keyword to obtain a third text containing the search keyword; screening the third text containing the search keyword from matching text pairs in the matching text pair library to obtain a second text pair, wherein the second text pair is one of the matching text pairs in the matching text pair library, the second text pair comprises a third text and a fourth text, and the third text is a synonymous text of the first text; vector transforming the first text pair to obtain a first vector, and vector transforming the second text pair to obtain a second vector; determining a matching relationship between the second text and the fourth text based on a matching degree of the first vector and the second vector; determining whether the first text and the second text match based on the matching relationship between the second text and the fourth text.
2. The method of claim 1, wherein, The matching text pair comprises a candidate text, and the matching text pair library further comprises a candidate keyword of the candidate text, and the searching in the matching text pair library according to the search keyword of the first text to obtain a third text containing the search keyword comprises: performing same word judgment on each candidate keyword in the matching text pair library according to the search keyword to obtain a judgment result; screening the candidate text based on the judgment result to obtain the third text containing the search keyword.
3. The method according to claim 1 or 2, characterized in that, Before the determining the matching relationship between the second text and the fourth text based on the matching degree of the first vector and the second vector, the method further comprises: inputting the first vector and the second vector into a preset full connection network, performing numerical mapping on the first vector and the second vector through the full connection network to obtain a vector matching score; and determining the matching degree of the first vector and the second vector based on the vector matching score.
4. A method of identifying a text match, characterized by, The method comprises: obtaining a first text pair, the first text pair comprising a first text and a second text; performing word segmentation on the first text to obtain at least one first text segmentation; for each candidate text in a matching text pair library, obtaining same segmentation according to comparison between the first text segmentation and at least one second text segmentation included in the candidate text, wherein the matching text pair library comprises a matching text pair, and the matching text pair comprises the candidate text; determining a text matching degree between the first text and the candidate text according to a word quantity of the same segmentation; screening the candidate text based on the text matching degree to obtain a third text; taking a matching text pair of the third text in the matching text pair library as a second text pair, wherein the second text pair is one of the matching text pairs in the matching text pair library, the second text pair comprises a third text and a fourth text, and the third text is a synonymous text of the first text; and determining a matching relationship between the second text and the fourth text based on a matching degree of the first vector and the second vector. vectorize the first text pair to obtain a first vector, and vectorize the second text pair to obtain a second vector; determine a matching relationship between the second text and the fourth text based on matching degrees of the first vector and the second vector; determine whether the first text and the second text match based on the matching relationship between the second text and the fourth text.
5. The method of claim 4, wherein, The method further includes: obtain a word weight of each same word, the word weight being used to represent an importance of the same word; determine a word matching degree of each same word based on the word weight and the word quantity; determine the text matching degree based on the word matching degree.
6. The method according to claim 4 or 5, characterized in that, Before the matching relationship between the second text and the fourth text is determined based on the matching degrees of the first vector and the second vector, the method further includes: input the first vector and the second vector into a preset fully connected network, and perform numerical mapping on the first vector and the second vector through the fully connected network to obtain a vector matching score; determine the matching degrees of the first vector and the second vector based on the vector matching score.
7. The method of claim 6, wherein, Before the first vector and the second vector are input into the preset fully connected network, the method further includes: pre-train the fully connected network, including: obtain a first sample text pair, and obtain an original matching score of the first sample text pair; the first sample text pair includes a first sample text and a second sample text; search for the first sample text in a matching text pair library to obtain a second sample text pair, wherein the second sample text pair is one of the matching text pairs in the matching text pair library, the second sample text pair includes a third sample text and a fourth sample text, and the third sample text is a synonymous text of the first sample text; vectorize the first sample text pair to obtain a first sample vector, and vectorize the second sample text pair to obtain a second sample vector; input the first sample vector and the second sample vector into the fully connected network, and perform numerical mapping on the first sample vector and the second sample vector through the fully connected network to obtain a target matching score; determine a loss value of the fully connected network based on the target matching score and the original matching score; perform parameter adjustment on the fully connected network based on the loss value to obtain a trained fully connected network.
8. An apparatus for identifying a text match, the apparatus comprising: The device includes: a text acquisition module configured to acquire a first text pair, the first text pair including a first text and a second text; a text search module configured to search for the first text in a matching text pair library to obtain a second text pair, wherein the second text pair is one of the matching text pairs in the matching text pair library, the second text pair includes a third text and a fourth text, and the third text is a synonymous text of the first text; The text conversion module is configured to convert the first text pair into a first vector and convert the second text pair into a second vector; The preliminary matching module is configured to determine a matching relationship between the second text and the fourth text based on a matching degree of the first vector and the second vector; The target matching module is configured to determine whether the first text and the second text match based on the matching relationship between the second text and the fourth text. The method further includes: obtaining a search keyword of the first text; searching the matching text pair library based on the search keyword to obtain the third text containing the search keyword; and screening the matching text pair in the matching text pair library containing the search keyword to obtain the second text pair. Alternatively, the method further includes: performing word segmentation on the first text to obtain at least one first text segment; for each candidate text in the matching text pair library, obtaining a same segment based on a comparison between the first text segment and at least one second text segment included in the candidate text; determining a text matching degree between the first text and the candidate text based on a word quantity of the same segment; screening the candidate text based on the text matching degree to obtain a third text; and taking the matching text pair in the matching text pair library containing the third text as the second text pair.
9. An electronic device, comprising: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the method of any one of claims 1 to 7 when executing the computer program.
10. A computer readable storage medium, the storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Semantic matching judgment method and device, electronic equipment and computer readable medium
CN112182348A
Text matching method, text matching device, electronic equipment and storage medium
CN115017886A