Text data processing method and device, computer device and storage medium
By acquiring and cross-processing the fused semantic and spatial information of text data, and combining them into combined features for matching, the problem of insufficient adaptability and robustness of text data matching in existing technologies is solved, and more efficient text data matching is achieved.
Patent Information
- Application Number
- CN202110917810.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-11
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2041-10-16
AI Technical Summary
Existing technologies have poor adaptability and robustness in matching keywords with descriptive information in text data processing, especially when the dictionary does not contain keywords or the structure is highly variable, making effective matching difficult.
By acquiring and fusing semantic and spatial information, and performing cross-processing, semantic and spatial features are obtained, which are then combined into combined features. Matching is then performed to determine whether the text data matches.
It improves the adaptability and robustness of text data matching, effectively handling keywords not included in the dictionary and situations with varying structures, achieving more accurate matching results.
Smart Images

Figure CN114282543B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a text data processing method and device, computer equipment and storage medium. BACKGROUND
[0002] Currently, in many scenarios, OCR (Optical Character Recognition) technology is used for text recognition, and after that, the recognized text data needs to be structured and processed to determine the keywords and the description information corresponding to the keywords.
[0003] In the related art, after the text data is recognized, the text data is matched with the preset keywords in a dictionary to find the keywords in the text data, and then based on the preset rules, the description information corresponding to the keywords is found in the text data. However, the keywords in the text data may not be included in the dictionary, or the structure of the text data is variable, which causes the keywords and the corresponding description information not to satisfy the preset rules, so the adaptability and robustness of the above technology are poor. SUMMARY
[0004] Embodiments of the present application provide a text data processing method, device, computer equipment and medium, which improve the adaptability and robustness of text data matching. The technical solution is as follows:
[0005] On the one hand, a text data processing method is provided, the method comprising:
[0006] Based on the first text data and the second text data, fusion semantic information and fusion spatial information are obtained;
[0007] The first semantic feature corresponding to the fusion semantic information and the first spatial feature corresponding to the fusion spatial information are cross-processed to obtain a second semantic feature and a second spatial feature respectively; the second semantic feature and the second spatial feature are combined to obtain a combined feature;
[0008] The combined feature is matched to obtain a matching result, the matching result indicating whether the first text data and the second text data match;
[0009] Wherein, the first text data and the second text data are any two text data recognized from the same object, the fusion semantic information represents the semantics of the first text data and the second text data, and the fusion spatial information represents the position of the first text data and the second text data in the object.
[0010] In another aspect, a text data processing apparatus is provided, the apparatus comprising:
[0011] an information obtaining module configured to obtain fused semantic information and fused spatial information based on the first text data and the second text data;
[0012] a cross processing module configured to cross process a first semantic feature corresponding to the fused semantic information and a first spatial feature corresponding to the fused spatial information to obtain a second semantic feature and a second spatial feature respectively, and combine the second semantic feature and the second spatial feature to obtain a combined feature;
[0013] a matching processing module configured to perform matching processing on the combined feature to obtain a matching result, the matching result indicating whether the first text data and the second text data match;
[0014] wherein the first text data and the second text data are any two text data recognized from a same object, the fused semantic information represents semantics of the first text data and the second text data, and the fused spatial information represents positions of the first text data and the second text data in the object.
[0015] Optionally, the information obtaining module comprises:
[0016] an information obtaining unit configured to obtain first semantic information and first spatial information of the first text data, and second semantic information and second spatial information of the second text data;
[0017] a first fusing unit configured to fuse the first semantic information and the second semantic information to obtain the fused semantic information;
[0018] a second fusing unit configured to fuse the first spatial information and the second spatial information to obtain the fused spatial information.
[0019] Optionally, the information obtaining unit is configured to:
[0020] add vectors corresponding to each character in the first text data to obtain the first semantic information, and obtain the first spatial information based on vertex coordinates of a text box in which the first text data is located in the object;
[0021] add vectors corresponding to each character in the second text data to obtain the second semantic information, and obtain the second spatial information based on vertex coordinates of a text box in which the second text data is located in the object.
[0022] Optionally, the cross processing module comprises:
[0023] The first obtaining unit is configured to obtain a first query feature, a first key feature and a first value feature corresponding to the first semantic feature;
[0024] The first obtaining unit is further configured to obtain a second query feature, a second key feature and a second value feature corresponding to the first spatial feature;
[0025] The second obtaining unit is configured to obtain the second semantic feature based on the second query feature, the first key feature and the first value feature;
[0026] The second obtaining unit is further configured to obtain the second spatial feature based on the first query feature, the second key feature and the second value feature.
[0027] Optionally, the first obtaining unit is configured to:
[0028] multiply the first semantic feature by a parameter matrix to obtain a semantic matrix, and obtain the first query feature, the first key feature and the first value feature based on the semantic matrix;
[0029] The first obtaining unit is further configured to:
[0030] multiply the first spatial feature by the parameter matrix to obtain a spatial matrix, and obtain the second query feature, the second key feature and the second value feature based on the spatial matrix.
[0031] Optionally, the second obtaining unit is configured to:
[0032] normalize a product of the second query feature, the first key feature and a scaling factor to obtain a first normalized feature, and determine a product of the first normalized feature and the first value feature as the second semantic feature;
[0033] The second obtaining unit is further configured to:
[0034] normalize a product of the first query feature, the second key feature and the scaling factor to obtain a second normalized feature, and determine a product of the second normalized feature and the second value feature as the second spatial feature.
[0035] Optionally, the apparatus further comprises:
[0036] The feature segmentation module is configured to respectively divide the first query feature, the first key feature and the first value feature into a plurality of first query sub-features, a plurality of first key sub-features and a plurality of first value sub-features, and respectively divide the second query feature, the second key feature and the second value feature into a plurality of second query sub-features, a plurality of second key sub-features and a plurality of second value sub-features.
[0037] The second obtaining unit is configured to:
[0038] obtain a plurality of second semantic sub-features based on the plurality of second query sub-features, the plurality of first key sub-features, and the plurality of first value sub-features, respectively, splice the plurality of second semantic sub-features to obtain the second semantic feature;
[0039] The second obtaining unit is further configured to:
[0040] obtain a plurality of second spatial sub-features based on the plurality of first query sub-features, the plurality of second key sub-features, and the plurality of second value sub-features, respectively, and splice the plurality of second spatial sub-features to obtain the second spatial feature.
[0041] Optionally, the text matching model comprises a feature extraction network, a cross processing network, and a matching network; and the apparatus further comprises:
[0042] a feature extraction module configured to invoke the feature extraction network to perform feature extraction on the fused semantic information and the fused spatial information respectively to obtain a third semantic feature and a third spatial feature;
[0043] The cross processing module is configured to invoke the cross processing network to perform feature extraction on the third semantic feature and the third spatial feature respectively to obtain the first semantic feature and the first spatial feature, perform cross processing on the first semantic feature and the first spatial feature to obtain the second semantic feature and the second spatial feature respectively, and combine the second semantic feature and the second spatial feature to obtain the combined feature;
[0044] The matching processing module is configured to invoke the matching network to perform matching processing on the combined feature to obtain the matching result.
[0045] Optionally, the cross processing network is configured to:
[0046] obtain the first query feature, the first key feature, and the first value feature corresponding to the first semantic feature;
[0047] obtain the second query feature, the second key feature, and the second value feature corresponding to the first spatial feature;
[0048] obtain the second semantic feature based on the second query feature, the first key feature, and the first value feature;
[0049] obtain the second spatial feature based on the first query feature, the second key feature, and the second value feature.
[0050] Optionally, the text matching model comprises a plurality of cross processing networks; and the cross processing module comprises:
[0051] a cross processing unit, configured to perform feature extraction on the third semantic feature and the third spatial feature based on a first cross processing network to obtain a first semantic feature and a first spatial feature, and perform cross processing on the first semantic feature and the first spatial feature to obtain a fourth semantic feature and a fourth spatial feature, respectively;
[0052] the cross processing unit is further configured to perform feature extraction and cross processing on the fourth semantic feature and the fourth spatial feature based on a second cross processing network, until the second semantic feature and the second spatial feature output by a last cross processing network are obtained;
[0053] a combination unit, configured to combine the second semantic feature and the second spatial feature to obtain the combined feature.
[0054] Optionally, the apparatus further comprises:
[0055] a sample acquisition module, configured to acquire sample fusion semantic information and sample fusion spatial information based on first sample text data and second sample text data;
[0056] a feature extraction module, configured to perform feature extraction on the sample fusion semantic information and the sample fusion spatial information based on the feature extraction network to obtain a first sample semantic feature and a first sample spatial feature;
[0057] the cross processing module is further configured to perform cross processing on the first sample semantic feature and the first sample spatial feature based on the cross processing network to obtain a second sample semantic feature and a second sample spatial feature, respectively, and combine the second sample semantic feature and the second sample spatial feature to obtain a sample combined feature;
[0058] the matching processing module is further configured to perform matching processing on the sample combined feature based on the matching network to obtain a sample matching result;
[0059] a model training module, configured to train the text matching model based on a matching result of the first sample text data and the second sample text data and the sample matching result.
[0060] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to perform the operations performed in the text data processing method as described above.
[0061] On the other hand, a computer-readable storage medium is provided that stores at least one computer program, which is loaded and executed by a processor to perform the operations performed in the text data processing method described above.
[0062] On the other hand, a computer program product or computer program is provided, the computer program product or computer program including computer program code stored in a computer-readable storage medium, a processor of a computer device reading the computer program code from the computer-readable storage medium, the processor executing the computer program code, causing the computer device to perform the operations performed in the text data processing method described above.
[0063] In the technical solution provided in this application embodiment, the first semantic feature represents the feature of the fused semantic information of the first text data and the second text data, and the first spatial feature represents the feature of the fused spatial information of the first text data and the second text data. By combining the second semantic feature and the second spatial feature after cross-processing the first semantic feature and the first spatial feature, a combined feature covering the semantic features and spatial features of the two text data can be obtained. Therefore, by performing matching processing on the combined feature, the matching result of the two text data can be obtained. The above method can achieve matching of any two text data, improving the adaptability and robustness of text data matching. Attached Figure Description
[0064] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0065] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application;
[0066] Figure 2 This is a flowchart of a text data processing method provided in an embodiment of this application;
[0067] Figure 3 This is a flowchart of another text data processing method provided in the embodiments of this application;
[0068] Figure 4 is a structural schematic diagram of a text matching model provided by an embodiment of the present application;
[0069] Figure 5 is a structural schematic diagram of another text matching model provided by an embodiment of the present application;
[0070] Figure 6 is a flowchart of another text data processing method provided by an embodiment of the present application;
[0071] Figure 7 is a structural schematic diagram of a feature extraction layer provided by an embodiment of the present application;
[0072] Figure 8 is a structural schematic diagram of a cross processing layer provided by an embodiment of the present application;
[0073] Figure 9 is a flowchart of a text matching model training method provided by an embodiment of the present application;
[0074] Figure 10 is a flowchart of a text data processing method provided by an embodiment of the present application;
[0075] Figure 11 is a schematic diagram of a medical text image provided by an embodiment of the present application;
[0076] Figure 12 is a structural schematic diagram of a text data processing apparatus provided by an embodiment of the present application;
[0077] Figure 13 is a structural schematic diagram of another text data processing apparatus provided by an embodiment of the present application;
[0078] Figure 14 is a structural schematic diagram of a terminal provided by an embodiment of the present application;
[0079] Figure 15 is a structural schematic diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION
[0080] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.
[0081] It can be understood that the terms "first", "second" and the like used in the present application can be used herein to describe various concepts, but unless specifically stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the present application, a first semantic feature can be referred to as a second semantic feature, and a second semantic feature can be referred to as a first semantic feature.
[0082] The terms "at least one", "multiple", "each", "any" and the like used in the present application include one, two or more than two, multiple includes two or more than two, each refers to each of the corresponding multiple, and any refers to any one of the multiple. For example, a plurality of cross processing networks includes 3 cross processing networks, and each cross processing network refers to each of the 3 cross processing networks, and any refers to any one of the 3 cross processing networks, which can be the first, the second or the third.
[0083] Artificial intelligence (AI) is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0084] Artificial intelligence technology is a comprehensive discipline, involving a wide range of fields, both hardware and software level technology. Artificial intelligence basic technology generally includes such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction system, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, automatic driving, intelligent transportation and other several major directions.
[0085] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithmic complexity theory, etc. It is a specialized study of how computers simulate or implement human learning behavior to acquire new knowledge or skills, reorganize existing knowledge structure, and continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent. Its applications are widespread in various fields of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.
[0086] Computer Vision (CV) is a science that studies how to make machines "see". More specifically, it refers to using cameras and computers to replace human eyes to identify, track and measure targets, and further process images to make them more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision researches related theories and technologies, and attempts to establish artificial intelligence systems that can obtain information from images or multidimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR (Optical Character Recognition), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, autonomous driving, intelligent transportation, etc. It also includes common face recognition, fingerprint recognition and other biometric identification technologies.
[0087] Nature Language Processing (NLP) is an important direction in the field of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph, etc.
[0088] The following will describe the text data processing method provided by the embodiments of the present application based on artificial intelligence technology, computer vision technology and natural language processing technology.
[0089] The text data processing method provided by the embodiments of the present application can be used in a computer device. Optionally, the computer device is a terminal or a server. Optionally, the server is a physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (Content Delivery Network), and big data and artificial intelligence platform. Optionally, the terminal is a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like, but is not limited thereto.
[0090] In a possible implementation, the computer program related to the embodiments of the present application can be deployed to execute on one computer device, or on multiple computer devices located in one place, or on multiple computer devices distributed in multiple places and interconnected through a communication network, and the multiple computer devices distributed in multiple places and interconnected through a communication network can constitute a blockchain system.
[0091] In a possible implementation, the computer device for training the text matching model in the embodiments of the present application is a node in the blockchain system, which can store the trained text matching model in the blockchain, and then the node or the corresponding node of other devices in the blockchain can perform matching processing on any two text data based on the text matching model.
[0092] Figure 1 is a schematic diagram of an implementation environment provided by the embodiments of the present application, referring to Figure 1 The implementation environment includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected through a wireless or wired network. Optionally, the server 102 is configured to train a text matching model by using the method provided by the embodiments of the present application, and the text matching model is used to determine whether any two text data match. The server 102 sends the trained text matching model to the terminal 101, and the terminal 101 can call the text matching model to perform matching processing on any two text data to obtain a matching result.
[0093] In a possible implementation, the terminal 101 runs an application client provided by the server, and the server 102 stores the trained text matching model in the application client. The application client has a text data processing function. The terminal 101 calls the text matching model to perform matching processing on any two text data to obtain a matching result based on the application client.
[0094] It should be noted that Figure 1In another embodiment, the text matching model can also be directly trained by the terminal 101.
[0095] Figure 2 is a flowchart of a text data processing method provided by an embodiment of the present application. The execution subject of the embodiment of the present application is a computer device. Referring to Figure 2 , the method comprises the following steps:
[0096] 201. The computer device obtains fusion semantic information and fusion spatial information based on the first text data and the second text data.
[0097] The computer device obtains the first text data and the second text data, which are any two text data identified from the same object. For example, the first text data and the second text data are any two text data identified from the same table, the same image, or the same article. The first text data and the second text data are located at different positions in the object, and the first text data and the second text data include characters or numerical values, etc.
[0098] The computer device obtains fusion semantic information corresponding to the first text data and the second text data, and fusion spatial information corresponding to the first text data and the second text data. The fusion semantic information represents the semantics of the first text data and the second text data, and the fusion spatial information represents the positions of the first text data and the second text data in the object.
[0099] 202. The computer device cross-processes a first semantic feature corresponding to the fusion semantic information and a first spatial feature corresponding to the fusion spatial information, to obtain a second semantic feature and a second spatial feature, respectively.
[0100] The computer device obtains a first semantic feature corresponding to the fusion semantic information, and a first spatial feature corresponding to the fusion spatial information. The first semantic feature is a feature of the fusion semantic information, i.e., a semantic feature of the first text data and the second text data. The first spatial feature is a feature of the fusion spatial information, i.e., a spatial feature of the first text data and the second text data.
[0101] The computer device cross-processes the first semantic feature and the first spatial feature to obtain a second semantic feature and a second spatial feature. The cross-processing refers to cross-processing the first semantic feature and the first spatial feature to obtain the second semantic feature and the second spatial feature. The second semantic feature covers part of the features represented by the first semantic feature and the first spatial feature, and the second spatial feature also covers part of the features represented by the first semantic feature and the first spatial feature.
[0102] 203、The computer device combines the second semantic feature and the second spatial feature to obtain a combined feature.
[0103] After obtaining the second semantic feature and the second spatial feature, the computer device combines the second semantic feature and the second spatial feature into a combined feature, so that the combined feature contains the second semantic feature and the second spatial feature.
[0104] 204、The computer device performs matching processing on the combined feature to obtain a matching result.
[0105] The combined feature obtained by the computer device contains semantic features of the first text data and the second text data, and spatial features of the first text data and the second text data. The computer device performs matching processing on the combined feature, which is equivalent to performing matching processing on the semantic features of the first text data and the second text data, and performing matching processing on the spatial features of the first text data and the second text data, thereby obtaining a matching result indicating whether the first text data and the second text data match.
[0106] In the method provided by the embodiment of the application, the first semantic feature represents the feature of the fused semantic information of the first text data and the second text data, and the first spatial feature represents the feature of the fused spatial information of the first text data and the second text data. By combining the second semantic feature and the second spatial feature obtained by cross processing of the first semantic feature and the first spatial feature, the combined feature containing the semantic features and the spatial features of the two text data can be obtained. Therefore, by performing matching processing on the combined feature, the matching result of the two text data can be obtained. The above method can realize matching of any two text data, and improves the adaptability and robustness of text data matching.
[0107] Figure 3 is a flowchart of a text data processing method provided by an embodiment of the application. The execution subject of the embodiment of the application is a computer device. Referring to Figure 3 , the method comprises the following steps:
[0108] 301、The computer device obtains first semantic information and first spatial information of first text data, and second semantic information and second spatial information of second text data.
[0109] The first text data and the second text data are any two text data identified from the same object. The computer device identifies the same object to obtain a plurality of text data in the object, and each text data is located at a different position in the object. The computer device takes any two text data in the plurality of text data as the first text data and the second text data. The object can be a table, a photographed image, or an article, etc.
[0110] The computer device acquires first semantic information and first spatial information of first text data, and second semantic information and second spatial information of second text data. The first semantic information represents the semantics of the first text data, the first spatial information represents the position of the first text data within the object, and the second semantic information represents the semantics of the second text data, while the second spatial information represents the position of the second text data within the object.
[0111] In one possible implementation, the process by which the computer device acquires the first semantic information and the first spatial information includes: the computer device adding the vectors corresponding to each character in the first text data to obtain the first semantic information, and acquiring the first spatial information based on the vertex coordinates of the text box in the object where the first text data is located.
[0112] The computer device performs semantic recognition on the first text data, obtaining a vector corresponding to each character of the first text data. The vector corresponding to each character represents the semantics of that character. The computer device adds the vectors corresponding to multiple characters to obtain first semantic information. Since this first semantic information contains the semantics of each character in the first text data, it can represent the semantics of the first text data. Optionally, the vector corresponding to each character is a word embedding. The characters in the first text data can be text or numbers, etc., and text includes Chinese characters or English characters, etc., which are not limited in this embodiment.
[0113] The first text data is the text data identified within the object. Optionally, the computer device identifies the object, obtaining multiple text boxes, each indicating the location of the text data. The computer device identifies the data in each text box as text data, thus each piece of text data corresponds to a text box. The computer device determines the text box where the first text data is located within the object, and determines the vertex coordinates of the text box. These vertex coordinates represent the position of the first text data, and therefore, based on these vertex coordinates, the computer device obtains the first spatial information corresponding to the first text data.
[0114] Optionally, the computer device obtains the vertex coordinates corresponding to the four vertices of the text box, and concatenates the obtained four vertex coordinates to obtain the first spatial information. Alternatively, the computer device adds the obtained four vertex coordinates to obtain the first spatial information. Since the first spatial information contains the vertex coordinates of the four vertices of the text box where the first text data is located, the first spatial information can represent the position of the first text data.
[0115] Correspondingly, the process of obtaining the second semantic information and the second spatial information by the computer device comprises: adding vectors corresponding to each character in the second text data to obtain the second semantic information, and obtaining the second spatial information based on the vertex coordinates of the text box in which the second text data is located. The process of obtaining the second semantic information and the second spatial information is the same as the process of obtaining the first semantic information and the first spatial information, and will not be described here.
[0116] 302. The computer device fuses the first semantic information and the second semantic information to obtain fused semantic information, and fuses the first spatial information and the second spatial information to obtain fused spatial information.
[0117] The fused semantic information contains the first semantic information and the second semantic information, and therefore represents the semantics of the first text data and the second text data. The fused spatial information contains the first spatial information and the second spatial information, and therefore represents the positions of the first text data and the second text data.
[0118] In a possible implementation, the first semantic information and the second semantic information are in the form of vectors, and the computer device adds the first semantic information and the second semantic information to obtain the fused semantic information. Alternatively, the computer device splices the first semantic information and the second semantic information to obtain the fused semantic information. In a possible implementation, the first spatial information and the second spatial information are also in the form of vectors, and the computer device adds the first spatial information and the second spatial information to obtain the fused spatial information. Alternatively, the computer device splices the first spatial information and the second spatial information to obtain the fused spatial information.
[0119] For example, the first semantic information is obtained by adding vectors of each character in the first text data, the second semantic information is obtained by adding vectors of each character in the second text data, and the fused semantic information is obtained by adding the first semantic information and the second semantic information, which is equivalent to adding vectors of each character in the first text data and vectors of each character in the second text data by the computer device to obtain the fused semantic information.
[0120] For example, the first spatial information is obtained by adding four vertex coordinates of the text box in which the first text data is located, the second spatial information is obtained by adding four vertex coordinates of the text box in which the second text data is located, and the fused spatial information is obtained by adding the first spatial information and the second spatial information, which is equivalent to adding four vertex coordinates of the text box in which the first text data is located and four vertex coordinates of the text box in which the second text data is located by the computer device to obtain the fused spatial information.
[0121] The steps 301-302 above illustrate the process of fusing the first semantic information of the first text data and the second semantic information of the second text data, and fusing the first spatial information of the first text data and the second spatial information of the second text data, to obtain fused semantic information and fused spatial information based on the first text data and the second text data. In another embodiment, the computer device can also obtain the fused semantic information and the fused spatial information in other manners.
[0122] 303. The computer device extracts features from the fused semantic information and the fused spatial information respectively to obtain first semantic features and first spatial features.
[0123] The computer device extracts features from the fused semantic information to obtain first semantic features corresponding to the fused semantic information, which are features of the fused semantic information, i.e., semantic features of the first text data and the second text data. The computer device extracts features from the fused spatial information to obtain first spatial features corresponding to the fused spatial information, which are features of the fused spatial information, i.e., spatial features of the first text data and the second text data.
[0124] 304. The computer device obtains first query features, first key features, and first value features corresponding to the first semantic features, and obtains second query features, second key features, and second value features corresponding to the first spatial features.
[0125] The computer device can obtain corresponding first query features, first key features, and first value features by performing different spatial transformations on the first semantic features, and can obtain corresponding second query features, second key features, and second value features by performing different linear transformations on the first spatial features. The query features, the key features, and the value features belong to different feature spaces respectively, and the query features can determine the matching degree between the key features and the value features.
[0126] In a possible implementation manner, the process of obtaining the first query features, the first key features, and the first value features by the computer device includes: multiplying the first semantic features by a parameter matrix to obtain a semantic matrix, and obtaining the first query features, the first key features, and the first value features based on the semantic matrix.
[0127] The computer device obtains a parameter matrix, which is used to perform spatial transformation on the first semantic feature. The computer device multiplies the first semantic feature by the parameter matrix to obtain a semantic matrix. The computer device splits the semantic matrix into the first query feature, the first key feature, and the first value feature. For example, the parameter matrix is a 3-dimensional parameter matrix. The semantic matrix obtained by multiplying the first semantic feature by the parameter matrix is a 3-dimensional semantic matrix. The computer device takes each dimension of the semantic matrix as the first query feature, the first key feature, and the first value feature, respectively.
[0128] Correspondingly, the computer device multiplies the first spatial feature by the parameter matrix to obtain a spatial matrix. Based on the spatial matrix, the computer device obtains the second query feature, the second key feature, and the second value feature. The process of obtaining the second query feature, the second key feature, and the second value feature is the same as the process of obtaining the first query feature, the first key feature, and the first value feature, which will not be described herein again.
[0129] 305、The computer device obtains the second semantic feature based on the second query feature, the first key feature, and the first value feature. The computer device obtains the second spatial feature based on the first query feature, the second key feature, and the second value feature.
[0130] The first query feature, the first key feature, and the first value feature belong to the features of the first text data. The second query feature, the second key feature, and the second value feature belong to the features of the second text data. The computer device obtains the second semantic feature based on the second query feature, the first key feature, and the first value feature. Therefore, the second semantic feature covers the first key feature and the first value feature of the first text data, and the second query feature used to match the key and the value in the second text data. The computer device obtains the second spatial feature based on the first query feature, the second key feature, and the second value feature. The second spatial feature covers the second key feature and the second value feature of the second text data, and the first query feature used to match the key and the value in the first text data. In other words, the computer device exchanges the query feature corresponding to the first text data with the query feature corresponding to the second text data, and thus cross-processes the first semantic feature of the first text data and the first spatial feature of the second text data.
[0131] In a possible implementation manner, the process of obtaining the second semantic feature based on the second query feature, the first key feature, and the first value feature includes: normalizing the product of the second query feature, the first key feature, and a scaling factor to obtain a first normalized feature. The computer device determines the product of the first normalized feature and the first value feature as the second semantic feature.
[0132] The computer device obtains a scaling factor, which represents a normalized scaling multiple. In an embodiment of the present application, the computer device determines a product of the second query feature and the first key feature, which can represent a correlation between the second query feature and the first key feature. The computer device normalizes the product by using the scaling factor as a normalization parameter to obtain a first normalized feature, which represents the correlation between the second query feature and the first key feature. Then, the computer device can use the first normalized feature as a weight of the first value feature, and thus determines a product of the first normalized feature and the first value feature as the second semantic feature.
[0133] Correspondingly, the computer device obtains the second spatial feature based on the first query feature, the second key feature, and the second value feature, including: normalizing a product of the first query feature, the second key feature, and the scaling factor to obtain a second normalized feature, and determining a product of the second normalized feature and the second value feature as the second spatial feature. The process of obtaining the second spatial feature is similar to the process of obtaining the second semantic feature, and thus is not described herein.
[0134] In an embodiment of the present application, in the process of feature extraction, the first semantic feature and the first spatial feature are respectively divided into a query feature, a key feature, and a value feature. The first query feature corresponding to the first text data and the second query feature corresponding to the second text data are interchanged to obtain the second semantic feature and the second spatial feature. Therefore, the information quantity of the second semantic feature and the second spatial feature can be improved, and subsequent matching processing based on the second semantic feature and the second spatial feature can improve the accuracy of matching.
[0135] In a possible implementation manner, the computer device divides the first query feature, the first key feature, and the first value feature into a plurality of first query sub-features, a plurality of first key sub-features, and a plurality of first value sub-features, respectively, and divides the second query feature, the second key feature, and the second value feature into a plurality of second query sub-features, a plurality of second key sub-features, and a plurality of second value sub-features, respectively. Then, the computer device obtains the second semantic feature and the second spatial feature, including: obtaining a plurality of second semantic sub-features based on the plurality of second query sub-features, the plurality of first key sub-features, and the plurality of first value sub-features, respectively, splicing the plurality of second semantic sub-features to obtain the second semantic feature, obtaining a plurality of second spatial sub-features based on the plurality of first query sub-features, the plurality of second key sub-features, and the plurality of second value sub-features, respectively, and splicing the plurality of second spatial sub-features to obtain the second spatial feature.
[0136] The computer device segments the first query feature to obtain a plurality of first query sub-features, segments the first key feature to obtain a plurality of first key sub-features, and segments the first value feature to obtain a plurality of first value sub-features. The number of the plurality of first query sub-features, the number of the plurality of first key sub-features, and the number of the plurality of first value sub-features are equal. The computer device divides the plurality of first query sub-features, the plurality of first key sub-features, and the plurality of first value sub-features into a plurality of first sub-feature sets, and each first sub-feature set includes one first query sub-feature, one first key sub-feature, and one first value sub-feature. Taking the first query feature as an example, for example, the first query feature is one feature vector, and the feature vector is evenly divided into eight feature sub-vectors, and the computer device respectively takes each feature sub-vector as a first query sub-feature.
[0137] Correspondingly, the computer device divides the second query feature, the second key feature, and the second value feature into a plurality of second query sub-features, a plurality of second key sub-features, and a plurality of second value sub-features, and divides the plurality of second query sub-features, the plurality of second key sub-features, and the plurality of second value sub-features into a plurality of second sub-feature sets, and each second sub-feature set includes one second query sub-feature, one second key sub-feature, and one second value sub-feature.
[0138] The number of the plurality of first sub-feature sets is equal to the number of the plurality of second sub-feature sets. The computer device groups the first sub-feature sets and the second sub-feature sets two by two, for example, the computer device groups according to the segmentation order. For each group of first sub-feature sets and second sub-feature sets, the computer device obtains one second semantic sub-feature based on the first key sub-feature and the first value sub-feature in the first sub-feature set and the second query sub-feature in the second sub-feature set, and obtains one second spatial sub-feature based on the first query sub-feature in the first sub-feature set and the second key sub-feature and the second value sub-feature in the second sub-feature set. For each group of first sub-feature sets and second sub-feature sets, the computer device can obtain one second semantic sub-feature and one second spatial sub-feature, so the computer device can obtain a plurality of second semantic sub-features and a plurality of second spatial sub-features. The computer device splices the plurality of second semantic sub-features to obtain a second semantic feature, and splices the plurality of second spatial sub-features to obtain a second spatial feature.
[0139] Optionally, the computer device splices the plurality of second semantic sub-features to obtain a spliced semantic sub-feature, and determines the product of the spliced semantic sub-feature and a parameter matrix as the second semantic feature. The computer device splices the plurality of second spatial sub-features to obtain a spliced spatial sub-feature, and determines the product of the spliced spatial sub-feature and the parameter matrix as the second spatial feature.
[0140] For example, taking the second semantic feature as an example, the computer device uses the following algorithm to obtain the second semantic feature.
[0141] MSA(y)=[SA1(y);SA2(y);…;SA k (y)]U msa ;
[0142] wherein, SA1(y), SA2(y)…SA k (y) respectively represent second semantic sub-features, [·] represents splicing, U msa represents a parameter matrix, and MSA(y) represents a second semantic feature.
[0143] The computer device realizes cross processing of the first semantic feature corresponding to the fused semantic information and the first spatial feature corresponding to the fused spatial information to obtain the second semantic feature and the second spatial feature respectively by performing the above steps 304-305. In another embodiment, the computer device can also cross process the first semantic feature and the second spatial feature in other manners to obtain the second semantic feature and the second spatial feature.
[0144] 306、The computer device combines the second semantic feature and the second spatial feature to obtain a combined feature.
[0145] After obtaining the second semantic feature and the second spatial feature, the computer device combines the second semantic feature and the second spatial feature into a combined feature, so that the combined feature contains the second semantic feature and the second spatial feature.
[0146] In a possible implementation manner, the computer device splices the second semantic feature and the second spatial feature to obtain the combined feature. Alternatively, the computer device adds the second semantic feature and the second spatial feature to obtain the combined feature.
[0147] 307、The computer device performs matching processing on the combined feature to obtain a matching result.
[0148] The combined feature obtained by the computer device contains semantic features of the first text data and the second text data, and spatial features of the first text data and the second text data. The computer device performs matching processing on the combined feature, which is equivalent to performing matching processing on the semantic features of the first text data and the second text data, and performing matching processing on the spatial features of the first text data and the second text data, thereby obtaining a matching result. The matching result indicates whether the first text data and the second text data match.
[0149] In a possible implementation, the matching result is a first matching result or a second matching result, the first matching result indicating that the first text data and the second text data match, and the second matching result indicating that the first text data and the second text data do not match. Optionally, the first matching result is a first numerical value, and the second matching result is a second numerical value, for example, the first numerical value is 1, and the second numerical value is 0.
[0150] In the embodiments of the present application, the first text data and the second text data match means that the content of the first text data and the content of the second text data are associated. Optionally, the content of the first text data is a keyword (key), and the second text data that matches the first text data is a value corresponding to the keyword, which can be understood as description information corresponding to the keyword. For example, the first text data is "admission date", and the second text data is "2021-8-8", and the first text data and the second text data match. For example, the first text data is "admission date", and the second text data is "622 yuan", and the first text data and the second text data do not match. In the above examples, the first text data is a keyword, and the second text data is a value. In addition, the first text data can also be a value, and the second text data can also be a keyword.
[0151] In a possible implementation, in the case where the first text data and the second text data match, the computer device determines the keyword and the value in the first text data and the second text data based on the character type of the first text data and the character type of the second text data. For example, the character type belonging to the numerical value type in the first text data and the second text data is determined as a value, and the character type belonging to other types is determined as a keyword. Therefore, the embodiments of the present application provide a method for matching text data of different character types, so that for multiple text data in an object, the matching relationship between the multiple text data can be determined by using the method provided in the embodiments of the present application, so as to facilitate text structuring of the object according to the matching relationship, and the complexity of text structuring is reduced.
[0152] The method provided in the embodiments of the present application, the first semantic feature represents the feature of the fusion semantic information of the first text data and the second text data, and the first spatial feature represents the feature of the fusion spatial information of the first text data and the second text data. The combination of the second semantic feature and the second spatial feature obtained by cross processing the first semantic feature and the first spatial feature can obtain the combination feature covering the semantic feature and the spatial feature of the two text data, so that the matching processing of the combination feature can obtain the matching result of the two text data. The above method can realize the matching of any two text data, and improve the adaptability and robustness of text data matching.
[0153] And, since the embodiment of the application can simultaneously consider the matching conditions between the semantic features of the text data and the matching conditions between the spatial features, the information dimension referenced in the matching processing of the text data is expanded, which is conducive to improving the accuracy of the text data matching.
[0154] And, in the process of feature extraction, the first semantic features and the first spatial features are respectively divided into query features, key features and value features, the first query features corresponding to the first text data are interchanged with the second query features corresponding to the second text data to obtain the second semantic features and the second spatial features, so as to improve the information amount of the second semantic features and the second spatial features, and subsequent matching processing based on the second semantic features and the second spatial features is conducive to improving the accuracy of the matching.
[0155] In another embodiment, a computer device stores a text matching model for text data matching. Figure 4 is a structural diagram of a text matching model provided by the embodiment of the application, as Figure 4 shown, the text matching model includes a feature extraction network 401, a cross processing network 402 and a matching network 403. The feature extraction network 401 is connected with the cross processing network 402, and the cross processing network 402 is connected with the matching network 403. The feature extraction network 401 is used to extract semantic features and spatial features of text data, the cross processing network 402 is used to cross process the semantic features and the spatial features of the text data, and the matching network 403 is used to determine whether the text data has a match based on the features of the text data.
[0156] In a possible implementation manner, the cross processing network 402 includes a semantic feature extraction layer, a spatial feature extraction layer and a cross processing layer. As Figure 5 shown, the semantic feature extraction layer and the spatial feature extraction layer in the first cross processing network 402 are respectively connected with the cross processing layer. The semantic feature extraction layer is used to extract semantic features, the spatial feature extraction layer is used to extract spatial features, and the cross processing layer is used to cross process the semantic features and the spatial features. The network parameters of the semantic feature extraction layer and the spatial feature extraction layer are the same, and the semantic feature extraction layer and the spatial feature extraction layer can be processed in parallel.
[0157] Optionally, the text matching model includes a plurality of cross processing networks 402, as Figure 5As shown, the plurality of cross processing networks 402 are connected in sequence. Among them, the semantic feature extraction layer and the spatial feature extraction layer in the first cross processing network 402 are respectively connected with the feature extraction network 401, the semantic feature extraction layer and the spatial feature extraction layer in the cross processing network 402 after the first cross processing network 402 are respectively connected with the cross processing layer in the last cross processing network 402, the semantic feature extraction layer and the spatial feature extraction layer in each cross processing network 402 are respectively connected with the cross processing layer in the cross processing network 402, and the cross processing layer in the last cross processing network 402 is connected with the matching network.
[0158] Figure 6 is a flowchart of a text data processing method provided by an embodiment of the present application. The execution subject of the embodiment of the present application is a computer device, which calls the text matching model shown in Figure 4 or Figure 5 to perform matching processing on the text data. The text matching model includes a feature extraction network, a cross processing network and a matching network, as described in Figure 6 The method includes the following steps:
[0159] 601. The computer device obtains first semantic information and first spatial information of first text data, and second semantic information and second spatial information of second text data.
[0160] 602. The computer device fuses the first semantic information and the second semantic information to obtain fused semantic information, and fuses the first spatial information and the second spatial information to obtain fused spatial information.
[0161] The steps 601-602 are the same as the processes of the steps 301-302 described above, and will not be described here.
[0162] 603. The computer device calls the feature extraction network in the text matching model to perform feature extraction on the fused semantic information and the fused spatial information, respectively, to obtain third semantic features and third spatial features.
[0163] The computer device inputs the fused semantic information into the feature extraction network, and the feature extraction network performs feature extraction on the fused semantic information to output third semantic features corresponding to the fused semantic information. The computer device inputs the fused spatial information into the feature extraction network, and the feature extraction network performs feature extraction on the fused spatial information to output third spatial features corresponding to the fused spatial information.
[0164] In a possible implementation, the fused semantic information and the fused spatial information exist in the form of vectors, and the third semantic feature and the third spatial feature output by the feature extraction network are a matrix of (N+1)*M, where N is the number of characters in the first text data, and M is a feature dimension.
[0165] In a possible implementation, the text matching model includes one feature extraction network, and the computer device inputs the fused semantic information into the feature extraction network to obtain the third semantic feature, and inputs the fused spatial information into the feature extraction network to obtain the third spatial feature. Alternatively, the computer device inputs the fused spatial information into the feature extraction network to obtain the third spatial feature, and inputs the fused semantic information into the feature extraction network to obtain the third semantic feature. In another possible implementation, the text matching model includes two feature extraction networks, and the computer device inputs the fused semantic information into one feature extraction network and inputs the fused spatial information into the other feature extraction network, and the two feature extraction networks are processed in parallel to obtain the third semantic feature and the third spatial feature, respectively. Optionally, the network parameters of the two feature extraction networks are the same.
[0166] 604、The computer device calls the cross processing network in the text matching model, performs feature extraction on the third semantic feature and the third spatial feature to obtain a first semantic feature and a first spatial feature, performs cross processing on the first semantic feature and the first spatial feature to obtain a second semantic feature and a second spatial feature, and combines the second semantic feature and the second spatial feature to obtain a combined feature.
[0167] The computer device inputs the third semantic feature and the third spatial feature into the cross processing network, and the cross processing network performs feature extraction on the third semantic feature and the third spatial feature to obtain a first semantic feature and a first spatial feature, continues to perform cross processing on the first semantic feature and the first spatial feature to obtain a second semantic feature and a second spatial feature, and continues to combine the second semantic feature and the second spatial feature to obtain a combined feature, where the combined feature includes the second semantic feature and the second spatial feature.
[0168] In a possible implementation, the computer device cross-processes the first semantic feature and the first spatial feature to obtain a second semantic feature and a second spatial feature respectively, including: calling a cross-processing network, obtaining a first query feature, a first key feature and a first value feature corresponding to the first semantic feature, obtaining a second query feature, a second key feature and a second value feature corresponding to the first spatial feature, obtaining the second semantic feature based on the second query feature, the first key feature and the first value feature, and obtaining the second spatial feature based on the first query feature, the second key feature and the second value feature. The process is the same as that of steps 304-305 described above, and will not be repeated here. The only difference is that in step 604, the cross-processing network is called to perform the process of obtaining the second semantic feature and the second spatial feature.
[0169] In another possible implementation, as shown in FIG. 6, the cross-processing network includes a semantic feature extraction layer, a spatial feature extraction layer and a cross-processing layer. The computer device calls the cross-processing network to process the third semantic feature and the third spatial feature to obtain the second semantic feature and the second spatial feature, including the following two parts. Figure 5
[0170] (I) The computer device calls the semantic feature extraction layer in the cross-processing network to perform feature extraction on the third semantic feature to obtain the first semantic feature, and calls the spatial feature extraction layer in the cross-processing network to perform feature extraction on the third spatial feature to obtain the first spatial feature.
[0171] The computer device inputs the third semantic feature into the semantic feature extraction layer, and the semantic feature extraction layer performs feature extraction on the third semantic feature to obtain the first semantic feature. The computer device inputs the third spatial feature into the spatial feature extraction layer, and the spatial feature extraction layer performs feature extraction on the third spatial feature to obtain the first spatial feature.
[0172] Optionally, the semantic feature extraction layer is a transformer encoder (an encoder based on machine translation), and the computer device performs feature extraction on the third semantic feature and the third spatial feature based on a self-attention mechanism. The computer device calls the semantic feature extraction layer, determines the product of the third semantic feature and a parameter matrix as a first semantic matrix, and obtains a third query feature, a third key feature and a third value feature based on the first semantic matrix. The product of the third query feature, the third key feature and a scaling factor is normalized to obtain a third normalized feature, and the product of the third normalized feature and the third value feature is determined as a first semantic feature. The computer device calls the spatial feature extraction layer, determines the product of the third spatial feature and a parameter matrix as a first spatial matrix, and obtains a fourth query feature, a fourth key feature and a fourth value feature based on the first spatial matrix. The product of the fourth query feature, the fourth key feature and a scaling factor is normalized to obtain a fourth normalized feature, and the product of the fourth normalized feature and the fourth value feature is determined as a first spatial feature.
[0173] Optionally, taking the first semantic feature as an example, the computer device calls the semantic feature extraction layer, and uses the following algorithm to perform feature extraction on the third semantic feature to obtain the first semantic feature.
[0174] [q,k,v]=yU qkv ;
[0175]
[0176] SA(y)=Av;
[0177] wherein y represents the third semantic feature, U qkv represents a parameter matrix, [q,k,v] represents the first semantic matrix, q represents the third query feature, k represents the third key feature, and v represents the third value feature. represents a scaling factor, softmax(·) represents a normalization function, A represents the third normalized feature, and SA(y) represents the first semantic feature.
[0178] Optionally, the computer device performs feature extraction on the third semantic feature and the third spatial feature based on a multi-head self-attention mechanism. The computer device divides the third query feature, the third key feature and the third value feature into a plurality of third query sub-features, a plurality of third key sub-features and a plurality of third value sub-features respectively, and obtains a plurality of first semantic sub-features based on the plurality of third query sub-features, the plurality of third key sub-features and the plurality of third value sub-features respectively. The computer device concatenates the plurality of first semantic sub-features to obtain the first semantic feature. The computer device divides the fourth query feature, the fourth key feature and the fourth value feature into a plurality of fourth query sub-features, a plurality of fourth key sub-features and a plurality of fourth value sub-features respectively, and obtains a plurality of first spatial sub-features based on the plurality of fourth query sub-features, the plurality of fourth key sub-features and the plurality of fourth value sub-features respectively. The computer device concatenates the plurality of first spatial sub-features to obtain the first spatial feature.
[0179] Optionally, the network structures of the semantic feature extraction layer and the spatial feature extraction layer are the same. Taking the semantic feature extraction layer as an example, Figure 7 is a structural diagram of a semantic feature extraction layer provided by an embodiment of the present application, as shown in Figure 7 The semantic feature extraction layer includes a multi-head self-attention layer 701, a residual and normalization layer 702, a feed forward layer 703 and a residual and normalization layer 704.
[0180] (ii) The computer device calls a cross processing layer in the cross processing network to cross process the first semantic feature and the first spatial feature to obtain the second semantic feature and the second spatial feature respectively.
[0181] Among them, the computer device calls the cross processing layer in the cross processing network to obtain the first query feature, the first key feature and the first value feature corresponding to the first semantic feature, obtains the second query feature, the second key feature and the second value feature corresponding to the first spatial feature, obtains the second semantic feature based on the second query feature, the first key feature and the first value feature, and obtains the second spatial feature based on the first query feature, the second key feature and the second value feature.
[0182] Optionally, the computer device normalizes the product of the second query feature, the first key feature and the scaling factor to obtain the first normalized feature, and determines the product of the first normalized feature and the first value feature as the second semantic feature. The computer device normalizes the product of the first query feature, the second key feature and the scaling factor to obtain the second normalized feature, and determines the product of the second normalized feature and the second value feature as the second spatial feature.
[0183] For example, the computer device calls the cross processing layer to determine the second semantic feature and the second spatial feature by using the following algorithm.
[0184] [q1,k1,v1]=y1U qkv ,[q2,k2,v2]=y2U qkv ;
[0185]
[0186] SA1=A1v1,SA2=A2v2;
[0187] wherein y1 represents the first semantic feature, y2 represents the first spatial feature, U qkv represents a parameter matrix, [q1,k1,v1] represents a semantic matrix, q1 in the semantic matrix represents the first query feature, k1 represents the first key feature, and v1 represents the first value feature. [q2,k2,v2] represents a spatial matrix, q2 in the spatial matrix represents the second query feature, k2 represents the second key feature, and v2 represents the second value feature. A1 represents the first normalized feature, and A2 represents the second normalized feature, represents a scaling factor, and softmax(·) represents a normalization function. SA1 represents the second semantic feature, and SA2 represents the second spatial feature.
[0188] Figure 8 is a structural schematic diagram of a cross processing layer provided by an embodiment of the present application, referring to Figure 8 The cross processing layer includes a multi-layer perception layer 801, a matrix multiplication layer 802, a standardization and normalization layer 803, a matrix multiplication layer 804, a multi-layer perception layer 805, a matrix multiplication layer 806, a standardization and normalization layer 807, and a matrix multiplication layer 808. The multi-layer perception layer 801 is configured to acquire the first query feature q1, the first key feature k1, and the first value feature v1 based on the first semantic feature y1. The multi-layer perception layer 805 is configured to acquire the second query feature q2, the second key feature k2, and the second value feature v2 based on the first spatial feature y2.
[0189] The matrix multiplication layer 802 is configured to multiply the first key feature k1 and the second query feature q2, the standardization and normalization layer 803 is configured to standardize and normalize the product of the first key feature k1 and the second query feature q2 to obtain a first normalized feature, the matrix multiplication layer 804 is configured to multiply the first normalized feature and the first value feature v1 to obtain a second semantic feature SA1. The matrix multiplication layer 806 is configured to multiply the second key feature and the first query feature, the standardization and normalization layer 807 is configured to standardize and normalize the product of the second key feature k2 and the first query feature q1 to obtain a second normalized feature, and the matrix multiplication layer 808 is configured to multiply the second normalized feature and the second value feature v2 to obtain a second spatial feature SA2.
[0190] In another possible implementation, the text matching model includes a plurality of cross processing networks. The computer device performs feature extraction on the third semantic feature and the third spatial feature respectively based on a first cross processing network to obtain a first semantic feature and a first spatial feature, and performs cross processing on the first semantic feature and the first spatial feature to obtain a fourth semantic feature and a fourth spatial feature respectively, performs feature extraction and cross processing on the fourth semantic feature and the fourth spatial feature based on a second cross processing network, until the second semantic feature and the second spatial feature output by a last cross processing network are obtained, and combines the second semantic feature and the second spatial feature to obtain a combined feature.
[0191] In the above implementation, the network structure of each cross processing network is the same but the network parameters are different, and the processing process of each cross processing network is the same, and the output of the last cross processing network is the second semantic feature and the second spatial feature. The computer device combines the second semantic feature and the second spatial feature to obtain the combined feature.
[0192] 605、The computer device invokes a matching network in the text matching model to perform matching processing on the combined feature to obtain a matching result.
[0193] The computer device inputs the combined feature into the matching network, and the matching network performs matching processing on the combined feature to output a corresponding matching result, which indicates whether the first text data and the second text data match. Optionally, the matching network is an MLP (Multi-Layer Perceptron) classification network.
[0194] The method provided in the embodiment of the application is used for matching two text data, and the adaptability and robustness of text data matching are improved.
[0195] In addition, the embodiment of the application calls a text matching model to perform matching processing on the first text data and the second text data, simplifies the process of text data matching, and improves the convenience of matching processing on the text data.
[0196] In addition, the embodiment of the application can simultaneously consider the matching conditions between the semantic features of the text data and the matching conditions between the spatial features, expand the information dimension referred to in the matching processing on the text data, and is beneficial to improving the accuracy of text data matching.
[0197] In addition, the embodiment of the application adopts the multi-head self-attention mechanism and the multi-head cross-attention mechanism, respectively divides the query feature, the key feature and the value feature into corresponding multiple sub-features for processing, can avoid overfitting in the process of feature extraction and cross processing, and further improves the accuracy of the second semantic feature and the second spatial feature.
[0198] In addition, in the process of feature extraction, the first semantic feature and the first spatial feature are respectively divided into query features, key features and value features, the first query feature corresponding to the first text data is interchanged with the second query feature corresponding to the second text data to obtain the second semantic feature and the second spatial feature, so that the information amount of the second semantic feature and the second spatial feature can be improved, and subsequent matching processing according to the second semantic feature and the second spatial feature is beneficial to improving the accuracy of matching.
[0199] Figure 9 is a flowchart of a text matching model training method provided by the embodiment of the application, and the execution subject of the embodiment of the application is a computer device. The text matching model trained in the embodiment can be applied to the embodiment of the application described above. Figure 6 Figure 9 The method comprises the following steps:
[0200] 901. The computer device obtains sample fusion semantic information and sample fusion spatial information based on the first sample text data and the second sample text data.
[0201] To train the text matching model, the computer device first acquires first sample text data and second sample text data, and based on the first sample text data and the second sample text data, acquires sample fusion semantic information and sample fusion spatial information. Wherein, the process of the computer device acquiring sample fusion semantic information and sample fusion spatial information is the same as the process of steps 301-302 described above, and will not be repeated here.
[0202] It should be noted that the process of training the text matching model based on the first sample text data and the second sample text data includes multiple iteration processes, and in each iteration process, the training is performed based on a pair of first sample text data and second sample text data. The steps 901-905 in the embodiments of the present application are only described by taking one iteration process as an example.
[0203] 902, the computer device performs feature extraction on the sample fusion semantic information and the sample fusion spatial information based on the feature extraction network, to obtain first sample semantic features and first sample spatial features.
[0204] 903, the computer device performs cross processing on the first sample semantic features and the first sample spatial features based on the cross processing network, to obtain second sample semantic features and second sample spatial features respectively; and combines the second sample semantic features and the second sample spatial features to obtain sample combination features.
[0205] 904, the computer device performs matching processing on the sample combination features based on the matching network to obtain sample matching results.
[0206] Wherein, the steps 902-904 are the same as the processes of steps 603-605 described above, and will not be repeated here.
[0207] 905, the computer device trains the text matching model based on the matching results of the first sample text data and the second sample text data, and the sample matching results.
[0208] The computer device acquires the matching results of the first sample text data and the second sample text data, which are the real matching results of the first sample text data and the second sample text data. The sample matching results acquired by the computer device are the matching results predicted by the text matching model. The computer device trains the text matching model based on the difference between the sample matching results and the real matching results.
[0209] Since the text matching model aims to match the first sample text data and the second sample text data, so as to obtain a sample matching result of the first sample text data and the second sample text data. Therefore, the more similar the sample matching result is to the real matching result, the more accurate the text matching model is. Then, the computer device trains the text matching model according to the difference between the sample matching result and the real matching result, so as to improve the matching ability of the text matching model, thereby improving the accuracy of the text matching model.
[0210] In a possible implementation, the computer device repeatedly performs the steps 901-905 to iteratively train the text matching model, and stops training the text matching model in response to an iteration round reaching a first threshold value, or in response to a loss value obtained in a current iteration round being not greater than a second threshold value. The first threshold value and the second threshold value are both arbitrary numerical values, for example, the first threshold value is 1000 or 1500, and the second threshold value is 0.004 or 0.003.
[0211] In a possible implementation, the computer device updates the network parameters of the text matching model by using an Adam (Adaptive Moment Estimation)-based gradient descent method. Optionally, the parameters in the Adam are set to (0.95, 0.9995). Optionally, the initial learning rate of the computer device in training the text matching model is 0.001, and the learning rate is reduced by one fifth every 100 iterations.
[0212] The method provided by the embodiment of the present application is used to represent the sample fusion semantic information of the first sample text data and the second sample text data by the first sample semantic feature, and represent the sample fusion spatial information of the first sample text data and the second sample text data by the first sample spatial feature. The second sample semantic feature and the second sample spatial feature obtained by cross processing the first sample semantic feature and the first sample spatial feature are combined, so as to obtain the sample combination feature covering the semantic feature and the spatial feature of the two sample text data. Therefore, the sample matching result of the two sample text data can be obtained by matching the sample combination feature, and the text matching model is trained based on the matching result of the first sample text data and the second sample text data and the sample matching result. The text matching model can match any two text data, thereby improving the adaptability and robustness of the text matching model.
[0213] The above embodiments can be applied to any scene requiring text data matching. For example, in a scene of structuring a medical text image recording information such as examination types, examination times, examination times, and fee amounts of a patient undergoing various medical examinations, the method provided by the above embodiments can be used to determine text data matching each other in the medical text image, thereby structuring the medical text image. Figure 10 is a flowchart of an image clustering method provided by an embodiment of the present application, referring to Figure 10 , the method comprises:
[0214] 1001, the computer device obtains a medical text image, performs text recognition on the medical text image, and obtains a plurality of text data in the medical text image. Wherein, the medical text image is as shown in Figure 11 Figure 11 The content in the black text box in Figure 11 is the recognized text data.
[0215] 1002, the computer device uses the text data processing method provided by the above Figure 4 or Figure 6 embodiments to perform text matching processing on each two text data in the plurality of text data, thereby obtaining a matching result of each two text data, wherein the matching result includes a first matching result and a second matching result, the first matching result indicates that the two text data match, and the second matching result indicates that the two text data do not match.
[0216] 1003, the computer device determines two text data corresponding to the first matching result as a pair of text data matching each other, thereby obtaining a plurality of pairs of text data matching each other, and realizing the structuring of the medical text image.
[0217] For example, in the medical text image shown in Figure 11 , the recognized text data includes "admission date", "2020-05-18", "laboratory fee", "16179.5", etc. Among them, "admission date" and "2020-05-18" match each other, and "laboratory fee" and "16179.5" match each other.
[0218] The above is only used as an example of structuring a medical text image, in addition to this, the computer device can also apply the method provided by the above Figure 4 or Figure 6 embodiments to any scene in the insurance field, the financial field, or the shopping field, etc. which has a structured demand for text images.
[0219] Figure 12 is a structural diagram of a text data processing device provided by an embodiment of the present application. Referring to Figure 12 , the device comprises:
[0220] The information obtaining module 1201 is configured to obtain fusion semantic information and fusion spatial information based on the first text data and the second text data.
[0221] The cross processing module 1202 is configured to cross process the first semantic feature corresponding to the fusion semantic information and the first spatial feature corresponding to the fusion spatial information to obtain a second semantic feature and a second spatial feature respectively, and combine the second semantic feature and the second spatial feature to obtain a combined feature.
[0222] The matching processing module 1203 is configured to perform matching processing on the combined feature to obtain a matching result, the matching result indicating whether the first text data and the second text data match.
[0223] The first text data and the second text data are any two text data identified from the same object, the fusion semantic information represents the semantics of the first text data and the second text data, and the fusion spatial information represents the positions of the first text data and the second text data in the object.
[0224] The text data processing apparatus provided by the embodiment of the present application can obtain the combined feature covering the semantic feature and the spatial feature of the two text data by combining the second semantic feature and the second spatial feature obtained by cross processing the first semantic feature and the first spatial feature, and thus can obtain the matching result of the two text data by performing matching processing on the combined feature, thereby realizing matching of any two text data and improving the adaptability and robustness of text data matching.
[0225] Optionally, referring to Figure 13 , the information obtaining module 1201 comprises:
[0226] The information obtaining unit 1211 is configured to obtain the first semantic information and the first spatial information of the first text data, and the second semantic information and the second spatial information of the second text data.
[0227] The first fusion unit 1221 is configured to fuse the first semantic information and the second semantic information to obtain the fusion semantic information.
[0228] The second fusion unit 1231 is configured to fuse the first spatial information and the second spatial information to obtain the fusion spatial information.
[0229] Optionally, referring to Figure 13 , the information obtaining unit 1211 is configured to:
[0230] The vectors corresponding to each character in the first text data are spliced to obtain first semantic information, and the first spatial information is obtained based on the vertex coordinates of the text box in which the first text data is located in the object;
[0231] The vectors corresponding to each character in the second text data are spliced to obtain second semantic information, and the second spatial information is obtained based on the vertex coordinates of the text box in which the second text data is located in the object.
[0232] Optionally, referring to Figure 13 , the cross processing module 1202 comprises:
[0233] The first obtaining unit 1212 is configured to obtain the first query feature, the first key feature, and the first value feature corresponding to the first semantic feature;
[0234] The first obtaining unit 1212 is further configured to obtain the second query feature, the second key feature, and the second value feature corresponding to the first spatial feature;
[0235] The second obtaining unit 1222 is configured to obtain the second semantic feature based on the second query feature, the first key feature, and the first value feature;
[0236] The second obtaining unit 1222 is further configured to obtain the second spatial feature based on the first query feature, the second key feature, and the second value feature.
[0237] Optionally, referring to Figure 13 , the first obtaining unit 1212 is configured to:
[0238] The product of the first semantic feature and the parameter matrix is obtained to obtain a semantic matrix, and the first query feature, the first key feature, and the first value feature are obtained based on the semantic matrix;
[0239] The first obtaining unit 1212 is further configured to:
[0240] The product of the first spatial feature and the parameter matrix is obtained to obtain a spatial matrix, and the second query feature, the second key feature, and the second value feature are obtained based on the spatial matrix.
[0241] Optionally, referring to Figure 13 , the second obtaining unit 1222 is configured to:
[0242] The product of the second query feature, the first key feature, and the scaling factor is normalized to obtain a first normalized feature, and the product of the first normalized feature and the first value feature is determined as the second semantic feature;
[0243] The second obtaining unit 1222 is further configured to:
[0244] The product of the first query feature, the second key feature and the scaling factor is normalized to obtain a second normalized feature; and the product of the second normalized feature and the second value feature is determined as a second space feature.
[0245] Optionally, referring to Figure 13 , the apparatus further includes:
[0246] The feature segmentation module 1204 is configured to respectively segment the first query feature, the first key feature and the first value feature into a plurality of first query sub-features, a plurality of first key sub-features and a plurality of first value sub-features; and respectively segment the second query feature, the second key feature and the second value feature into a plurality of second query sub-features, a plurality of second key sub-features and a plurality of second value sub-features.
[0247] The second obtaining unit 1222 is configured to:
[0248] The second obtaining unit 1222 is configured to respectively obtain a plurality of second semantic sub-features based on the plurality of second query sub-features, the plurality of first key sub-features and the plurality of first value sub-features, and splice the plurality of second semantic sub-features to obtain a second semantic feature.
[0249] The second obtaining unit 1222 is further configured to:
[0250] The second obtaining unit 1222 is further configured to respectively obtain a plurality of second space sub-features based on the plurality of first query sub-features, the plurality of second key sub-features and the plurality of second value sub-features, and splice the plurality of second space sub-features to obtain a second space feature.
[0251] Optionally, referring to Figure 13 , the text matching model includes a feature extraction network, a cross processing network and a matching network; and the apparatus further includes:
[0252] The feature extraction module 1205 is configured to call the feature extraction network to respectively perform feature extraction on the fused semantic information and the fused space information to obtain a third semantic feature and a third space feature.
[0253] The cross processing module 1202 is configured to call the cross processing network to respectively perform feature extraction on the third semantic feature and the third space feature to obtain a first semantic feature and a first space feature; perform cross processing on the first semantic feature and the first space feature to respectively obtain a second semantic feature and a second space feature; and combine the second semantic feature and the second space feature to obtain a combined feature.
[0254] The matching processing module 1203 is configured to call the matching network to perform matching processing on the combined feature to obtain a matching result.
[0255] Optionally, the cross processing network is configured to:
[0256] obtain the first query feature, the first key feature and the first value feature corresponding to the first semantic feature;
[0257] obtain the second query feature, the second key feature and the second value feature corresponding to the first spatial feature;
[0258] obtain the second semantic feature based on the second query feature, the first key feature and the first value feature;
[0259] obtain the second spatial feature based on the first query feature, the second key feature and the second value feature.
[0260] Optionally, referring to Figure 13 , the text matching model comprises a plurality of cross processing networks; the cross processing module 1202 comprises:
[0261] The cross processing unit 1232 is configured to perform feature extraction on the third semantic feature and the third spatial feature based on the first cross processing network to obtain the first semantic feature and the first spatial feature; and perform cross processing on the first semantic feature and the first spatial feature to obtain the fourth semantic feature and the fourth spatial feature, respectively.
[0262] The cross processing unit 1232 is further configured to perform feature extraction and cross processing on the fourth semantic feature and the fourth spatial feature based on the second cross processing network until the second semantic feature and the second spatial feature output by the last cross processing network are obtained.
[0263] The combination unit 1242 is configured to combine the second semantic feature and the second spatial feature to obtain a combined feature.
[0264] Optionally, referring to Figure 13 , the apparatus further comprises:
[0265] The sample obtaining module 1206 is configured to obtain sample fusion semantic information and sample fusion spatial information based on the first sample text data and the second sample text data.
[0266] The feature extraction module 1205 is configured to perform feature extraction on the sample fusion semantic information and the sample fusion spatial information based on the feature extraction network to obtain the first sample semantic feature and the first sample spatial feature.
[0267] The cross processing module 1202 is further configured to perform cross processing on the first sample semantic feature and the first sample spatial feature based on the cross processing network to obtain the second sample semantic feature and the second sample spatial feature, respectively; and combine the second sample semantic feature and the second sample spatial feature to obtain a sample combined feature.
[0268] The matching processing module 1203 is further configured to perform matching processing on the sample combined feature based on the matching network to obtain a sample matching result.
[0269] The model training module 1207 is configured to train the text matching model based on the matching result of the first sample text data and the second sample text data and the sample matching result.
[0270] All the optional technical solutions described above can be combined to form optional embodiments of the present application, which will not be repeated here.
[0271] It should be noted that the text data processing apparatus provided in the above embodiments is only used for text data processing by way of example based on the division of the above functional modules. In actual applications, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the text data processing apparatus and the text data processing method provided in the above embodiments belong to the same concept, and the specific implementation process is described in the method embodiments, which will not be repeated here.
[0272] The embodiments of the present application also provide a computer device, which includes a processor and a memory. The memory stores at least one computer program, which is loaded and executed by the processor to implement the operations performed in the text data processing method of the above embodiments.
[0273] Optionally, the computer device is provided as a terminal. Figure 14 FIG. 1 is a structural schematic diagram of a terminal 1400 provided by the embodiments of the present application. The terminal 1400 can be a portable mobile terminal, such as a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a notebook computer or a desktop computer. The terminal 1400 can also be referred to as a user equipment, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0274] The terminal 1400 includes a processor 1401 and a memory 1402.
[0275] The processor 1401 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1401 can be implemented in at least one of a hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable-Gate-Array), a PLA (Programmable Logic Array). The processor 1401 can also include a main processor and a coprocessor, the main processor being a processor for processing data in an awake state, also known as a CPU (Central Processing Unit), and the coprocessor being a low-power processor for processing data in a standby state. In some embodiments, the processor 1401 can be integrated with a GPU (Graphics Processing Unit) for rendering and drawing content required to be displayed by the display screen. In some embodiments, the processor 1401 can further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
[0276] The memory 1402 can include one or more computer-readable storage media that can be non-transitory. The memory 1402 can also include a high-speed random access memory, and a nonvolatile memory such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1402 is used to store at least one computer program for being executed by the processor 1401 to implement the text data processing method provided by the method embodiments in the present application.
[0277] In some embodiments, the terminal 1400 can also optionally include a peripheral device interface 1403 and at least one peripheral device. The processor 1401, the memory 1402, and the peripheral device interface 1403 can be connected through a bus or a signal line. Each peripheral device can be connected to the peripheral device interface 1403 through a bus, a signal line, or a circuit board. Optionally, the peripheral device includes at least one of a radio frequency circuit 1404, a display screen 1405, and a camera assembly 1406.
[0278] The peripheral interface 1403 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 1401 and the memory 1402. In some embodiments, the processor 1401, the memory 1402 and the peripheral interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1401, the memory 1402 and the peripheral interface 1403 can be implemented on a separate chip or circuit board, and the present embodiments are not limited in this regard.
[0279] The radio frequency circuit 1404 is used to receive and send RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1404 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1404 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 1404 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 1404 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1404 can also include NFC (Near Field Communication) related circuitry, and the present application is not limited in this regard.
[0280] The display screen 1405 is configured to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 1405 is a touch display screen, the display screen 1405 is further configured to capture touch signals on or above the surface of the display screen 1405. The touch signals can be input to the processor 1401 as control signals for processing. In this case, the display screen 1405 can be further configured to provide virtual buttons and / or virtual keyboard, also known as soft buttons and / or soft keyboard. In some embodiments, the display screen 1405 can be one, disposed on the front panel of the terminal 1400; in other embodiments, the display screen 1405 can be at least two, respectively disposed on different surfaces of the terminal 1400 or in a folding design; in other embodiments, the display screen 1405 can be a flexible display screen, disposed on a curved surface or a folding surface of the terminal 1400. Even, the display screen 1405 can be disposed in an irregular shape other than a rectangle, i.e., a special-shaped screen. The display screen 1405 can be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0281] The camera assembly 1406 is configured to capture images or videos. Optionally, the camera assembly 1406 includes a front camera and a rear camera. The front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, the rear camera is at least two, which are any one of a main camera, a depth-of-field camera, a wide-angle camera, and a long-focus camera, to realize the background blur function of the main camera and the depth-of-field camera, the panoramic shooting and VR (Virtual Reality) shooting function of the main camera and the wide-angle camera, or other fusion shooting functions. In some embodiments, the camera assembly 1406 can further include a flash. The flash can be a single-color-temperature flash or a dual-color-temperature flash. The dual-color-temperature flash refers to the combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
[0282] Those skilled in the art can understand that the structure shown in FIG. 14 is not a limitation on the terminal 1400, and the terminal 1400 can include more or fewer components than those shown in the figure, or combine certain components, or use a different arrangement of components. Figure 14 The structure shown in FIG. 14 is not a limitation on the terminal 1400, and the terminal 1400 can include more or fewer components than those shown in the figure, or combine certain components, or use a different arrangement of components.
[0283] Optionally, the computer device is provided as a server. Figure 15is a structural schematic diagram of a server provided by an embodiment of the present application. The server 1500 can have great differences due to different configurations or performances, and can include one or more processors (Central Processing Units, CPUs) 1501 and one or more memories 1502. The memory 1502 stores at least one computer program, which is loaded and executed by the processor 1501 to implement the method provided by each of the above-mentioned method embodiments. Of course, the server can also have a wired or wireless network interface, a keyboard, an input and output interface, and other components for realizing the functions of the device, and the details are not described herein.
[0284] An embodiment of the present application further provides a computer readable storage medium, which stores at least one computer program. The at least one computer program is loaded and executed by a processor to implement the operations performed in the text data processing method of the above-mentioned embodiment.
[0285] An embodiment of the present application further provides a computer program product or a computer program, which includes computer program code stored in a computer readable storage medium. A processor of a computer device reads the computer program code from the computer readable storage medium, and the processor executes the computer program code, so that the computer device implements the operations performed in the text data processing method of the above-mentioned embodiment. In some embodiments, the computer program related to the embodiment of the present application can be deployed to be executed on one computer device, or on multiple computer devices located in one place, or on multiple computer devices distributed in multiple places and interconnected through a communication network, and the multiple computer devices distributed in multiple places and interconnected through a communication network can constitute a blockchain system.
[0286] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by a program instructing related hardware, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk.
[0287] The above is only an optional embodiment of the present application, and does not limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method of processing text data, characterized by, The method comprises: obtaining fusion semantic information and fusion spatial information based on first text data and second text data; obtaining first query features, first key features and first value features of first semantic features corresponding to the fusion semantic information; obtaining second query features, second key features and second value features corresponding to first spatial features corresponding to the fusion spatial information; obtaining second semantic features based on the second query features, the first key features and the first value features; obtaining second spatial features based on the first query features, the second key features and the second value features; combining the second semantic features and the second spatial features to obtain combined features; performing matching processing on the combined features to obtain a matching result, the matching result indicating whether the first text data and the second text data match; wherein the first text data and the second text data are any two text data identified from the same object, the fusion semantic information represents the semantics of the first text data and the second text data, and the fusion spatial information represents the positions of the first text data and the second text data in the object.
2. The method of claim 1, wherein, The method comprises: obtaining fusion semantic information and fusion spatial information based on first text data and second text data; obtaining first semantic information and first spatial information of the first text data, and second semantic information and second spatial information of the second text data; fusing the first semantic information and the second semantic information to obtain the fusion semantic information; 3. The method of claim 2, wherein, fusing the first spatial information and the second spatial information to obtain the fusion spatial information. The method comprises: adding vectors corresponding to each character in the first text data to obtain the first semantic information, and obtaining the first spatial information based on vertex coordinates of a text box in which the first text data is located in the object; 4. The method of claim 1, wherein, adding vectors corresponding to each character in the second text data to obtain the second semantic information, and obtaining the second spatial information based on vertex coordinates of a text box in which the second text data is located in the object. The method comprises: multiplying the first semantic features and a parameter matrix to obtain a semantic matrix, and obtaining the first query features, the first key features and the first value features based on the semantic matrix; The method comprises:
5. The method of claim 1, wherein, multiplying the first spatial features and the parameter matrix to obtain a spatial matrix, and obtaining the second query features, the second key features and the second value features based on the spatial matrix. The method comprises: normalizing a product of the second query feature, the first key feature and a scaling factor to obtain a first normalized feature; and determining a product of the first normalized feature and the first value feature as the second semantic feature; the method further comprises: normalizing a product of the first query feature, the second key feature and the scaling factor to obtain a second normalized feature; and determining a product of the second normalized feature and the second value feature as the second spatial feature.
6. The method of claim 1, wherein, the method further comprises: respectively dividing the first query feature, the first key feature and the first value feature into a plurality of first query sub-features, a plurality of first key sub-features and a plurality of first value sub-features; and respectively dividing the second query feature, the second key feature and the second value feature into a plurality of second query sub-features, a plurality of second key sub-features and a plurality of second value sub-features; the method further comprises: respectively obtaining a plurality of second semantic sub-features based on the plurality of second query sub-features, the plurality of first key sub-features and the plurality of first value sub-features, and splicing the plurality of second semantic sub-features to obtain the second semantic feature; the method further comprises: respectively obtaining a plurality of second spatial sub-features based on the plurality of first query sub-features, the plurality of second key sub-features and the plurality of second value sub-features, and splicing the plurality of second spatial sub-features to obtain the second spatial feature.
7. The method of claim 1, wherein, The text matching model comprises: a feature extraction network, a cross processing network and a matching network. The feature extraction network is configured to perform feature extraction on the fused semantic information and the fused spatial information respectively to obtain third semantic features and third spatial features. The cross processing network is configured to perform feature extraction on the third semantic features and the third spatial features respectively to obtain the first semantic features and the first spatial features, perform cross processing on the first semantic features and the first spatial features respectively to obtain the second semantic features and the second spatial features, and combine the second semantic features and the second spatial features to obtain the combined features. The matching network is configured to perform matching processing on the combined features to obtain the matching result.
8. The method of claim 7, wherein, The text matching model comprises a plurality of cross processing networks. The cross processing network is configured to perform feature extraction on the third semantic features and the third spatial features respectively to obtain the first semantic features and the first spatial features. The cross processing network is configured to perform cross processing on the first semantic features and the first spatial features respectively to obtain the second semantic features and the second spatial features. The cross processing network is configured to combine the second semantic features and the second spatial features to obtain the combined features, comprising: based on the first cross processing network, the third semantic feature and the third spatial feature are respectively subjected to feature extraction to obtain the first semantic feature and the first spatial feature; the first semantic feature and the first spatial feature are subjected to cross processing to respectively obtain a fourth semantic feature and a fourth spatial feature; based on the second cross processing network, the fourth semantic feature and the fourth spatial feature are respectively subjected to feature extraction and cross processing until the second semantic feature and the second spatial feature output by the last cross processing network are obtained; the second semantic feature and the second spatial feature are combined to obtain the combined feature.
9. The method according to claim 7 or 8, characterized in that, The method further comprises: based on the first sample text data and the second sample text data, sample fusion semantic information and sample fusion spatial information are obtained; based on the feature extraction network, the sample fusion semantic information and the sample fusion spatial information are respectively subjected to feature extraction to obtain a first sample semantic feature and a first sample spatial feature; based on the cross processing network, the first sample semantic feature and the first sample spatial feature are subjected to cross processing to respectively obtain a second sample semantic feature and a second sample spatial feature; the second sample semantic feature and the second sample spatial feature are combined to obtain a sample combined feature; based on the matching network, the sample combined feature is subjected to matching processing to obtain a sample matching result; based on the matching result of the first sample text data and the second sample text data, and the sample matching result, the text matching model is trained.
10. A text data processing apparatus characterized by comprising: The device comprises: an information acquisition module configured to obtain fusion semantic information and fusion spatial information based on first text data and second text data; a cross processing module configured to obtain a first query feature, a first key feature, and a first value feature of a first semantic feature corresponding to the fusion semantic information; obtain a second query feature, a second key feature, and a second value feature corresponding to a first spatial feature corresponding to the fusion spatial information; obtain a second semantic feature based on the second query feature, the first key feature, and the first value feature; obtain a second spatial feature based on the first query feature, the second key feature, and the second value feature; and combine the second semantic feature and the second spatial feature to obtain a combined feature; a matching processing module configured to perform matching processing on the combined feature to obtain a matching result, the matching result indicating whether the first text data and the second text data match; wherein the first text data and the second text data are any two text data identified from the same object, the fusion semantic information represents the semantics of the first text data and the second text data, and the fusion spatial information represents the positions of the first text data and the second text data in the object.
11. The apparatus of claim 10, wherein, The information acquisition module comprises: an information acquisition unit configured to obtain first semantic information and first spatial information of the first text data, and second semantic information and second spatial information of the second text data; The first fusion unit is configured to fuse the first semantic information and the second semantic information to obtain the fused semantic information. The second fusion unit is configured to fuse the first spatial information and the second spatial information to obtain the fused spatial information.
12. A computer device, comprising: The computer device comprises a processor and a memory, and the memory stores at least one computer program, which is loaded and executed by the processor to implement the operations performed in the text data processing method according to any one of claims 1 to 9.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores at least one computer program, which is loaded and executed by the processor to implement the operations performed in the text data processing method according to any one of claims 1 to 9.
14. A computer program product, characterised in that, The computer program product comprises computer program code stored in a computer readable storage medium, and the processor of the computer device reads the computer program code from the computer readable storage medium, and the processor executes the computer program code to implement the operations performed in the text data processing method according to any one of claims 1 to 9.