Text matching method, device, equipment, medium and computer program product
By introducing distance loss value and matching loss value in the text matching model training process, the matching drape problem in the text matching model is solved, and the accuracy and performance of the model is improved, and it is suitable for a variety of text matching tasks.
Patent Information
- Application Number
- CN202111057181.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-09
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2041-09-09
AI Technical Summary
In the prior art, text matching models have matching drape problems when dealing with noise and complex arbitrary expressions, resulting in low model accuracy, especially in medical term standardization and knowledge graph alignment tasks.
By obtaining training sample data, labeling sample labels, matching using text matching model, calculating the difference between the first sample data and the second sample data to determine the distance loss value and the difference between the sample tag and the predicted matching result determine the matching loss value. Combining the two, the text matching model is trained to obtain the target matching model.
It improves the accuracy of the text matching model, reduces the impact of matching drape problems, and improves the model's performance in multiple text matching tasks.
Smart Images

Figure CN114281931B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text matching method, apparatus, device, medium, and computer program product. Background Art
[0002] Text matching is a fundamental and important problem in natural language processing (NLP). It can be applied to a wide range of NLP tasks, including medical terminology standardization, knowledge graph alignment, and medical question-answer matching. By building a text matching model based on the task and training the model's parameters using training data, we can obtain a target model capable of completing the task.
[0003] During model training, due to the presence of significant noise or complex, arbitrary expressions in the training data, for example, in medical terminology standardization tasks, a large number of inputs should not be normalized but rejected without providing a result, i.e., a "match dangling" problem exists. In related technologies, when addressing this "match dangling" problem, a pre-built classification model is typically used to achieve rejection. This involves placing a classification model before the text matching model. This classification model can be a support vector machine trained through multiple training cycles.
[0004] However, when using the above-mentioned pre-classification model to solve the "matching dangling" problem, it is difficult to construct its training data; and the performance of the pre-classification model will greatly affect the overall performance of the task. Once the classification model makes a classification error, the subsequent text matching model will run out of completely wrong results, thereby reducing its task performance and resulting in low accuracy of the final model. Summary of the Invention
[0005] The embodiments of the present application provide a text matching method, apparatus, device, medium, and computer program product that can improve the accuracy of text matching models. The technical solution is as follows:
[0006] In one aspect, a text matching method is provided, comprising:
[0007] Acquire training sample data, where the training sample data is annotated with a sample label, wherein the training sample data includes first sample data and second sample data, the first sample data corresponds to an empty matching relationship, and the second sample data corresponds to a reference matching relationship;
[0008] Performing text matching on the training sample data using a text matching model to obtain a predicted matching result;
[0009] determining a distance loss value based on a difference between the first sample data and the second sample data;
[0010] Determining a matching loss value based on a difference between the sample label and the predicted matching result;
[0011] The text matching model is trained based on the matching loss value and the distance loss value to obtain a target matching model, and the target matching model is used to match the target text content to obtain a matching result.
[0012] In another aspect, a text matching device is provided, comprising:
[0013] an acquisition module, configured to acquire training sample data, wherein the training sample data is annotated with a sample label, wherein the training sample data includes first sample data and second sample data, the first sample data corresponds to an empty matching relationship, and the second sample data corresponds to a reference matching relationship;
[0014] A prediction module is used to perform text matching on the training sample data using a text matching model to obtain a predicted matching result;
[0015] a determining module, configured to determine a distance loss value based on a difference between the first sample data and the second sample data;
[0016] The determining module is further configured to determine a matching loss value based on a difference between the sample label and the predicted matching result;
[0017] A training module is used to train the text matching model based on the matching loss value and the distance loss value to obtain a target matching model, and the target matching model is used to match the target text content to obtain a matching result.
[0018] On the other hand, a computer device is provided, wherein the terminal includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement any text matching method described in the embodiments of the present application.
[0019] On the other hand, a computer-readable storage medium is provided, in which at least one program code is stored. The program code is loaded and executed by a processor to implement any text matching method described in the embodiments of the present application.
[0020] In another aspect, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the text matching method described in any of the above embodiments.
[0021] The technical solution provided by this application includes at least the following beneficial effects:
[0022] To address the match dangling problem associated with data with empty matching relationships in text matching tasks, a distance loss value indicating the difference between first and second sample data, and a matching loss value indicating the difference between a sample label and a predicted matching result, are obtained when training a text matching model using a loss function. The first sample data is the sample data with an empty matching relationship. Simultaneously, the model parameters of the text matching model are trained based on the matching loss value and the distance loss value to obtain a target matching model capable of completing the text matching task. By adding a training benchmark for the matching loss value during model training, the accuracy of the obtained target matching model can be improved. Furthermore, the above method can be applied to a variety of text matching tasks, uniformly reducing the impact of the "match dangling" problem on the text matching model and thereby improving the performance of the text matching model. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0024] Figure 1 This is a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application;
[0025] Figure 2 is a flow chart of a text matching method provided by an exemplary embodiment of the present application;
[0026] Figure 3 is a flow chart of a method for obtaining a distance loss value provided by an exemplary embodiment of the present application;
[0027] Figure 4 is a flow chart of a text matching method provided by another exemplary embodiment of the present application;
[0028] Figure 5 This is a schematic diagram of the architecture of a twin network provided by an exemplary embodiment of the present application;
[0029] Figure 6 This is a structural block diagram of a text matching device provided by an exemplary embodiment of the present application;
[0030] Figure 7 is a structural block diagram of a text matching device provided by another exemplary embodiment of the present application;
[0031] Figure 8 It is a structural diagram of a server provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0033] First, a brief introduction to the terms involved in the embodiments of this application is given:
[0034] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0035] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and smart transportation.
[0036] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to linguistics. NLP technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0037] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.
[0038] Text matching is a fundamental problem in natural language processing, applicable to a wide range of NLP tasks, including information retrieval, question-answering systems, paraphrasing, dialogue systems, and machine translation. Any NLP task involving matching text based on pre-defined criteria can be abstracted as text matching. Specifically, in the medical field, the same diagnosis can often be written in hundreds or even thousands of different ways. Medical terminology standardization aims to find corresponding standardized medical terminology for each of these diverse clinical expressions—that is, matching relevant clinical statements with standardized terminology.
[0039] Dangling Mapping: This refers to the situation in which data containing a large amount of noise or complex random expressions in a matching problem has a significant impact on many text matching problems. For example, in the field of medical AI, for medical terminology standardization tasks, a large number of inputs should not be normalized but rejected without giving any results. For medical knowledge graph alignment tasks, many entity nodes do not exist in both graphs at the same time, so many entities should have predicted equivalent aligned entities. Such problems are collectively referred to as "dangling mapping" problems.
[0040] The text matching method provided in the embodiment of the present application is a universal matching overhang recognition method based on multi-task learning. It can be migrated between multiple tasks or machine learning models to uniformly solve the "matching overhang" problem, thereby improving the performance of each machine learning model.
[0041] Please refer to Figure 1 , which shows a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application. The implementation environment includes: a terminal 110, a server 120 and a communication network 130.
[0042] Terminal 110 includes various terminal devices such as mobile phones, tablet computers, desktop computers, and portable laptops. Terminal 110 is used to provide sample data to server 120. For example, this sample data can be training sample data annotated with sample labels or initial sample data without labels. In some embodiments, terminal 110 is also used to indicate to server 120 the text matching model or text matching task to be trained.
[0043] The server 120 is used to provide a text matching model training function. The server 120 uses the acquired training sample data to train the text matching model according to the text matching model or text matching task to be trained indicated by the terminal 110. After completing the training of the target matching model, the server 120 can receive the target text content sent by the terminal 110, input the target text content into the target matching model, obtain a matching result, and return the matching result to the terminal 110. Alternatively, the server can also directly send the trained target matching model to the terminal 110.
[0044] It is worth noting that the above-mentioned server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0045] Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to enable data computing, storage, processing, and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology, all based on the cloud computing business model. It can form a resource pool that can be used on demand with flexibility and convenience. Cloud computing technology will become a crucial support. Backend services for technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identification mark and will need to be transmitted to backend systems for logical processing. Data of varying levels will be processed separately, and data from all industries will require a strong system backend, which can only be achieved through cloud computing.
[0046] In some embodiments, the server 120 can also be implemented as a node in a blockchain system. Blockchain is a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (for anti-counterfeiting) and generate the next block. Blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0047] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operations. The user management module is responsible for managing the identity information of all blockchain participants, including maintaining public and private key generation (account management), key management, and maintaining the correspondence between users' real identities and blockchain addresses (authority management). It also supervises and audits transactions involving certain real identities, providing risk control rule configuration (risk control audit), with authorization. The basic service module is deployed on all blockchain node devices to verify the validity of business requests and record valid requests in storage after reaching consensus. For a new business request, the basic service first performs interface adaptation and authentication processing (interface adaptation), then encrypts the business information through a consensus algorithm (consensus management). After encryption, the encrypted information is transmitted completely and consistently to the shared ledger (network communication) and recorded and stored. The smart contract module is responsible for contract registration, issuance, contract triggering, and contract execution. Developers can define contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the execution is triggered by calling keys or other events to complete the contract logic. It also provides the function of contract upgrade and cancellation. The operation module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation, and real-time status visualization during product release.
[0048] Illustratively, the terminal 110 and the server 120 are connected via a communication network 130 .
[0049] Please refer to Figure 2 , which shows a text matching method shown in an embodiment of the present application. In the embodiment of the present application, the method is applied to Figure 1 In the server shown, the method includes:
[0050] Step 201: Obtain training sample data.
[0051] The above-mentioned training sample data is used to train the text matching model, and the training sample data is annotated with sample labels, wherein the training sample data includes first sample data and second sample data, the first sample data corresponds to an empty matching relationship, and the second sample data corresponds to a reference matching relationship. The empty matching relationship means that the text content as the sample data does not have any matching relationship with other text contents in the preset matching task, and the reference matching relationship means that the text content as the sample data has a matching relationship with at least one of the other text contents in the preset matching task. Schematically, when the above-mentioned preset matching task is information retrieval, such as a medical knowledge base retrieval task, the data corresponding to the empty matching relationship is index data unrelated to the medical knowledge base, and the data corresponding to the reference matching relationship includes the index data in the medical knowledge base and similar data associated with the above-mentioned index data.
[0052] In some embodiments, the first sample data is training sample data labeled with a dangling label, and the second sample data is training sample data labeled with a reference label, wherein the dangling label indicates that the first sample data corresponds to an empty matching relationship, and the reference label indicates a reference matching relationship corresponding to the second sample data.
[0053] In some embodiments, the above-mentioned training sample data is obtained by labeling the initial sample data. Optionally, the labeling process of the initial sample data can be completed manually or by a labeling module in the server. Schematically, the initial sample data is obtained; in response to the matching relationship of the initial sample data in the target task being the empty matching relationship, the initial sample data is labeled with a dangling label to obtain the first sample data; or, in response to the matching relationship of the initial sample data in the target task being a reference matching relationship, the initial sample data is labeled with a reference label to obtain the second sample data; wherein the target task is used to indicate the text matching task that the target matching model needs to complete; based on the first sample data and the second sample data, the training sample data is obtained.
[0054] Optionally, the above-mentioned target tasks include at least one of terminology standardization tasks, knowledge graph alignment tasks, question-answer matching tasks, knowledge base retrieval tasks, synonym mining tasks, and knowledge graph entity linking tasks.
[0055] Among them, the terminology standardization task is used to instruct the matching of sentences in the preset field with standardized terms. For example, in the medical field, there are often hundreds or thousands of different ways of writing the same diagnosis. Normalizing the different sentence contents corresponding to the same diagnosis to the standardized terms corresponding to the above diagnosis is the medical terminology standardization task.
[0056] The knowledge graph alignment task is used to instruct the establishment of matching relationships between entities that point to the same object. The knowledge graph is composed of a number of interconnected entities and their attributes. The above-mentioned entities refer to physical objects that exist objectively and can be distinguished from each other. Entities are the basic UANs of the knowledge graph and are important language units that carry information in texts. In other words, the knowledge graph is composed of pieces of knowledge, each of which is represented by an SPO triple (Subject-Predicate-Object). Knowledge graph alignment, also known as entity alignment, aims to determine whether the entities of two or more different knowledge graphs point to the same object in the real world. If multiple entities represent the same object, an alignment relationship is established between these entities. For example, "caries" and "rotten teeth" both refer to the same disease, so an alignment relationship is established between these two entities.
[0057] The question-answer matching task is used to match an input question with candidate answers. This task can be a retrieval task for a predefined domain. Specifically, the text matching model performing the question-answer matching task searches for candidate answers in the information retrieval domain corresponding to the predefined domain based on the input question content. If a target answer matching the input question content is found, the corresponding target answer is output.
[0058] The knowledge base retrieval task is used to instruct the matching of input content with knowledge content in a preset knowledge base. The input content and the output knowledge content have a semantic matching relationship. Taking the medical knowledge base as an example, when the input content is "tooth decay", the model matches the knowledge content related to "tooth decay" in the medical knowledge base based on "tooth decay" and outputs it. For example, the output outputs the clinical name corresponding to "tooth decay" as "caries" and / or the output outputs the knowledge content that "tooth decay" is a bacterial disease.
[0059] The synonym mining task is used to obtain output words with similar semantic features to the input words. For example, the above-mentioned synonym mining task can also be targeted at a preset field. For example, in the medical field, the model can perform synonym matching based on the input words and the corresponding vocabulary domain of the medical field, and output words with similar meanings to the input words. For example, if the input word is "cavities", the output words can be "caries", "cavities", "rotten teeth", etc.
[0060] The knowledge graph entity linking task is used to instruct the matching of entity content in the knowledge graph with content in a preset form, which includes at least one of text form, image form, video form, and media data form. The above-mentioned entity linking refers to linking the entity elements in the text to the entity content in the preset library. The form of the entity content can be text form, image form, video form, or media data form. For example, if the input entity element is "tooth decay", the output entity content can be entity content such as caries pictures, caries treatment videos, etc. stored in the medical library.
[0061] Optionally, the server obtains training sample data from the terminal. For example, when the initial sample data is labeled in the terminal, the terminal uploads the training sample data to the server. Alternatively, the server obtains training sample data from a database, which is not limited here.
[0062] Step 202: Perform text matching on the training sample data using a text matching model to obtain a predicted matching result.
[0063] In some embodiments, the above-mentioned text matching model is a model to be trained, and the text matching model is determined according to a target task, that is, a target task is obtained, and the target task is used to indicate the text matching requirements to be achieved by the text matching model; based on the target task, model information corresponding to the text matching model is obtained, and the model information includes at least one of the information such as model structure, initial parameters, and model loss function. Schematically, the terminal provides the server with model information such as the model structure, initial parameters, and model loss function of the above-mentioned text matching model, and the server constructs a text matching model based on the above-mentioned model information and trains the text matching model through training sample data; or, the terminal provides the server with task content corresponding to the target task, and the above-mentioned task content indicates the text matching task that the target matching model trained by the server needs to complete, and the server obtains a text matching model that can achieve the above-mentioned target task from a database, randomly initializes the model parameters of the text matching model, and trains the text matching model based on the acquired training sample data.
[0064] Schematically, the training sample data is input into the acquired text matching model, and the corresponding predicted matching result under the current model parameters is output, and the predicted matching result is used to train the current text matching model.
[0065] In some embodiments, the text matching model performs feature extraction on the training sample data to obtain a sample feature vector. Illustratively, the text matching model may include a convolutional neural network (CNN), a super-resolution test sequence (Visual Geometry Group, VGG) network, a support vector machine (SVM) classifier, an encoder (Encoder), a decoder (Decoder), and the like. The specific network structure included is determined by the specific text matching task and is not limited here.
[0066] Step 203: Determine a distance loss value based on the difference between the first sample data and the second sample data.
[0067] In some embodiments, the difference between the first sample data and the second sample data is represented by a vector distance in a vector space. To address the overhang problem, after training the target matching model, it is necessary to ensure that the vector representation of the sample data marked with the overhang label is greater than or equal to a preset vector distance from the vector representation of all other sample data. Illustratively, a preset vector distance corresponding to the first sample data is obtained; difference data between the first sample data and the second sample data is obtained; and a distance loss value is determined based on the difference data and the preset vector distance.
[0068] Optionally, the preset vector distance may be preset by the system or determined based on training sample data. If the preset vector distance is preset by the system, then the preset vector distance is associated with the target task or the text matching model.
[0069] In some embodiments, the distance information between the first sample data and the second sample data in the sample set in the vector space is determined as the above-mentioned difference data, that is, the distance loss value is determined based on the difference between the distance information and the preset vector distance. The above-mentioned sample set includes all sample data in the training sample data except the above-mentioned first sample data, or the above-mentioned sample set is a sample set obtained by randomly sampling the second sample data based on the first sample data. Illustratively, the above-mentioned distance information includes but is not limited to at least one of the types of distance information such as Euclidean distance, cosine similarity distance, Mahalanobis distance, and Manhattan distance.
[0070] In an embodiment of the present application, the server determines the distance loss value based on the difference between the above-mentioned distance information and the preset vector distance. If the distance loss value converges, it means that the vector representation of the first sample data after feature extraction by the current text matching model is far enough away from the vector representation corresponding to other second sample data (i.e., positive sample) in the vector space, and the trained target matching model can correctly identify the input text content and will not perform matching operations on text content that should not be matched, thereby solving the matching dangling problem.
[0071] Step 204 : determining a matching loss value based on the difference between the sample label and the predicted matching result.
[0072] The matching loss value is determined by the loss function corresponding to the text matching model. Specifically, the text matching model is trained by obtaining a corresponding model loss function based on the text matching model, inputting the predicted matching result into the model loss function, and outputting the loss between the predicted matching result and the sample label.
[0073] In some embodiments, the above-mentioned model loss function may be provided by the terminal, for example, when the terminal uploads the model information of the text matching model, the terminal carries the above-mentioned model loss function in the model information and uploads it together; or, the above-mentioned model loss function may be obtained from a database, for example, the server reads the corresponding model loss function from the database according to the model identifier of the text matching model.
[0074] In the embodiment of the present application, there is no fixed order between step 203 and step 204. Step 203 can be performed first or step 204 can be performed first, or step 203 and step 204 can be performed simultaneously.
[0075] Step 205 : Training the text matching model based on the matching loss value and the distance loss value to obtain a target matching model.
[0076] The above target matching model is used to match the target text content to obtain a matching result.
[0077] In some embodiments, the matching loss value and the distance loss value are weighted and summed according to a preset weight relationship to obtain a target loss value; the model parameters of the text matching model are iteratively trained based on the target loss value; and in response to the convergence of the target loss value, a target matching model is obtained.
[0078] In an exemplary embodiment, the above-mentioned preset weight relationship may be preset by the system or obtained through network parameter adjustment. In one example, the above-mentioned preset weight relationship includes β corresponding to the matching loss value and γ corresponding to the distance loss value, β and γ are hyperparameters obtained through network parameter adjustment, and the target loss value is obtained through the target loss function Lnew As shown in Formula 1, where L old is the model loss function, L x The distance loss function used to obtain the distance loss value.
[0079] Formula 1: L new =β*L old +γ*L x
[0080] After obtaining the target loss value, the current model parameters of the text matching model can be adjusted according to the target loss value, and then the above process of adjusting the model parameters through the matching loss value and the distance loss value can be repeated until the text matching model converges and the target matching model is obtained.
[0081] In summary, the text matching method provided in the embodiment of the present application is to solve the matching dangling problem existing in data with empty matching relationships in text matching tasks. When the text matching model is trained through the loss function, a distance loss value that can indicate the difference between the first sample data and the second sample data, and a matching loss value that can indicate the difference between the sample label and the predicted matching result are obtained, wherein the first sample data is the sample data with an empty matching relationship. At the same time, the model parameters of the text matching model are trained according to the matching loss value and the distance loss value to obtain a target matching model that can complete the text matching task. By adding a training benchmark of the matching loss value during the training process of the model, the accuracy of the obtained target matching model can be improved. At the same time, the above method can be applied to a variety of text matching tasks to uniformly reduce the impact of the "matching dangling" problem on the text matching model, so as to improve the performance of the text matching model.
[0082] Please refer to Figure 3 , which shows a method for obtaining a distance loss value according to an embodiment of the present application. In the embodiment of the present application, the determination of the distance loss value in the text matching method is schematically described. The method includes:
[0083] Step 301: Randomly sample the second sample data based on the first sample data to obtain a sample set.
[0084] Illustratively, the sample set includes a target number of second sample data.
[0085] In some embodiments, the number of sample sets obtained by random sampling may be one or more, which is not limited here.
[0086] Step 302: Determine the vector distance between the second sample data and the first sample data in the sample set.
[0087] Illustratively, feature extraction is performed on the first sample data and the second sample data respectively through a text matching model to obtain a first vector corresponding to the first sample data and a second vector corresponding to the second sample data, and a vector distance between the first vector and the second vector is calculated.
[0088] Step 303: Determine the mean of the vector distances between all second sample data and the first sample data in the sample set as the preset vector distance.
[0089] In an exemplary embodiment, the preset vector distance is determined by obtaining the mean of the vector distances between the second vectors of the target number in the sample set and the first vector. In one example, the preset vector distance λ is obtained by formula 2: x ,in, represents the sample set corresponding to the first sample data x, n represents the number of second sample data in the sample set, ‖‖2 represents the Euclidean (L2) distance between the two feature vectors in the vector space, and W is the nonlinear mapping from the first vector x to the second vector y in the calculated vector space.
[0090] Formula 2:
[0091] Step 304: Determine a first Euclidean distance of the first sample data in the vector space.
[0092] Schematically, in order to determine the distance loss function, it is necessary to determine the distance information between the first sample data and the second sample data in the sample set in the vector space. In an embodiment of the present application, the above distance information includes a first Euclidean distance and a second Euclidean distance. The L2 distance of the first vector in the vector space is calculated to obtain the above first Euclidean distance. The above distance information is only illustrated by taking the Euclidean distance as an example. The above distance information can also be distance information of the cosine similarity distance, Mahalanobis distance, Manhattan distance, etc., which are not limited here.
[0093] Step 305: Determine a nonlinear mapping from the first sample data in the vector space to the second sample data in the sample set.
[0094] A nonlinear mapping from the first vector to the second vector is calculated in the vector space to obtain a second Euclidean distance.
[0095] Step 306: Determine the second Euclidean distance of the nonlinear mapping in the vector space.
[0096] In an embodiment of the present application, the L2 distance of the nonlinear mapping from the first vector to the second vector in the vector space is calculated to obtain the second Euclidean distance, and the determined first Euclidean distance and second Euclidean distance are determined as the distance information.
[0097] Step 307: Determine a distance loss value based on the difference between the distance information and the preset vector distance.
[0098] Schematically, the absolute value of the difference between the preset vector distance and the second Euclidean distance is determined, and the absolute value of the first Euclidean distance and the number of targets in the sample set are added to obtain the distance loss value. In one example, the distance loss function L corresponding to the distance loss value is: x As shown in Formula 3, represents the sample set corresponding to the first sample data x, n represents the number of second sample data in the sample set, ‖‖2 represents the Euclidean (L2) distance between two feature vectors in the vector space, W is the nonlinear mapping from the first vector x to the second vector y in the vector space, abs() is the absolute value, λ x is the preset vector distance obtained by the above formula 2, and α represents the hyperparameter of the first sample data position, which is obtained through network parameter adjustment.
[0099] Formula 3:
[0100] In summary, the distance loss value acquisition method provided in the embodiment of the present application determines the distance loss value through the above-mentioned distance loss function. The above-mentioned distance loss function defaults to treating the "overhanging" samples (first sample data) as so-called background samples, that is, they should be as far away from other samples (i.e., positive samples) as possible. Here, first, a positive sample set N with a number of n is randomly sampled for a "overhanging" sample, where each sample y must be at least lambda away from x. x The distance, and lambda x The calculation of is the average distance from all samples in the current random sampling set N to the "overhanging" sample x. In other words, the distance loss function L x It is hoped that for any randomly sampled sample set N, the distance between the "hanging" sample x and every sample in the set should be greater than or equal to its average distance. Since multiple different sample sets are randomly sampled for each "hanging" sample x, after training is completed, it can be achieved that the distance between the vector representation of the "hanging" sample and all sample vector representations is at least greater than or equal to lambda x , and lambda x >0.
[0101] Please refer to Figure 4 , which illustrates a text matching method provided by an exemplary embodiment of the present application. In this embodiment, the method is applied to a medical terminology standardization task. The medical terminology standardization task indicates that a non-standard query input needs to be mapped to a medical concept in a medical standard system. The method includes:
[0102] Step 401: Obtain training sample data and terminology standardization model.
[0103] The above training sample data is used to train the terminology standardization model. In the embodiment of the present application, the model architecture of the above terminology standardization model uses the architecture of the twin network. The above network architecture can also be other network architectures, which are not limited here.
[0104] like Figure 5 As shown, it shows a schematic diagram of the architecture of the above-mentioned twin network for the medical terminology standardization task. The terminology standardization model 500 is a twin network using a 3-layer fully connected and shared weight, wherein the input data 501 includes wordA and wordB, and the input data 501 is respectively modeled by a natural language model to obtain a semantic word vector 502, and the above-mentioned semantic word vector 502 includes embedA and embedB. The input data 501 is respectively manually designed to obtain an artificial feature vector 503, and the above-mentioned artificial feature vector 503 includes featA and featB. After the semantic word vector 502 passes through three layers of dense blocks (dense) 510, it is input into the fully connected layer (concat) 520 together with the artificial feature vector 503. The outputs of the two sub-networks (networkA and networkB) are connected to the hidden layer before the output layer, and the similarity between the two input data 501 is evaluated by the contrastive loss (contrastiveloss) 530.
[0105] In some embodiments, the artificially designed feature vectors include: (1) Chinese word edit distance; (2) Chinese pinyin edit distance; (3) the first number of the same radicals in Chinese words; and (4) the longest common subsequence of Chinese words.
[0106] In an embodiment of the present application, the data format corresponding to the above-mentioned medical terminology standardization task is [non-standard data, standard terminology]. Therefore, the data used for the model training of the twin network is labeled data (positive samples, i.e., the second sample data) and labeled data randomly replaced with standard words (negative samples, i.e., the first sample data).
[0107] Step 402: Perform text matching on the training sample data using the term standardization model to obtain a predicted matching result.
[0108] The training sample data is input into the term standardization model, which can output a predicted matching result for evaluating the similarity between the input training sample data pairs, wherein the predicted matching result is obtained based on the model parameter prediction corresponding to the current term standardization model.
[0109] Step 403: Obtain the model loss function corresponding to the term normalization model.
[0110] In an embodiment of the present application, the loss function L of the above-mentioned twin network during training is shown in Formula 4, where N is the number of all sample pairs, y is the training label, d is the Euclidean distance of the final embedding of the two input samples, and margin is a predetermined threshold (usually set to 0.5).
[0111] Formula 4:
[0112] Step 404: Determine a matching loss value corresponding to the predicted matching result based on the model loss function.
[0113] The above-mentioned predicted matching result is input into the above-mentioned model loss function to obtain the matching loss value corresponding to the predicted matching result, wherein, for the above-mentioned model loss function, the form of the above-mentioned predicted matching result in the embodiment of the present application is the final embedding of the input sample.
[0114] Step 405 : Determine a distance loss value based on the difference between the first sample data and the second sample data.
[0115] In the embodiment of the present application, in combination with the distance loss value acquisition method given in steps 301 to 307, a distance loss function for determining the difference between positive and negative samples is determined. The distance loss function is shown in Formula 5, where I is the unit matrix, represents the sample set corresponding to the first sample data x, n represents the number of second sample data in the sample set, ‖‖2 represents the Euclidean (L2) distance between two feature vectors in the vector space, abs() is the absolute value, λ x is the preset vector distance obtained by the above formula 6, and α represents the hyperparameter of the first sample data position, which is obtained through network parameter adjustment.
[0116] Formula 5:
[0117] Formula 6:
[0118] Step 406: Train the term normalization model based on the matching loss value and the distance loss value to obtain a target normalization model.
[0119] The above target normalization model is used to match the input data pairs to obtain normalized results.
[0120] In the embodiment of the present application, the content of training the model in combination with the matching loss value and the distance loss value is the same as step 205 and will not be repeated here.
[0121] In one example, the above-mentioned medical terminology standardization task is evaluated. First, medical experts manually annotate a large amount of hospital outpatient data, and obtain 253 valid data and 400 data that should not be standardized (i.e., there is a "match dangling" problem). Indicatively, the evaluation index adopted is complete matching, that is, the engine output is correct only if and only if all standard words are correct. Please refer to Table 1, which shows the evaluation results. It can be seen from Table 1 that the optimized engine obtained by the text matching method provided in this application has a better standardization effect on the diagnostic data of real scenarios than the original engine, especially on the test data with the "match dangling" problem. The improvement is more obvious, which shows the effectiveness of the text matching method provided in this application in solving the "match dangling" problem.
[0122] Table 1
[0123]
[0124] In summary, the text matching method provided in the embodiments of the present application addresses the matching dangling problem present in medical terminology standardization tasks, i.e., a certain input should not be standardized. When training a terminology standardization model using a loss function, a matching loss value is determined based on the difference between the first sample data and the second sample data, and a matching loss value of the terminology standardization model is determined based on the difference between the sample label of the training sample data and the predicted matching result. Simultaneously, the model parameters of the terminology standardization model are trained based on the matching loss value and the distance loss value to obtain a terminology standardization model capable of completing the medical terminology standardization task. By adding a training benchmark for the matching loss value during the model training process, the accuracy of the obtained terminology standardization model can be improved, thereby enhancing the performance of the terminology standardization model.
[0125] In one example, the text matching method provided by the embodiment of the present application can also be applied to the knowledge graph alignment task. Taking MultiKE as an example, MultiKE is a knowledge graph entity alignment method based on deep learning. It mainly uses the technology of multi-view learning to learn a comprehensive vector embedding based on multiple views, namely the name view, the relationship view, and the attribute view. Schematically, the above three views are schematically explained:
[0126] (1) Name view: First, word embeddings are obtained through a pre-trained word embedding model, and character embeddings are obtained through a pre-trained Skip-Gram model, as shown in Formula 7, where LP converts characters or singles into word embeddings.
[0127] Formula 7:
[0128] Then, the final embedding representation of the name input is obtained through Formula 8, where n is a positive integer, l is the input, encoder is the encoder obtained by training an autoencoder, and [;] represents the concatenation operation.
[0129] Formula 8: Φ(l)=encoder([LP(o1);LP(o2);…;LP(o n )])
[0130] By passing the above entity name through the module corresponding to Formula 8, the name-based embedding representation of the entity can be obtained. The above embedding representation is expressed by Formula 9.
[0131] Formula 9: h (1) =Φ(name(h))
[0132] (2) Relational view: To preserve the relational structure of the knowledge graph, the TransE model is used, treating the relationship as a transfer vector between the head entity and the tail entity, which is expressed as Formula 10, where ||·|| represents the L1 or L2 norm. Formula 10 can be used to construct an objective function (such as using sigmoid as the activation function and logistic loss). Through training, the obtained entity and relationship embeddings are made to minimize the above equation.
[0133] Formula 10: f rel (h (2) ,r,t (2) )=-||h (2) +rt (2) ||
[0134] (3) Attribute view: For attributes, a convolutional neural network is used to extract entity features from attributes and attribute values, as shown in Formula 11, where<a;v> Represents an attribute-attribute value pair of an entity, W is the transformation matrix, Omega is the convolution kernel, and sigma is the activation function.
[0135] Formula 11: CNN(<a;v> )=σ(vec(σ(<a;v> *Ω))W)
[0136] The goal of CNN is to make the output as close as possible to the embedded representation of the entity, as shown in Formula 12, where the purpose of minimizing the above formula can be achieved by constructing a loss function.
[0137] Formula 12: f attr (h (3) ,a,v)=-||h (3) -CNN(<a;v> )||
[0138] After the above three views corresponding steps, multiple embedding representations of an entity can be obtained (h (1) , h (2) , h (3) In addition to the aforementioned objectives, these word embeddings must also meet the objectives on the training set (obtained from the output of PARIS). For a relation triple (h, r, t) in the knowledge graph G, if t and t' are known to be aligned, then (h, r, t') also has a high probability of appearing in G'. Based on this, taking the relation view as an example, we can construct the alignment loss function shown in Formula 13 below, whose goal is to maximize the probability that the triple (h, r, t') is true.
[0139] Formula 13:
[0140]
[0141] Similarly, a similar alignment loss function can be constructed and optimized on the attribute view.
[0142] The above content is a standard loss function for MultiKE model training. In the embodiment of the present application, in order to deal with the "matching dangling" problem, the text matching method provided in the embodiment of the present application will be introduced into the overall training framework of the above model, that is, the distance loss function provided by Formula 3 will be added to the loss function of the training model.
[0143] During the entire training process, the name view embedding is first learned by learning pre-trained word / character embeddings and training an autoencoder. In each training cycle, the objective function for the relationship view is minimized, followed by the objective function for the attribute view, and finally, the distance loss function corresponding to the newly introduced "matching dangle" problem is minimized. Next, the alignment loss function for the relationship and attribute views is minimized based on the training data. After training, the embedding representations of multiple views of an entity are combined to obtain a more comprehensive embedding representation of the entity. A nearest neighbor search algorithm is then used to determine the aligned pairing of unaligned entities based on their nearest neighbors in the vector space.
[0144] Please refer to Figure 6 , which shows a structural block diagram of a text matching device provided by an exemplary embodiment of the present application, the device includes the following modules:
[0145] An acquisition module 610 is configured to acquire training sample data, wherein the training sample data is annotated with a sample label, wherein the training sample data includes first sample data and second sample data, wherein the first sample data corresponds to an empty matching relationship, and the second sample data corresponds to a reference matching relationship;
[0146] Prediction module 620, configured to perform text matching on the training sample data using a text matching model to obtain a predicted matching result;
[0147] a determination module 630, configured to determine a distance loss value based on a difference between the first sample data and the second sample data;
[0148] The determination module 630 is further configured to determine a matching loss value based on a difference between the sample label and the predicted matching result;
[0149] The training module 640 is used to train the text matching model based on the matching loss value and the distance loss value to obtain a target matching model. The target matching model is used to match the target text content to obtain a matching result.
[0150] In an optional embodiment, if Figure 7 As shown, the determining module 630 further includes:
[0151] An acquiring unit 631 is configured to acquire a preset vector distance corresponding to the first sample data;
[0152] The acquiring unit 631 is further configured to acquire difference data between the first sample data and the second sample data;
[0153] The determining unit 632 is configured to determine the distance loss value based on the difference data and the preset vector distance.
[0154] In an optional embodiment, the determining module 630 further includes:
[0155] a sampling unit 633, configured to randomly sample the second sample data based on the first sample data to obtain a sample set;
[0156] The determining unit 632 is further configured to determine a vector distance between the second sample data in the sample set and the first sample data;
[0157] The determining unit 632 is further configured to determine the average of the vector distances between all second sample data and the first sample data in the sample set as the preset vector distance.
[0158] In an optional embodiment, the determining unit 632 is further configured to determine distance information between the first sample data and the second sample data in the sample set in a vector space as the difference data;
[0159] The determining unit 632 is further configured to determine the distance loss value based on a difference between the distance information and the preset vector distance.
[0160] In an optional embodiment, the determining unit 632 is further configured to determine a first Euclidean distance of the first sample data in the vector space;
[0161] The determining unit 632 is further configured to determine a nonlinear mapping from the first sample data to the second sample data in the sample set in the vector space;
[0162] The determining unit 632 is further configured to determine a second Euclidean distance of the nonlinear mapping in the vector space;
[0163] The determining unit 632 is further configured to determine the difference data according to the first Euclidean distance and the second Euclidean distance.
[0164] In an optional embodiment, the sample set includes a target number of second sample data;
[0165] The determining unit 632 is further configured to determine an absolute value of a difference between the preset vector distance and the second Euclidean distance;
[0166] The determining unit 632 is further configured to accumulate the first Euclidean distance and the absolute value of the number of targets in the sample set to obtain the distance loss value.
[0167] In an optional embodiment, the acquisition module 610 is further configured to acquire initial sample data;
[0168] The device further comprises:
[0169] The labeling module 650 is configured to label the initial sample data with a dangling label in response to the initial sample data having a matching relationship in the target task being the empty matching relationship, thereby obtaining the first sample data; or, in response to the initial sample data having a matching relationship in the target task being the reference matching relationship, label the initial sample data with a reference label, thereby obtaining the second sample data; wherein the target task is used to indicate a text matching task that the target matching model needs to complete;
[0170] The acquisition module 610 is further configured to obtain the training sample data based on the first sample data and the second sample data.
[0171] In an optional embodiment, the target task includes at least one of a medical terminology standardization task, a knowledge graph alignment task, a medical question-answer matching task, a medical knowledge base retrieval task, a medical synonym mining task, and a knowledge graph entity linking task;
[0172] Among them, the term standardization task is used to instruct the matching of sentences in a preset field with standardized terms; the knowledge graph alignment task is used to instruct the construction of matching relationships between entities pointing to the same object; the question-answer matching task is used to instruct the matching of input questions with candidate answers; the knowledge base retrieval task is used to instruct the matching of input content with knowledge content in a preset knowledge base; the synonym mining task is used to instruct the acquisition of output vocabulary with similar meaning characteristics to the input vocabulary; the knowledge graph entity linking task is used to instruct the matching of entity content in the knowledge graph with content in a preset form, and the preset form includes at least one of text form, image form, video form, and media data form.
[0173] In an optional embodiment, the training module 640 further includes:
[0174] A calculation unit 641 is configured to perform a weighted summation of the matching loss value and the distance loss value according to a preset weight relationship to obtain a target loss value;
[0175] A training unit 642 is configured to iteratively train model parameters of the text matching model based on the target loss value;
[0176] The judgment unit 643 is configured to obtain the target matching model in response to the convergence of the target loss value.
[0177] In an optional embodiment, the acquisition module 610 is further configured to acquire a target task, where the target task is used to indicate a text matching requirement implemented by the text matching model.
[0178] The determination module 630 is further configured to obtain model information corresponding to the text matching model based on the target task, where the model information includes at least one of model structure, initial parameters, model loss function, and the like.
[0179] In summary, the text matching device provided in the embodiment of the present application is designed to solve the matching dangling problem existing in data with an empty matching relationship in a text matching task. When training the text matching model through a loss function, a distance loss value indicating the difference between the first sample data and the second sample data, and a matching loss value indicating the difference between the sample label and the predicted matching result are obtained, wherein the first sample data is the sample data with an empty matching relationship. At the same time, the model parameters of the text matching model are trained according to the matching loss value and the distance loss value to obtain a target matching model that can complete the text matching task. By adding a training benchmark of the matching loss value during the training process of the model, the accuracy of the obtained target matching model can be improved. At the same time, the above method can be applied to a variety of text matching tasks to uniformly reduce the impact of the "matching dangling" problem on the text matching model, so as to improve the performance of the text matching model.
[0180] It should be noted that the text matching device provided in the above embodiment is merely an example of the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the text matching device provided in the above embodiment and the text matching method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0181] Figure 8 The following is a schematic diagram of the structure of a server provided by an exemplary embodiment of the present application. Specifically, it includes the following structure.
[0182] The server 800 includes a central processing unit (CPU) 801, a system memory 804 including a random access memory (RAM) 802 and a read-only memory (ROM) 803, and a system bus 805 connecting the system memory 804 and the CPU 801. The server 800 also includes a mass storage device 806 for storing an operating system 813, application programs 814, and other program modules 815.
[0183] The mass storage device 806 is connected to the central processing unit 801 through a mass storage controller (not shown) connected to the system bus 805. The mass storage device 806 and its associated computer-readable media provide non-volatile storage for the server 800. That is, the mass storage device 806 may include a computer-readable medium (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0184] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other solid-state storage technologies, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 804 and mass storage device 806 can be collectively referred to as memory.
[0185] According to various embodiments of the present application, the server 800 may also be connected to a remote computer on a network such as the Internet for operation. That is, the server 800 may be connected to the network 812 via the network interface unit 811 connected to the system bus 805, or the network interface unit 811 may be used to connect to other types of networks or remote computer systems (not shown).
[0186] The memory also includes one or more programs, which are stored in the memory and configured to be executed by the CPU.
[0187] Embodiments of the present application further provide a computer device comprising a processor and memory, wherein the memory stores at least one instruction, at least one program, code set, or instruction set, and the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the biometric recognition methods provided in the above-described method embodiments. Optionally, the computer device may be a terminal or a server.
[0188] An embodiment of the present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the biometric recognition method provided by the above-mentioned method embodiments.
[0189] Embodiments of the present application further provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the biometric recognition method described in any of the above embodiments.
[0190] Optionally, the computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a solid-state drive (SSD), or an optical disk. Among them, the random access memory may include a resistance random access memory (ReRAM) and a dynamic random access memory (DRAM). The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0191] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0192] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A text matching method, characterized in that: The method comprises: Acquire training sample data, where the training sample data is annotated with a sample label, wherein the training sample data includes first sample data and second sample data, the first sample data corresponds to an empty matching relationship, and the second sample data corresponds to a reference matching relationship, wherein the empty matching relationship means that the text content of the first sample data does not have any matching relationship with other text contents in a preset matching task, and the reference matching relationship means that the text content of the second sample data has a matching relationship with at least one text content of the other text contents in the preset matching task; Performing text matching on the training sample data using a text matching model to obtain a predicted matching result; Randomly sampling the second sample data based on the first sample data to obtain a sample set, where the sample set includes a target number of the second sample data; Determining vector distances between the target number of second sample data in the sample set and the first sample data respectively; Determining a mean value of vector distances between all second sample data and the first sample data in the sample set as a preset vector distance; Acquire difference data between the first sample data and the second sample data; determining a distance loss value based on the difference data and the predetermined vector distance; Determining a matching loss value based on a difference between the sample label and the predicted matching result; The text matching model is trained based on the matching loss value and the distance loss value to obtain a target matching model, and the target matching model is used to match the target text content to obtain a matching result.
2. The method according to claim 1, characterized in that The obtaining of difference data between the first sample data and the second sample data includes: The distance information between the first sample data and the second sample data in the sample set in the vector space is determined as the difference data.
3. The method according to claim 2, characterized in that The determining the distance information between the first sample data and the second sample data in the sample set in the vector space as the difference data includes: determining a first Euclidean distance of the first sample data in the vector space; Determining a nonlinear mapping from the first sample data to second sample data in the sample set in a vector space; determining a second Euclidean distance of the nonlinear mapping in the vector space; The difference data is determined according to the first Euclidean distance and the second Euclidean distance.
4. The method according to claim 3, characterized in that The sample set includes a target number of second sample data; The determining the distance loss value based on the difference data and the preset vector distance includes: Determining an absolute value of a difference between the preset vector distance and the second Euclidean distance; The first Euclidean distance and the absolute value of the number of targets in the sample set are accumulated to obtain the distance loss value.
5. The method according to any one of claims 1 to 4, characterized in that: The obtaining of training sample data includes: Get initial sample data; In response to the matching relationship of the initial sample data in the target task being the empty matching relationship, the initial sample data is annotated with a dangling label to obtain the first sample data; or, in response to the matching relationship of the initial sample data in the target task being the reference matching relationship, the initial sample data is annotated with a reference label to obtain the second sample data; wherein the target task is used to indicate a text matching task that the target matching model needs to complete; The training sample data is obtained based on the first sample data and the second sample data.
6. The method according to claim 5, characterized in that The target task includes at least one of a terminology standardization task, a knowledge graph alignment task, a question-answer matching task, a knowledge base retrieval task, a synonym mining task, and a knowledge graph entity linking task; Among them, the term standardization task is used to instruct the matching of sentences in a preset field with standardized terms; the knowledge graph alignment task is used to instruct the construction of matching relationships between entities pointing to the same object; the question-answer matching task is used to instruct the matching of input questions with candidate answers; the knowledge base retrieval task is used to instruct the matching of input content with knowledge content in a preset knowledge base; the synonym mining task is used to instruct the acquisition of output vocabulary with similar meaning characteristics to the input vocabulary; the knowledge graph entity linking task is used to instruct the matching of entity content in the knowledge graph with content in a preset form, and the preset form includes at least one of text form, image form, video form, and media data form.
7. The method according to any one of claims 1 to 4, characterized in that: The training of the text matching model based on the matching loss value and the distance loss value to obtain a target matching model includes: Performing a weighted summation on the matching loss value and the distance loss value according to a preset weight relationship to obtain a target loss value; Iteratively training model parameters of the text matching model based on the target loss value; In response to the target loss value converging, the target matching model is obtained.
8. The method according to any one of claims 1 to 4, characterized in that: Before obtaining the training sample data, the method further includes: Acquire a target task, where the target task is used to indicate a text matching requirement implemented by the text matching model; Based on the target task, model information corresponding to the text matching model is obtained, where the model information includes at least one of model structure, initial parameters, model loss function, and the like.
9. A text matching device, characterized in that: The device comprises: an acquisition module, configured to acquire training sample data, the training sample data being annotated with sample labels, wherein the training sample data includes first sample data and second sample data, the first sample data corresponding to an empty matching relationship, and the second sample data corresponding to a reference matching relationship, wherein the empty matching relationship means that the text content of the first sample data does not have any matching relationship with other text contents in a preset matching task, and the reference matching relationship means that the text content of the second sample data has a matching relationship with at least one of the other text contents in the preset matching task; A prediction module is used to perform text matching on the training sample data using a text matching model to obtain a predicted matching result; a sampling unit, configured to randomly sample the second sample data based on the first sample data to obtain a sample set, wherein the sample set includes a target number of the second sample data; a determining unit, configured to determine vector distances between the target number of second sample data in the sample set and the first sample data respectively; and determine an average of the vector distances between all second sample data in the sample set and the first sample data as a preset vector distance; The acquiring unit is further configured to acquire difference data between the first sample data and the second sample data; The determining unit is further configured to determine a distance loss value based on the difference data and the preset vector distance; a determination module, configured to determine a matching loss value based on a difference between the sample label and the predicted matching result; A training module is used to train the text matching model based on the matching loss value and the distance loss value to obtain a target matching model, and the target matching model is used to match the target text content to obtain a matching result.
10. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the text matching method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one program code, and the program code is loaded and executed by a processor to implement the text matching method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program / instructions, characterized in that: The computer program / instructions are stored in a computer-readable storage medium, and the processor of the computer device reads the computer program / instructions from the computer-readable storage medium. The processor executes the computer program / instructions, so that the computer device executes to implement the text matching method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for generating information
CN111897951A
Text classification method
CN113344031A