Text processing method, device, equipment and computer-readable storage medium
By recognizing and encoding the first type of word on the text, multiple pairs of upper and lower word pairs in the text are identified, and the problem of low recognition accuracy and efficiency of upper and lower word pairs in the prior art is solved, and the conditions in plain text are realized efficient identification under.
Patent Information
- Application Number
- CN202210033962.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-12
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-01-12
AI Technical Summary
The prior art has low accuracy and efficiency when identifying upper and lower word pairs in text, especially when dealing with multiple pairs of upper and lower word pairs, and it is impossible to effectively identify upper and lower word pairs in plain text.
By recognizing the first type of word, encoding process and decoding process of the upper and lower relationships of the text to be processed, the confidence of each word part and the first type of word is determined, thereby identifying the second type of word corresponding to the first type of word, forming multiple types of words Pair the upper and lower terms.
It realizes accurate identification of multiple pairs of upper and lower word pairs in text under plain text conditions, improves recognition efficiency and accuracy, and is suitable for many-to-many, one-to-many and many-to-one scenarios, reducing time complexity and additional overhead .
Smart Images

Figure CN116467405B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of Internet technology, and relate to but are not limited to a text processing method, apparatus, device, and computer-readable storage medium. Background Art
[0002] With the rapid development of Internet technology, the amount of information and data on the Internet has increased dramatically, which has increased the difficulty of information search. With the development of artificial intelligence technology, the accuracy of information search has become increasingly higher. When searching for information, in most scenarios, when a hypernym is input, the information of the subordinate entity word corresponding to the hypernym is retrieved, or when a subordinate entity word is input, the information of the hypernym corresponding to the subordinate entity word is retrieved. Therefore, it is necessary to obtain the correspondence between the hypernym and the subordinate entity word in advance, that is, it is necessary to determine the hypernym and hyponym pairs in advance.
[0003] In the related art, when determining hyponym and hyponym pairs, the following methods are usually adopted: a method based on predetermined rules, a method through template matching, a method using sequence labeling, or a method based on hyponym and hyponym relationship classification.
[0004] However, the methods in the related art cannot accurately identify hyponym and hyponym pairs when only plain text is input, and can only identify one pair of hyponym and hyponym pairs in the text each time. Therefore, the methods in the related art have low recognition accuracy and efficiency for hyponym and hyponym pairs. Summary of the invention
[0005] The embodiments of the present application provide a text processing method, apparatus, device and computer-readable storage medium, which are applied at least in the field of artificial intelligence technology, can accurately identify multiple pairs of hyponym and hyponym pairs in the text to be processed, and can improve the recognition efficiency of hyponym and hyponym pairs.
[0006] The technical solution of the embodiment of the present application is implemented as follows:
[0007] The present application provides a text processing method, the method comprising:
[0008] Performing first-type word recognition on the text to be processed to obtain at least one first-type word;
[0009] For each of the first-type words, encoding the first-type words and the text to be processed is performed to obtain a text word vector corresponding to the first-type words and the text to be processed; wherein the text to be processed includes at least two word segments;
[0010] Performing a hyponym-hypernym decoding process on the text word vector to obtain a confidence level that each of the at least two word segments has a hyponym-hypernym relationship with the first type of word;
[0011] Determining, according to the confidence, a second type word corresponding to each first type word from the at least two participles;
[0012] The first type of words are associated with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0013] The present application provides a text processing device, the device comprising:
[0014] A recognition module, used for performing first-type word recognition on the text to be processed to obtain at least one first-type word;
[0015] An encoding processing module, used for encoding each of the first type of words and the text to be processed to obtain a text word vector corresponding to the first type of words and the text to be processed; wherein the text to be processed includes at least two word segments;
[0016] A decoding processing module, used for performing a hyponym decoding process on the text word vector to obtain a confidence that each of the at least two participles has a hyponym relationship with the first type of word;
[0017] a determination module, configured to determine, from the at least two participles, a second type of word corresponding to each of the first type of words according to the confidence level;
[0018] The association module is used to associate the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0019] The present application provides a text processing device, including:
[0020] The memory is used to store executable instructions; the processor is used to implement the above-mentioned text processing method when executing the executable instructions stored in the memory.
[0021] An embodiment of the present application provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; wherein a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor is used to execute the computer instructions to implement the above-mentioned text processing method.
[0022] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute the executable instructions to implement the above-mentioned text processing method.
[0023] The embodiment of the present application has the following beneficial effects: when processing the text to be processed, the first type of words in the text to be processed are first identified, and then based on the first type of words, the first type of words and the text to be processed are sequentially encoded and decoded to obtain the confidence of each word segment in the text to be processed, and the second type of words that have a hypernym relationship with each first type of word are determined from at least two word segments based on the confidence, thereby forming at least one hypernym pair. In this way, since all the hypernym pairs in the text to be processed can be identified at the same time under the condition of only inputting the file to be processed, the efficiency of text recognition can be greatly improved, and since the encoding and the hypernym decoding are sequentially performed based on the first type of words identified first, the second type of words corresponding to the first type of words can be accurately identified, thereby accurately identifying multiple pairs of hypernyms in the text to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1A This is an interface diagram of mining hyponym and hyponym pairs based on rule-based concept hyponym mining method;
[0025] Figure 1B It is the process of identifying hyponym and hyponym pairs based on Bootstrapping template matching technology;
[0026] Figure 1C This is a schematic diagram of the extraction process of the hyponymy extraction method based on sequence annotation;
[0027] Figure 1D This is a schematic diagram of the classification process of the hyponymy classification method based on the pre-trained model BERT;
[0028] Figure 2 This is an optional architectural diagram of a text processing system provided in an embodiment of the present application;
[0029] Figure 3 is a structural schematic diagram of a text processing device provided in an embodiment of the present application;
[0030] Figure 4 This is an optional flowchart of the text processing method provided in the embodiment of the present application;
[0031] Figure 5 is another optional flowchart of the text processing method provided in the embodiment of the present application;
[0032] Figure 6 This is another optional flowchart of the text processing method provided in the embodiment of the present application;
[0033] Figure 7 This is a product interface diagram for search association word recommendation provided in an embodiment of the present application;
[0034] Figure 8 This is a product interface diagram generated by the conceptual candidate search box words provided in the embodiment of the present application;
[0035] Fig. 9 It is a schematic diagram of the question-answer matching process of the knowledge graph-based question-answering system provided in an embodiment of the present application;
[0036] Fig.10 is a flowchart of a text processing method implemented by a text processing system provided in an embodiment of the present application;
[0037] Fig.11 It is a schematic diagram of three scenarios provided in the embodiments of the present application;
[0038] Fig.12 It is a structural diagram of the MRC model provided in the embodiment of the present application;
[0039] Fig.13 It is a schematic diagram of the structure of the encoder of the MRC model provided in the embodiment of the present application;
[0040] Fig.14 It is a schematic diagram of a case predicted by the method of an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0042] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art of the technical field of the embodiments of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0043] Before describing the solution of the embodiment of the present application, the terms involved in the embodiment of the present application are first explained:
[0044] (1) Bidirectional Encoder Representations (BERT): A pre-trained language representation model that considers context from both sides of a word (left and right).
[0045] (2) Machine Reading Comprehension (MRC): a reading comprehension model in question-answering systems.
[0046] (3) Bootstrapping algorithm: It refers to generating semantic matching templates from large-scale corpus, that is, using limited sample data through repeated sampling to re-establish new samples that are sufficient to represent the distribution of the parent sample.
[0047] (4) Info Box: refers to the information box in the encyclopedia query page, which is used to record the attribute information of the entity corresponding to the encyclopedia page.
[0048] (5) Named Entity Recognition (NER): refers to identifying named entities with specific meanings from text, such as names of people, places, institutions, works, proper nouns, etc.
[0049] (6) BIO (Begin-Inside-Outside) annotation: It is a common annotation method in sequence annotation models. BIO annotation is to annotate each element as "BX", "IX" or "O", where "BX" means that the segment where this element is located belongs to type X and this element is at the beginning of this segment, "IX" means that the segment where this element is located belongs to type X and this element is in the middle of this segment, and "O" means that it does not belong to any type. For example, in NER, BIO annotates each word in the text sequence as the first word, internal word or non-entity (or concept) word of a certain entity (or concept).
[0050] (7) Hyponym: usually a named entity, such as a person, organization, place, work, etc.
[0051] (8) Hypernym: Usually a concept, i.e., an entity with more abstract semantics. A hypernym can refer to a class of named entities. For example, the concept “puzzle mobile games” can refer to various specific game names and other entities.
[0052] Before explaining the text processing method of the embodiment of the present application, the method in the related art is first described.
[0053] In the related art, when performing hyponym-hyponym pair recognition, the first method is a rule-based concept hyponym-hyponym relationship mining method. In this method, coarse-grained concepts are extracted through structured and semi-structured data such as open knowledge bases and encyclopedias such as Info Box. Figure 1AAs shown in the figure, it is an interface diagram of mining hyponym pairs based on the rule-based concept hyponym relationship mining method. In a certain encyclopedia query webpage, the "work" attribute in the info Box of the entry "Zhang San" entity can obtain the superordinate concepts corresponding to the subordinate entity "Zhang San": actor, singer, producer, lyricist, etc.
[0054] In the rule-based concept hyponym mining method, although the mining accuracy is high, it does not have generalization ability, and the extracted concepts are limited to specific Info Box attributes, such as the work and position corresponding to the person entity, and the category corresponding to the video entity. These ranges are relatively narrow. In addition, this method is completely dependent on existing encyclopedia data and cannot extract hyponym pairs outside of encyclopedia data. The recognition range of hyponym pairs is small.
[0055] The second method is to automatically mine concept phrases from texts using Bootstrapping-based template matching technology. In this method, Bootstrapping-based template matching technology is usually used to solve the problem of insufficient samples in machine learning. It uses limited samples through repeated sampling to establish new samples that are sufficient to represent the distribution of the parent sample. In concept hyponym extraction, the process is: use a small number of concept hyponym pairs as the initial seed sample set, then predict the template through some learning strategies, and then obtain more samples based on the predicted template annotation to expand the original seed sample set, and repeat this process iteratively. Figure 1B As shown in FIG. 1 , a hyponym pair recognition process based on the Bootstrapping template matching technology is performed. First, the input text 101 “Everyone knows LL, he is a famous pianist” is aligned 102, and then the text 101 is template matched based on the Bootstrapping template 103 to obtain sample words 104 such as “LL”, “is a”, and “famous pianist”; then, the obtained sample words are annotated by regular expressions and predefined dictionaries to obtain the final annotated words, and the annotated words are expanded into the template 103 as expanded samples.
[0056] Although the Bootstrapping-based template matching technology has more generalization ability than the rule-based method and can efficiently and quickly mine the matching templates of concept hyponym pairs from large-scale predictions, since this method is highly dependent on the initial seed sample set, the accuracy is not very high and the generalization ability is also very limited.
[0057] The third method is a method for extracting hyponyms based on sequence labeling. Since hyponyms are named entity recognition, a common and mature method for named entity extraction is sequence labeling. Therefore, while extracting entities through sequence labeling, the hypernyms corresponding to the entity can also be labeled. Sequence labeling uses the BIO method to label each word in the text as the first word, internal word, and non-entity (or concept) word of a certain entity or concept. This method uses two sequence taggers to label the entities and concepts in the text respectively, and finally the extracted hyponym pairs can be obtained. Figure 1C As shown, for the input text 105 "Crossing YLJ is a red drama broadcast by Country X TV from January 1, 2020", entities are extracted through sequence labeling, and the hypernyms corresponding to the entities are labeled, and a pair of hyponyms "Crossing YLJ" and "red drama" can be labeled.
[0058] In the method of extracting hyponymy based on sequence annotation, this method uses a neural network and a sequence annotation method to jointly extract concept hyponym pairs in the text, which has a certain generalization ability and accuracy. However, since there may be multiple hyponym pairs of "entity-concept" in the input text, this method cannot solve the problem of identifying such samples.
[0059] The fourth method is a classification method based on the pre-trained model BERT. This method assumes that the entities and concepts in the text have been identified, and uses the pre-trained language model BERT to train the classification model to determine whether the entities and concepts satisfy the hierarchical relationship. Figure 1D As shown, the BERT model 106 judges the hierarchical relationship of the input concept word "dessert" and the entity word "cream chestnut powder" based on the text 107 "cream chestnut powder is a kind of dessert", and obtains the model output result 108. According to the model output result 108, it is determined that "dessert" and "cream chestnut powder" have a hierarchical relationship.
[0060] In the hyponym classification method based on the pre-trained model BERT, this method uses the information contained in the pre-trained language model to classify whether there is a conceptual relationship based on given entities, concepts and corresponding texts. It can decompose complex extraction problems into simple binary classification problems, making the model easier to learn. At the same time, it uses large-scale expected pre-training knowledge and has strong performance. However, for all potential entity-concept pairs, this method needs to construct such a sample, which results in a very high time cost. In addition, this method must extract entities and concepts in advance, which cannot be implemented in real scenarios where only plain text is given.
[0061] Based on the above methods and problems in the related art, the embodiment of the present application provides a text processing method, which provides a system for automatically extracting hyponym pairs from plain text. Compared with other methods in the industry, the system can quickly extract hyponym pairs in the text, has better generalization ability, and can cover a wider range of business scenarios. The main contributions are as follows: (1) Effectively utilize the knowledge in the pre-trained language model to directly extract subordinate entities and their corresponding superordinate concepts from plain text; (2) Solve the problem that there may be multiple hyponym pairs in the text; (3) Under the condition that the accuracy and recall rate are guaranteed, the time complexity and additional overhead are lower than those of the methods in the related art; (4) Support three major business scenarios: many-to-many scenario (extracting hyponym pairs from plain text), one-to-many scenario (extracting superordinate concepts in text given subordinate entities and text) and many-to-one scenario (extracting subordinate entities in text given superordinate concepts and text); (5) Can serve at least three possible applications: query understanding search association word recommendation, search box word recommendation and knowledge graph-based question-answering system.
[0062] In the text processing method provided by the embodiment of the present application, first, the first type of word recognition is performed on the text to be processed to obtain at least one first type of word; then, for each first type of word, the first type of word and the text to be processed are encoded to obtain a text word vector corresponding to the first type of word and the text to be processed; wherein the text to be processed includes at least two participles; the text word vector is decoded with a hyponym relationship to obtain a confidence that each participle of at least two participles has a hyponym relationship with the first type of word; then, according to the confidence, a second type of word corresponding to each first type of word is determined from at least two participles; finally, the first type of word is associated with the second type of word to obtain at least one hyponym pair corresponding to the text to be processed. In this way, since all hyponym pairs in the text to be processed can be simultaneously identified under the condition that only the file to be processed is input, the efficiency of text recognition can be greatly improved, and since the encoding process and the hyponym decoding process are performed in sequence based on the first type of word identified first, the second type of word corresponding to the first type of word can be accurately identified, so that multiple pairs of hyponym pairs in the text to be processed can be accurately identified.
[0063] The following describes an exemplary application of the text processing device of the embodiment of the present application. The text processing device provided by the embodiment of the present application can be implemented as a terminal or a server. In one implementation, the text processing device provided by the embodiment of the present application can be implemented as a laptop, a tablet computer, a desktop computer, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device), an intelligent robot, a smart home appliance, a smart speaker, a smart watch, and a vehicle-mounted terminal, etc., any terminal with a retrieval function and a text processing function; in another implementation, the text processing device provided by the embodiment of the present application can also be implemented as a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms. The terminal and the server can be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiment of the present application. Below, an exemplary application of the text processing device when it is implemented as a server will be described.
[0064] See also Figure 2 , Figure 2It is an optional architecture diagram of the text processing system 10 provided in the embodiment of the present application. In order to support a text processing application and respond to the user's information search request through the text processing application, the text to be processed can be identified, at least one hyponym pair in the text to be processed can be identified, and the user's information search request can be responded to based on the hyponym pair. In the embodiment of the present application, the text processing system 10 includes at least a terminal 100, a network 200 and a server 300, wherein the server 300 constitutes the text processing device of the embodiment of the present application. Among them, the terminal 100 is connected to the server 300 through the network 200, and the network 200 can be a wide area network or a local area network, or a combination of the two. At least one text processing application is installed on the terminal 100. The text processing application can be any information search application, question-and-answer matching application, shopping application, or any other application that requires information search or information matching. The server 300 can obtain the text to be processed sent by the terminal 100 through the network 200; and perform first-type word recognition on the text to be processed to obtain at least one first-type word; for each first-type word, encode the first-type word and the text to be processed to obtain a text word vector corresponding to the first-type word and the text to be processed; wherein the text to be processed includes at least two participles; and, perform hyponym-hypernym decoding on the text word vector to obtain a confidence that each participle of the at least two participles has a hyponym-hypernym relationship with the first-type word; according to the confidence, determine a second-type word corresponding to each first-type word from the at least two participles; associate the first-type word with the second-type word to obtain at least one hyponym-hypernym pair corresponding to the text to be processed. After obtaining the hyponym and hyponym pairs, the server 300 may construct an information database based on the obtained hyponym and hyponym pairs, or may send the hyponym and hyponym pairs to the terminal 100 through the network 200, and the terminal may construct the information database.
[0065] In some embodiments, when the text processing device is implemented as a terminal, the terminal can obtain the text to be processed input by the user through the terminal, and use the text processing method provided in the embodiment of the present application to recognize the text to be processed, identify the hyponym and hyponym pairs in the text to be processed, build an information database based on the recognized hyponym and hyponym pairs, or respond to the user's information search request based on the recognized hyponym and hyponym pairs.
[0066] The text processing method provided in the embodiment of the present application can also be based on a cloud platform and implemented through cloud technology. For example, the above-mentioned server 300 can be a cloud server, and the first type of words are identified for the text to be processed through the cloud server, and the second type of words corresponding to each first type of words are determined through the cloud server. In some embodiments, there can also be a cloud storage device, and the identified hyponym and hyponym pairs can be stored in the cloud storage device, or the text to be processed and the identified hyponym and hyponym pairs can be mapped and stored in the cloud storage device. In this way, when responding to the user's information search request later, the hyponym and hyponym pairs can be directly obtained from the cloud storage device, so that the user's information search request can be responded to quickly and accurately.
[0067] It should be noted here that cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0068] Figure 3 is a structural diagram of a text processing device provided in an embodiment of the present application, Figure 3 The text processing device shown includes: at least one processor 310, a memory 350, at least one network interface 320 and a user interface 330. The various components in the text processing device are coupled together via a bus system 340. It is understood that the bus system 340 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 340 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 340 is not described in detail. Figure 3 Various buses are labeled as bus system 340 .
[0069] The processor 310 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0070] The user interface 330 includes one or more output devices 331 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 330 also includes one or more input devices 332, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0071] The memory 350 may be removable, non-removable or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drive, optical disk drive, etc. The memory 350 may optionally include one or more storage devices physically away from the processor 310. The memory 350 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 350 described in the embodiment of the present application is intended to include any suitable type of memory. In some embodiments, the memory 350 can store data to support various operations, and examples of these data include programs, modules, and data structures or subsets or supersets thereof, as exemplarily described below.
[0072] Operating system 351, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0073] A network communication module 352, for reaching other computing devices via one or more (wired or wireless) network interfaces 320, exemplary network interfaces 320 include: Bluetooth, Wireless Compatibility Authentication (WiFi), and Universal Serial Bus (USB);
[0074] The input processing module 353 is used to detect one or more user inputs or interactions from one of the one or more input devices 332 and translate the detected inputs or interactions.
[0075] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 3A text processing device 354 stored in the memory 350 is shown. The text processing device 354 may be a text processing device in a text processing device, which may be software in the form of a program or a plug-in, and includes the following software modules: an identification module 3541, an encoding processing module 3542, a decoding processing module 3543, a determination module 3544, and an association module 3545. These modules are logical, and therefore may be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.
[0076] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the text processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0077] The text processing method provided in the embodiment of the present application will be described below in conjunction with the exemplary application and implementation of the text processing device provided in the embodiment of the present application, wherein the text processing device can be any terminal with retrieval function and text processing function, or it can also be a server, that is, the text processing method of the embodiment of the present application can be executed by the terminal, it can also be executed by the server, or it can also be executed by the interaction between the terminal and the server.
[0078] See also Figure 4 , Figure 4 This is an optional flow chart of the text processing method provided in the embodiment of the present application. Figure 4 The steps shown are explained, and it should be noted that Figure 4 The text processing method in is implemented by using the terminal as the execution subject.
[0079] Step S401, performing first type word recognition on the text to be processed to obtain at least one first type word.
[0080] In the embodiment of the present application, the text to be processed can be input by the user through a text processing application, can be downloaded from the Internet, or can be obtained from a text library. The user can also input other types of information, such as voice information, picture information, and video information, and then obtain the text to be processed by performing voice recognition on the voice information, or obtain the text to be processed by performing recognition on the picture information and video information through image recognition or text recognition technology.
[0081] The text processing application can be an application dedicated to identifying hyponym and hyponym pairs, or it can be any application that needs to perform information search or information matching, such as an information search application, a question-and-answer matching application, a shopping application, etc. When the text processing application is an application dedicated to identifying hyponym and hyponym pairs, the text processing application is used to identify the hyponym and hyponym pairs, and output the identified hyponym and hyponym pairs to a specific application, or generate an information library based on the identified hyponym and hyponym pairs, and provide the information library to other applications. When the text processing application is an application that needs to perform information search or information matching, before performing information search or information matching, the server of the text processing application can pre-process the text to be processed using the text processing method of the embodiment of the present application to obtain at least one hyponym and hyponym pair, thereby constructing an information library based on the hyponym and hyponym pairs, so that when the text processing application subsequently receives a user's information search request, it can perform information matching based on the pre-constructed information library, and achieve accurate and rapid response to the user's information search request.
[0082] In some embodiments, the pre-built information database can also be expanded after responding to the user's information search request. That is, based on the pre-built information database, the text in the information search request can be determined as the text to be processed, and the text to be processed can be further identified to obtain hyponym and hyponym pairs, and then the hyponym and hyponym pairs can be expanded to the pre-built information database.
[0083] In the embodiment of the present application, the first type of word recognition for the processed text can be to identify the subordinate entity words in the processed text, or to identify the hypernymous concept words in the processed text. Since the recognition of subordinate entity words is usually named entity recognition, the method of sequence annotation can be used to identify the subordinate entity words in the processed text. In the embodiment of the present application, the sequence annotation can adopt the BIO method to mark each word in the processed text as the first word, internal word and non-entity word of a certain entity. Alternatively, the hypernymous concept words in the processed text can also be marked in the form of sequence annotation, that is, the BIO method can be adopted to mark each word in the processed text as the first word, internal word and non-concept word of a certain concept. In the embodiment of the present application, when the first type of word recognition for the processed text is to identify the entity words in the processed text, the first type of word obtained is the subordinate entity word; when the first type of word recognition for the processed text is to identify the concept words in the processed text, the first type of word obtained is the hypernymous concept word.
[0084] In some embodiments, when identifying the first type of words, the identification can be performed through a pre-trained text recognition model, and the model parameters in the text recognition model are model parameters for identifying subordinate entity words or model parameters for identifying superordinate concept words, and the model parameters can also include pre-set constraints. The constraints here are conditions for constraining the type of entity words or the type of concept words. For example, words such as names of people, places, institutions, works, and proper nouns can be constrained to be subordinate entity words. In this way, when the text recognition model is used for identification, the names of people, places, institutions, works, and proper nouns in the text to be processed can be identified as subordinate entity words.
[0085] Step S402, for each first type word, encode the first type word and the text to be processed to obtain a text word vector corresponding to the first type word and the text to be processed; wherein the text to be processed includes at least two word segments.
[0086] Here, encoding processing refers to performing word vectorization processing on the first type of words and the text to be processed, converting the first type of words and the text to be processed into word vector representations, and obtaining text word vectors of the first type of words and the text to be processed. The text word vector includes the first word vector corresponding to the first type of words and the text vector corresponding to the text to be processed, and the text word vector is a word vector representation used to simultaneously represent the first type of words and the text to be processed.
[0087] In one implementation, when encoding the first type of words, each character in the first type of words may be encoded to obtain a first word vector corresponding to the first type of words; when encoding the text to be processed, each character in each word segment of the text to be processed may be encoded to obtain a text vector corresponding to the text to be processed.
[0088] In another implementation, when encoding the first type of words, the first type of words may be encoded as a whole to obtain a first word vector corresponding to the first type of words; when encoding the text to be processed, each word segment of the text to be processed may be encoded to obtain a second word vector for each word segment, and then the corresponding multiple second word vectors may be concatenated according to the order of the multiple word segments in the text to be processed to form a text vector of the text to be processed.
[0089] In some text processing scenarios, a hypernym word may be a hypernym phrase, which may be composed of multiple words (i.e., a text fragment). Therefore, in an embodiment of the present application, the at least two word segments included in the text to be processed may be at least two words, or at least two phrases, or a part of a word and a part of a phrase.
[0090] Step S403, performing hyponym-hypernym decoding processing on the text word vector to obtain the confidence that each of the at least two word segments has a hyponym-hypernym relationship with the first type of word.
[0091] Here, the decoding process of the hierarchical relationship refers to decoding and calculating the text word vectors of the first type of words and the text to be processed, and obtaining the confidence that each word segment in the text to be processed has a hierarchical relationship with the first type of words. Among them, the confidence can be any real number with a value between 0 and 1. When the confidence value is higher, the probability that the corresponding word segment has a hierarchical relationship with the first type of words is greater. When the confidence value is lower, the probability that the corresponding word segment has a hierarchical relationship with the first type of words is smaller. In the embodiment of the present application, the confidence that each word segment has a hierarchical relationship with the first type of words can be calculated.
[0092] In an embodiment of the present application, when the identified first type of word is a lower-level entity word, the confidence calculated by decoding is the confidence of the corresponding participle as a higher-level concept word of the first type of word; when the identified first type of word is a higher-level concept word, the confidence calculated by decoding is the confidence of the corresponding participle as a lower-level entity word of the first type of word.
[0093] In some embodiments, when performing the decoding process of the hyponymy relationship, a pre-trained model can also be used to implement it. For example, a pre-trained MRC model can be used to determine the hyponymy relationship, and the first type of words and the text to be processed are used as inputs of the MRC model. The hyponymy relationship decoding process is performed through the MRC model to obtain the confidence that each of the at least two participles has a hyponymy relationship with the first type of words. In other words, the loss function of the MRC model can be used to judge each participle that has a hyponymy relationship with the input first type of words and the text to be processed.
[0094] Step S404: Determine, based on the confidence level, a second type word corresponding to each first type word from at least two participles.
[0095] In the embodiment of the present application, the word segmentation greater than the threshold can be determined as a second type of word corresponding to the first type of word according to the size of the confidence. It should be noted that the threshold can be determined according to the model parameters of the MRC model, or it can be manually set according to the training results of the model. For example, the threshold can be set to 0.8, then when the confidence of any word segmentation is greater than 0.8, it is determined that the word segmentation is a second type of word corresponding to the first type of word.
[0096] Step S405: Associating the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0097] Here, the first type of words and the second type of words can be stored in association, that is, the mapping relationship between the superordinate concept words and the subordinate entity words can be determined. In this way, when the second type of words are subsequently queried based on the first type of words, or the first type of words are queried based on the second type of words, the corresponding words can be quickly queried based on the mapping relationship.
[0098] The text processing method provided in the embodiment of the present application, when processing the text to be processed, first identifies the first type of words in the text to be processed, and then based on the first type of words, sequentially performs encoding processing and hyponym decoding processing on the first type of words and the text to be processed, obtains the confidence of each word segment in the text to be processed, and determines the second type of words that have a hyponym relationship with each first type of word from at least two word segments based on the confidence, thereby forming at least one hyponym pair. In this way, since all the hyponym pairs in the text to be processed can be simultaneously identified under the condition of only inputting the file to be processed, the efficiency of text recognition can be greatly improved, and since encoding processing and hyponym decoding processing are sequentially performed based on the first type of words identified first, the second type of words corresponding to the first type of words can be accurately identified, thereby accurately identifying multiple hyponym pairs in the text to be processed.
[0099] Figure 5 is another optional flow chart of the text processing method provided in the embodiment of the present application, such as Figure 5 As shown, the method comprises the following steps:
[0100] Step S501: the terminal collects the text to be processed and generates a text processing request according to the text to be processed.
[0101] In an embodiment of the present application, the text input by the user can be collected to obtain the text to be processed, or the collected voice can be subjected to voice recognition to obtain the text to be processed, or the collected image or video can be recognized to obtain the text to be processed.
[0102] In some embodiments, the user may operate on the client of the text processing application to generate a text processing request. For example, the user may input the text to be processed and trigger a request button to generate a text processing request including the text to be processed.
[0103] Step S502: The terminal sends a text processing request to the server.
[0104] Here, the server refers to the server of the text processing application. The server can be a local server, a cloud server, or a server cluster composed of multiple physical servers or a server in a distributed system.
[0105] Step S503: the server performs first-type word recognition on the text to be processed to obtain at least one first-type word.
[0106] In step S504, the server performs feature extraction on each first-type word through an encoder to obtain a first word vector corresponding to the first-type word.
[0107] Here, the Chinese BERT model (Chinese-BERT-wwm) based on the whole word masking technology can be used as an encoder to extract features of the first type of words and obtain the first word vector corresponding to the first type of words.
[0108] Step S505: the server performs word segmentation on the text to be processed to obtain at least two word segments.
[0109] In an embodiment of the present application, when performing word segmentation processing on the text to be processed, word segmentation processing can be performed in units of characters to obtain at least two characters, with each character serving as a word segmentation. Word segmentation processing can also be performed in units of words to obtain at least two word segments.
[0110] Step S506: The server performs feature extraction on each word segment through an encoder to obtain a second word vector corresponding to each word segment; wherein all second word vectors corresponding to at least two word segments constitute a text vector of the text to be processed, and the first word vector and the text vector constitute a text word vector.
[0111] Here, Chinese-BERT-wwm can also be used as an encoder to extract features for each word segment and obtain a second word vector corresponding to each word segment.
[0112] Step S507: The server performs a hyponym-hypernym decoding process on the text word vector to obtain a confidence level that each of the at least two word segments has a hyponym-hypernym relationship with the first type of word.
[0113] In some embodiments, step S507 may be implemented by the following steps:
[0114] Step S5071, through the linear layer in the decoder, based on the first word vector, the second vector corresponding to each word segment is mapped into two categories to obtain the binary classification result of the second word vector of each word segment.
[0115] In the embodiment of the present application, when the first type of words are lower-level entity words, the second type of words are higher-level concept words; when the first type of words are higher-level concept words, the second type of words are lower-level entity words.
[0116] The binary classification result is used to characterize that the segmented word belongs to a part of the hypernym word of the first type of word, or the binary classification result is used to characterize that the segmented word belongs to a part of the hyponym word of the first type of word.
[0117] In step S5072, the server decodes the binary classification result to obtain the confidence that each of the at least two segmented words has a hyponymous relationship with the first type of word.
[0118] In one implementation, some segmented words in the to-be-processed text may be directly determined as second-type words according to the confidence level. That is, the second-type words may be determined by the following steps:
[0119] Step S508: The server determines the word segments with a confidence level greater than a confidence level threshold as second-type words.
[0120] In another implementation, a plurality of consecutive word segments in the text to be processed may be determined as a second type of word according to the confidence level, that is, a text segment or a phrase in the text to be processed may be determined as a second type of word. Therefore, the second type of word may be determined by the following steps:
[0121] Step S509: When multiple word segments whose confidences are greater than the confidence threshold are located continuously in the text to be processed, the server determines the text segments corresponding to the multiple continuous word segments as second-type words.
[0122] Typically, hypernymous concept words are mostly presented in the form of text fragments or phrases. Therefore, when the embodiment of the present application determines that the text fragment is a second-type word, the second-type word may be a hypernymous concept word, and correspondingly, the first-type word is a subordinate entity word.
[0123] In step S510, the server associates the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0124] Step S511: the server sends at least one identified hyponym and hyponym pair to the terminal.
[0125] The text processing method provided in the embodiment of the present application encodes the first type of words and the text to be processed through a specific encoder, and decodes the text word vectors in terms of hyponymy and hyponymy through a specific decoder, thereby obtaining the confidence that each word segment has a hyponymy relationship with the first type of words, and based on the confidence, adopts different methods to determine the word segment as the second type of word or the text fragment as the second type of word, which can achieve accurate determination of different types of second type words, achieve comprehensive and complete recognition of hyponymy and hyponymy pairs in the text to be processed, and improve the universality of the text processing method.
[0126] Figure 6 is another optional flow chart of the text processing method provided in the embodiment of the present application, such as Figure 6 As shown, the method comprises the following steps:
[0127] Step S601: the terminal collects the text to be processed and generates a text processing request according to the text to be processed.
[0128] Step S602: The terminal sends a text processing request to the server.
[0129] Step S603: the server performs first-type word recognition on the text to be processed to obtain at least one first-type word.
[0130] Step S604: For each first-type word, the server concatenates the first-type word with the text to be processed to form a concatenated text.
[0131] Here, the text to be processed may be concatenated after the first type of words to form a concatenated text.
[0132] Step S605: The server inputs the concatenated text into a pre-trained MRC model.
[0133] Step S606, encoding the concatenated text through the encoding module of the MRC model to obtain text word vectors corresponding to the first type of words and the text to be processed.
[0134] In the embodiment of the present application, the MRC model is trained by using sample words generated by a sample word generation method based on full word masking, that is, when training the MRC model, the sample words can be first generated by a sample word generation method based on full word masking, and then the MRC model is trained by using the sample words. It should be noted that the sample word generation method based on full word masking means that when generating training samples, if a partial word (WordPiece) subword of a complete word is masked (masked), then other parts belonging to the word will also be masked, that is, full word masking. It should be noted that the masking here refers to masking in a broad sense, that is, masking can be performed in any of the following ways: replacing the word to be masked with a [MASK] mark, keeping the original vocabulary, and randomly replacing the word to be masked with another word, and is not limited to the case where a word is replaced with a [MASK] label.
[0135] In some embodiments, the MRC model includes a first decoding module, the first decoding module corresponds to a first decoding parameter, and the first decoding parameter is a parameter for determining the confidence that each word segment has a hyponymous relationship with the first type of word; correspondingly, the method further includes:
[0136] Step S607, using a first decoding module, based on a first decoding parameter obtained in advance through training, performs a hyponym decoding process on the text word vector to obtain a confidence level that each of the at least two word segments has a hyponym relationship with the first type of word.
[0137] Step S608: The server determines a second type word corresponding to each first type word from at least two word segments according to the confidence level.
[0138] In some embodiments, the MRC model includes a second decoding module, the second decoding module corresponds to a second decoding parameter, and the second decoding parameter is a parameter for determining the starting confidence of each participle as the starting position of the second type of word and the ending confidence of each participle as the ending position of the second type of word; correspondingly, the method also includes:
[0139] Step S609, through the second decoding module, based on the second decoding parameters obtained in advance, the text word vector is decoded based on the hyponym relationship, and the starting confidence of each of the at least two word segments as the starting position of the second type of word and the ending confidence of each word as the ending position of the second type of word are obtained.
[0140] Step S610: The server determines a second type of word from at least two word segments according to the start confidence and the end confidence.
[0141] In some embodiments, step S610 may be implemented by the following steps:
[0142] Step S6101: determine the word segmentation whose start confidence is greater than the first threshold as the start word.
[0143] In the embodiment of the present application, at least one starting word can be determined from the text to be processed.
[0144] Step S6102: Determine the word segmentation whose ending confidence is greater than the second threshold as the ending word.
[0145] In the embodiment of the present application, at least one ending word can be determined from the text to be processed.
[0146] Step S6103: From among all the start words and all the end words, determine the target start words and target end words whose positions are adjacent and whose start words are located before the end words.
[0147] Here, adjacent start words and end words form a word pair, and a word pair only includes one start word and one end word, and the position of the start word in the text to be processed is located before the position of the end word in the text to be processed. The start word in each word pair is the target start word, and the end word is the target end word. There are no other start words and other end words between the target start word and the target end word.
[0148] Step S6104: In the text to be processed, the text segment between the target start word and the target end word is determined as a second type of word.
[0149] In the embodiment of the present application, since there are no other starting words and other ending words between the target starting word and the target ending word, a text segment between a pair of target starting words and target ending words constitutes a superordinate concept word or a subordinate entity word of the first type of word.
[0150] In step S611, the server associates the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0151] Step S612: The server sends the at least one identified hyponym and hyponym pair to the terminal.
[0152] The text processing method provided in the embodiment of the present application uses different decoding modules in the MRC model to perform different decoding processing on the text word vectors. Therefore, it is possible to recognize different types of hyponym and hyponym pairs, and respectively recognize word hyponym and hyponym pairs and phrase hyponym and hyponym pairs in the text to be processed, thereby achieving comprehensive and accurate recognition of the text to be processed.
[0153] In some embodiments, after identifying the text to be processed to obtain at least one hyponym pair, the method may further include:
[0154] Step S11, constructing an information database using hyponym pairs.
[0155] Here, when there is no pre-constructed information base, when at least one hyponym and hyponym pair is obtained, the information base can be constructed and the hyponym and hyponym pairs can be stored in the information base; when there is an existing information base, constructing the information base can be to update the information base. In the embodiment of the present application, updating the information base can be based on the currently identified hyponym and hyponym pairs, judging the hyponym and hyponym pairs already stored in the information base, when the currently identified hyponym and hyponym pair does not have the same hyponym and hyponym pair in the information base, that is, when the currently identified hyponym and hyponym pair is a new word pair, the hyponym and hyponym pair is stored in the information base; when the currently identified hyponym and hyponym pair has the same hyponym and hyponym pair in the information base, that is, when the currently identified hyponym and hyponym pair is an existing word pair, the information base is not updated.
[0156] Step S12, constructing a concept map of the target domain based on the hyponym and hyponym pairs in the information database.
[0157] In an embodiment of the present application, domain division can be performed on the hyponym pairs according to the contents of the superordinate concept words or subordinate entity words in the hyponym pairs to determine the target domain to which the hyponym pairs belong. Alternatively, text domain identification can be performed based on the text to be processed to obtain the domain corresponding to the text to be processed, and the domain corresponding to the text to be processed can be determined as the target domain to which the identified hyponym pairs belong.
[0158] The concept map can be a map formed based on hypernymous concept words and hyponymous entity words. The concept map includes multiple nodes, and each two nodes are connected by a connecting line, which represents the hypernymous relationship between the two connected nodes. Each node corresponds to a word, and of the two nodes connected by each connecting line, one node corresponds to a hypernymous concept word, and the other node corresponds to a hyponymous entity word. This pair of hypernymous concept words and hyponymous entity words constitutes a hypernymous word pair.
[0159] In some embodiments, based on the continuous accumulation of hyponym and hyponym pairs, the concept map can be dynamically updated continuously, that is, the concept map is updated according to the new hyponym and hyponym pairs identified. In the embodiment of the present application, the constructed information base can be obtained, and the concept map of the target field can be constructed according to the hyponym and hyponym pairs in the information base. Therefore, when it is detected that the information base is updated, the concept map can be dynamically updated according to the hyponym and hyponym pairs updated in the information base.
[0160] Step S13, responding to the received information search request based on the concept map to obtain a response result.
[0161] Here, the information search request may be a search request issued through any search application, for example, an information search request input through search software, a product search request input through shopping software, a disease inquiry request input through an inquiry application, etc.
[0162] In one implementation, the concept graph of the embodiment of the present application can be independently constructed by the search application, that is, the search application can use the text processing method of the embodiment of the present application to identify the hyponym and hyponym pairs, and then construct a concept graph based on the hyponym and hyponym pairs, or the search application can request to obtain multiple hyponym and hyponym pairs identified by the text processing application, and then construct a concept graph based on the hyponym and hyponym pairs. In another implementation, the concept graph of the embodiment of the present application can also be constructed by other text processing applications. When responding to an information search request, the search application can request to obtain the concept graph constructed by other text processing applications for use.
[0163] The embodiments of the present application can be applied to at least any of the following scenarios:
[0164] Scenario 1: Recommendation of search association words when understanding input questions. For example, after at least one hyponym pair is identified using the method of an embodiment of the present application, an information base can be constructed based on the hyponym pair, and a plurality of hyponym pairs are stored in the information base. When a user performs a question search query through a search application, after inputting a partial question, text recognition and understanding can be performed on the partial question input by the user, and the entity words in the partial question input by the user can be determined, and the corresponding concept words can be matched from the information base based on the entity words, or the concept words in the partial question input by the user can be determined, and the corresponding entity words can be matched from the information base based on the concept words; then, a complete question can be generated based on the concept words, or based on the entity words, or based on the entity words and the concept words, that is, the association words are obtained, and the complete question is generated based on the association words.
[0165] Scenario 2: Generation of conceptual candidate search box words. For example, in any search application, multiple actionable items can be provided on the search interface. When a user clicks on any actionable item, multiple entity contents corresponding to the actionable item can be displayed or obtained as the selection result of the user operation, and the user operation is responded to. In this scenario, it is also possible to construct an information library based on the hyponym and hyponym pairs identified by the method of the embodiment of the present application. When generating multiple entity contents corresponding to each operability, it can be implemented based on the constructed information library, that is, the actionable item can be a conceptual word of the hyponym and hyponym pairs in the information library. After the conceptual word is determined, at least one entity word corresponding to each conceptual word can be pulled from the information library, and then the information corresponding to the pulled entity word is used as the content under the actionable item corresponding to the conceptual word.
[0166] Scenario three: Question-answering system based on knowledge graph. For example, after at least one hyponym and hyponym pair is identified using the method of an embodiment of the present application, an information base can be constructed based on the hyponym and hyponym pairs, and a plurality of hyponym and hyponym pairs are stored in the information base. A concept graph can be constructed based on the hyponym and hyponym pairs in the information base, wherein in the concept graph, the hypernym concept words and the subordinate entity words serve as nodes in the concept graph, and the connection between the concept words and the entity words represents the relationship between the concept words and the entity words, so that there is a hypernym concept word connected to a plurality of subordinate entity words. In the question-answering system, the user's questions can be answered based on the concept graph, that is, the answers to the user's questions can be generated from the concept graph based on the relationship between the concept words and the entity words.
[0167] The following is an example application of the embodiment of the present application in an actual application scenario. The embodiment of the present application provides a text processing method. Since the task faced in text processing is actually a relationship extraction task in a broad sense, the relationship extraction model can be reused and applied to this task. However, since the general relationship extraction model has the following limitations, it is considered to use the characteristics of the concept extraction task and design a corresponding model to realize the recognition of the text to be processed:
[0168] 1) In the relationship extraction task, the relationship between entities is extracted. The extracted head entity and tail entity are homogeneous (that is, they are both specific entities), while in the concept extraction task (that is, extracting hyponym pairs consisting of concepts and entities), entities and concepts are heterogeneous (that is, one is a specific entity and the other is a general concept). Entities are specific while concepts are abstract and general, so it is necessary to distinguish the difference between the two to design a customized extraction paradigm; 2) In the concept extraction task, only the relationship between entities and concepts needs to be considered, without considering the relationship between concepts and concepts, or between entities and entities. Reusing the relationship extraction model will inevitably extract these two types of relationships (that is, the relationship between concepts and concepts, or between entities and entities). Therefore, when designing the model, it is necessary to consider a more reasonable extraction method, such as using the method of "first extracting the entity, and then extracting the superordinate concept corresponding to the entity" proposed in the embodiment of the present application.
[0169] The text processing method proposed in the embodiment of the present application can solve the following problems at the same time: 1) The knowledge of the pre-trained language model BERT can be used to jointly extract hyponym pairs in the text; 2) The problem of multiple hyponym pairs in the text can be solved; 3) Compared with the relationship classification method based on the pre-trained model BERT, the embodiment of the present application has a lower time cost and does not require the extraction of entities and concepts in advance. All hyponym pairs with hyponym relationships in the text can be directly extracted from the plain text; 4) The model architecture of the text processing method in the embodiment of the present application is universal and applicable to all other information extraction tasks, such as coreference resolution, event extraction, entity linking, etc.; 5) The model of the text processing method in the embodiment of the present application also supports a variety of business scenarios and a variety of application products, and examples of applicable business scenarios and application products will be given below.
[0170] The text processing method of the embodiment of the present application can be applied to at least the following products:
[0171] 1) Query understanding and search word recommendation. For the search query text, we can identify the entities in the query text and retrieve the concept graph constructed by the concept hyponym extraction method to obtain more search word recommendations with abstract meanings. Figure 7 As shown, it is a product interface diagram of the search association word recommendation provided in the embodiment of the present application. When the user enters XX school in the search box 701, the entity in the input content can be identified, and the hyponyms and hyponyms obtained by the text processing method provided in the embodiment of the present application are used to retrieve the constructed concept map to obtain more search association word recommendations 702 with abstract meanings.
[0172] 2) Concept-based candidate search box word generation. Through the concept hypernym extraction method, all subordinate entities under the concept hypernym can be obtained, and the concept words can be used as search cards and placed on the browser homepage as search recommendations. Figure 8 As shown, it is a product interface diagram generated by the concept candidate search box words provided by the embodiment of the present application. In the TV series ranking list, there are different types of TV series. For example, under the superordinate concept of high-scoring ancient costume suspense TV series, there can be multiple specific TV series names, and these specific TV series names are the subordinate entities of the superordinate concept of high-scoring ancient costume suspense TV series. When forming the TV series ranking list, multiple subordinate entities corresponding to the superordinate concept of high-scoring ancient costume suspense TV series can be generated based on the text processing method provided by the embodiment of the present application to form a hyponym pair, and then the TV series ranking list can be classified according to the hyponym pair.
[0173] 3) Question and answer system based on knowledge graph. Traditional question and answer systems based on knowledge graphs are all based on graphs of entities and entity relationships, and the answers generated from questions are usually texts corresponding to a specific entity. However, human answers are usually abstract, so the text processing method of the embodiment of the present application is used to identify hyponym pairs, and then a concept graph is constructed based on the identified hyponym pairs. The text that answers the question is generated based on the concept graph, which is more in line with the logic of human answers. For example, for the input question "Where is Xiao Wang's wife's hometown?", if a concept graph is not constructed based on the method of the embodiment of the present application to perform question and answer matching, the result may be "X City", but if the method of the embodiment of the present application is used to answer based on the constructed concept graph, the result may be "In the beautiful coastal city of X City". In other words, when the method of the embodiment of the present application is used to perform question and answer matching based on the knowledge graph, not only a specific entity can be answered, but also at least one concept can be answered, that is, a more abstract answer can be obtained. Obviously, this answer is more in line with human language logic. Fig. 9 As shown, it is a schematic diagram of the question-answer matching process of the question-answering system based on the knowledge graph provided in the embodiment of the present application. First, the input question 901 "Where is Xiao Wang's wife's hometown?" is semantically parsed 902 to obtain a semantic representation 903. Then, based on a pre-built knowledge base 905, the obtained semantic representation 903 is semantically matched, queried, and reasoned 904 to obtain an answer 906. It should be noted that the pre-built knowledge base is the above-mentioned concept graph.
[0174] The text processing method of the embodiment of the present application is a method for extracting all possible hyponym and hyponym pairs in a plain text. Fig.10 is a flowchart of a text processing method implemented by a text processing system provided in an embodiment of the present application, such as Fig.10 As shown, the entire text processing process includes a data annotation stage 1001, a model training stage 1002, and a model reasoning stage 1003.
[0175] In the data labeling stage 1001, the unlabeled data 1004 is labeled with entities, concepts and "is a" relationships 1005 using an automatic and manual method to obtain training data 1006 (ie, training samples).
[0176] In the model training stage 1002, the training data 1006 is used to construct data 1007 in question + text format, and the data 1007 in question + text format is input into the MRC model 1008 provided in the embodiment of the present application for prediction, so as to predict the span tag 1009 of the concept (the span tag here is an inline tag of Hypertext Markup Language (HTML) and is used to combine inline elements in a document).
[0177] In the model reasoning stage 1003, entity extraction 1011 is performed based on the test data 1010 to obtain a subordinate entity set 1012, wherein the subordinate entity set 1012 includes at least one subordinate entity word. Question + text format data 1013 is constructed based on the subordinate entity set 1012, and the question + text format data 1013 is input into the MRC model 1014 for prediction, thereby predicting the span tag 1015 of the concept corresponding to the subordinate entity word. In addition, based on the identified subordinate entity set 1012 and the span tag 1015 of the concept corresponding to the subordinate entity word, the upper and lower triples 1016 can be obtained.
[0178] Fig.11 Schematic diagrams of three scenarios provided in the embodiments of the present application, such as Fig.11 As shown, the method provided in the embodiment of the present application can solve the concept and hierarchical relationship extraction in three scenarios:
[0179] 1) Many-to-Many scenario 1101: This scenario is to extract all hyponym and hyponym pairs in a given plain text through the MRC model 1104. This scenario is used to mine all possible common hyponym and hyponym pairs in a text.
[0180] 2) One-to-Many scenario 1102: In this scenario, given a subordinate entity and the text in which the entity exists, all superordinate concepts of the subordinate entity in the text are extracted from the text through the MRC model 1104. This scenario is used to mine the superordinate concepts of a specific entity in the text, and can expand the concept set corresponding to the entity.
[0181] 3) Many-to-One scenario 1103: In this scenario, given a superordinate concept and the text containing the concept, all subordinate entities that the superordinate concept needs to be attached to in the text are extracted from the text through the MRC model 1104. This scenario is used to mine the subordinate entities of a specific concept in the text, and can expand the set of subordinate entities corresponding to the concept.
[0182] The entity extraction process in the text processing method provided in the embodiment of the present application is described below. It should be noted that in the embodiment of the present application, the entities involved refer to entity words, and the concepts involved refer to concept words.
[0183] The embodiment of the present application first identifies all possible entities from the text, which can be achieved using a sequence annotation tool and the deep learning NER model corresponding to the sequence annotation tool, which is more generalized. For example, given the text "xx game is a puzzle mobile game under T company, and it is also the most popular game nowadays.", two named entities can be identified by the sequence annotation tool: "xx game" and "T company".
[0184] The following is a description of the concept extraction process of entities in the text processing method provided in the embodiment of the present application.
[0185] In the embodiment of the present application, after all entities are extracted from the text, each entity may have a corresponding superordinate concept in the text. Therefore, for each entity, a machine reading comprehension model (i.e., an MRC model) can be used to extract the superordinate concept corresponding to the entity from the text by taking the entity as a question and the text as a context. The concept extraction process of the entity, i.e., the MRC model, is as follows: Fig.12 As shown, the MRC model 120 includes a Chinese BERT model 1201 (Chinese-BERT-wwm) based on the whole word masking technology and a multilayer perceptron 1202 (MLP). The entity 1203 and the text 1204 are input into the MRC model 120, that is, the entity is used as a question (query), the text is used as a context (context), the question and the context are spliced, and the input text of the MRC model 120 is used to obtain the confidence 1205 of each word segment in the text 1204 as the superordinate concept of the entity 1203.
[0186] In the MRC model 120 part, using Chinese-BERT-wwm as the encoder of the MRC model can effectively utilize the knowledge learned by the pre-trained language model in the pre-training stage. Fig.13As shown, it is a structural diagram of the encoder of the MRC model provided by the embodiment of the present application. In the pre-training stage 131 (Pre-traning), the input is input sentence A and input sentence B. Input sentence A and input sentence B are input to the BERT model, and input sentence A and input sentence B are segmented and feature extracted to obtain an input vector. Among them, the BERT model adds some special flags. The [CLS] flag is placed at the first position of the first sentence. The representation vector C obtained by the BERT model can be used for subsequent classification tasks; the [SEP] flag is used to separate two input sentences, such as input sentences A and B. The [SEP] flag should be added after input sentences A and B; the [MASK] flag is used to cover some words in the sentence. After the word is covered with [MASK], the [MASK] vector output by the BERT model is used to predict what the word is. After the BERT model obtains the sentence to be input, the words of the sentence should be converted into embedded vectors, and the embedded vector is represented by E. In the fine-tuning stage 132 (Fine-Tuning), fine-tuning is performed when it is subsequently used for some downstream tasks, such as question-answering systems. The BERT model can be fine-tuned on different tasks without adjusting its structure.
[0187] In an embodiment of the present application, a linear layer (i.e., MLP) can be used to map the representation of each word obtained by the encoder to a binary classification space, and a binary classification multi-label multi-classification loss function can be used to judge each word in the context of the input text to determine whether the word is part of a hypernym concept.
[0188] Finally, the reasoning stage is performed. In the reasoning stage, the predicted results are decoded using a specific threshold after parameter adjustment. All continuous words with scores greater than the threshold in the output results of the context can be used as the hypernym corresponding to the subordinate entity (query). Since there may be multiple continuous segments, in the embodiment of the present application, multiple hypernyms corresponding to an entity can be extracted. For the case where there is no hypernym in the text for the subordinate entity, the model of the embodiment of the present application can also cover it, that is, the output scores corresponding to all words are less than the threshold.
[0189] In the embodiment of the present application, since corresponding 0 to multiple concepts are identified for each entity identified in the text, many-to-many scenarios and one-to-many scenarios can be solved; for many-to-one scenarios, it is only necessary to replace the query of the MRC model with the superordinate concept and the decoding result with the subordinate entity.
[0190] Since the embodiment of the present application proposes a method of first identifying entities and then identifying the concepts corresponding to the entities, it can effectively avoid identifying the relationship between entities and entities, and the relationship between concepts and concepts, and therefore, it is more in line with the task goal of extracting hyponyms and hyponyms. In addition, the method of the embodiment of the present application can effectively solve the recognition of hyponyms and hyponyms in the three major business scenarios of many-to-many, one-to-many and many-to-one. Table 1 below is the experimental results of the recognition of hyponyms and hyponyms using the method of the embodiment of the present application, wherein the test set is real business data. As can be seen from Table 1, in the validation set consisting of 500 samples, there are 802 true sample words (TP, true positive), 63 false positive sample words (FP, false positive), and 289 false negative sample words (FN, false negative). The result after the validation set is identified is that the precision rate P is 92.7%, the recall rate R is 73.5%, and the F value metric F1 is 82.0%. The test set consists of 100 samples, including 166 true sample words, 8 false positive sample words, and 87 false negative sample words. The result of the test set recognition is that the precision rate P is 95.4%, the recall rate R is 65.6%, and the F value F1 is 77.8%. Obviously, the precision rate is higher under the real business data.
[0191] Table 1
[0192]
[0193] In addition, the text processing module provided in the embodiment of the present application also extracted 3.4 million deduplicated hyponym and hyponym pairs. Fig.14 This is a schematic diagram of a case predicted by the method of the embodiment of the present application. It can be seen that the text processing module of the embodiment of the present application can solve many-to-many and one-to-many scenarios at the same time. In addition, the architecture of first extracting entities and then extracting the corresponding superordinate concepts of the entities proposed in the embodiment of the present application is universal and can be used for other information extraction tasks, such as coreference resolution, event extraction, and entity linking.
[0194] It should be noted that the entity extraction process of the embodiment of the present application uses an internal sequence labeling tool of the company. This tool is not only strong in entity recognition ability for short texts in general fields, but can also be applied to entity recognition of long texts in different fields. However, if the method of the embodiment of the present application is used in other fields (such as medicine and finance) or other types of data (such as information flow data), it is necessary to adaptively change the entity extraction model. For example, a vertical category model is trained on a vertical category field or data for entity extraction. In addition, the decoder of the MRC model can use a more complex decoder, for example, using two linear layers to determine whether each word is the starting position (start) or the ending position (end) of the concept, and finally using all adjacent starting positions and ending positions to obtain the final superordinate concept recognition result.
[0195] It is understandable that in the embodiments of the present application, the content involving user information, such as the text to be processed entered by the user or the text to be processed related to the user information, when the embodiments of the present application are applied to specific products or technologies, it is necessary to obtain the user's permission or consent, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0196] The following is a description of an exemplary structure of the text processing device 354 provided in the present application as a software module. In some embodiments, Figure 3 As shown, the text processing device 354 includes:
[0197] A recognition module 3541 is used to perform first-type word recognition on the text to be processed to obtain at least one first-type word;
[0198] The encoding processing module 3542 is used for encoding the first type of words and the text to be processed for each of the first type of words to obtain a text word vector corresponding to the first type of words and the text to be processed; wherein the text to be processed includes at least two word segments;
[0199] A decoding processing module 3543 is used to perform a hyponym decoding process on the text word vector to obtain a confidence that each of the at least two word segments has a hyponym relationship with the first type of word;
[0200] A determination module 3544, configured to determine, from the at least two participles, a second type of word corresponding to each of the first type of words according to the confidence level;
[0201] The association module 3545 is used to associate the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
[0202] In some embodiments, the encoding processing module is also used to: perform feature extraction on the first type of words through an encoder to obtain a first word vector corresponding to the first type of words; perform word segmentation processing on the text to be processed to obtain the at least two word segmentations; perform feature extraction on each of the word segmentations through the encoder to obtain a second word vector corresponding to each of the word segmentations; wherein all the second word vectors corresponding to the at least two word segmentations constitute the text vector of the text to be processed, and the first word vector and the text vector constitute the text word vector.
[0203] In some embodiments, the decoding processing module is also used to: perform binary classification mapping on the second vector corresponding to each of the word segmentations based on the first word vector through a linear layer in the decoder to obtain a binary classification result of the second word vector of each word segmentation; perform the decoding processing on the binary classification result to obtain the confidence that each of the at least two word segmentations has the hyponymous relationship with the first type of word.
[0204] In some embodiments, when the first type of word is a subordinate entity word, the second type of word is a superordinate concept word; when the first type of word is a superordinate concept word, the second type of word is a subordinate entity word; the binary classification result is used to characterize that the participle is a part of the superordinate concept word of the first type of word, or, the binary classification result is used to characterize that the participle is a part of the subordinate entity word of the first type of word.
[0205] In some embodiments, the determination module is also used for at least one of the following: determining the word segmentation whose confidence is greater than the confidence threshold as the second type of word; and when the positions of multiple word segmentations whose confidence is greater than the confidence threshold are continuous in the text to be processed, determining the text segments corresponding to the multiple continuous word segmentations as the second type of word.
[0206] In some embodiments, the encoding processing module is also used to: concatenate the first type of words and the text to be processed to form a concatenated text; input the concatenated text into a pre-trained MRC model, and encode the concatenated text through the encoding module of the MRC model to obtain text word vectors corresponding to the first type of words and the text to be processed; wherein the MRC model is trained using sample words generated by a sample word generation method based on full-word masking.
[0207] In some embodiments, the MRC model includes a first decoding module; the decoding processing module is also used to: through the first decoding module, perform hyponym decoding processing on the text word vector based on the first decoding parameters obtained in advance, and obtain the confidence that each of the at least two word segments has the hyponym relationship with the first type of word.
[0208] In some embodiments, the MRC model includes a second decoding module; the decoding processing module is also used to: through the second decoding module, based on the second decoding parameters obtained in advance, perform hyponym decoding processing on the text word vector to obtain the starting confidence of each of the at least two participles as the starting position of the second type of word, and the ending confidence of each participle as the ending position of the second type of word; the determination module is also used to: determine the second type of word from the at least two participles based on the starting confidence and the ending confidence.
[0209] In some embodiments, the determination module is also used to: determine the segmentation whose start confidence is greater than a first threshold as a start word; determine the segmentation whose end confidence is greater than a second threshold as an end word; among all the start words and all the end words, determine the target start word and target end word that are adjacent in position and the start word is located before the end word; in the text to be processed, determine the text fragment between the target start word and the target end word as the second type of word.
[0210] In some embodiments, the device also includes: a processing module, used to construct an information database using the hyponym and hyponym pairs; construct a concept map of the target domain based on the hyponym and hyponym pairs in the information database; respond to the received information search request based on the concept map to obtain a response result.
[0211] It should be noted that the description of the device of the embodiment of the present application is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment, so it is not repeated. For technical details not disclosed in the embodiment of the device, please refer to the description of the method embodiment of the present application for understanding.
[0212] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned method of the embodiment of the present application.
[0213] The present application embodiment provides a storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the method provided by the present application embodiment, for example, Figure 4 The method shown.
[0214] In some embodiments, the storage medium can be a computer-readable storage medium, for example, a ferroelectric random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPR OM), a flash memory, a magnetic surface memory, an optical disk, or a compact disk read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above memories.
[0215] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0216] As an example, executable instructions may, but need not necessarily, correspond to a file in a file system, may be stored as part of a file storing other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions). As an example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network.
[0217] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A text processing method, characterized in that: The method comprises: The first type of words are recognized on the text to be processed by a pre-trained text recognition model to obtain at least one first type of word; the model parameters in the text recognition model include pre-set constraints, and the constraints are conditions for constraining entity word types or concept word types; For each of the first-type words, encoding the first-type words and the text to be processed is performed to obtain a text word vector corresponding to the first-type words and the text to be processed; wherein the text to be processed includes at least two word segments; Performing a hyponym-hypernym decoding process on the text word vector to obtain a confidence level that each of the at least two word segments has a hyponym-hypernym relationship with the first type of word; Determining, according to the confidence, a second type word corresponding to each first type word from the at least two participles; The first type of words are associated with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
2. The method according to claim 1, characterized in that: The encoding process of the first type of words and the to-be-processed text to obtain text word vectors corresponding to the first type of words and the to-be-processed text includes: Extracting features of the first type of words through an encoder to obtain a first word vector corresponding to the first type of words; Performing word segmentation processing on the text to be processed to obtain the at least two word segments; The encoder performs feature extraction on each of the word segments to obtain a second word vector corresponding to each of the word segments; wherein all the second word vectors corresponding to the at least two word segments constitute a text vector of the text to be processed, and the first word vector and the text vector constitute the text word vector.
3. The method according to claim 2, characterized in that The performing the hyponymy decoding process on the text word vector to obtain the confidence that each of the at least two participles has a hyponymy relationship with the first type of word, includes: Through the linear layer in the decoder, based on the first word vector, the second vector corresponding to each of the word segments is subjected to binary classification mapping to obtain a binary classification result of the second word vector of each of the word segments; The decoding process is performed on the binary classification result to obtain the confidence that each of the at least two participles has the hyponymous relationship with the first type of word.
4. The method according to claim 3, characterized in that When the first type of words are lower-level entity words, the second type of words are higher-level concept words; When the first type of words are hypernymous concept words, the second type of words are hyponymous entity words; The binary classification result is used to represent that the segmented word is a part of a hypernym of the first type of word, or the binary classification result is used to represent that the segmented word is a part of a hyponym of the first type of word.
5. The method according to claim 1, characterized in that The step of determining, according to the confidence level, a second type word corresponding to each first type word from the at least two participles comprises at least one of the following methods: Determine the word segmentation whose confidence is greater than the confidence threshold as the second type of word; as well as, When the positions of a plurality of word segments whose confidences are greater than a confidence threshold are continuous in the text to be processed, the text segments corresponding to the plurality of continuous word segments are determined as the second type of words.
6. The method according to claim 1, characterized in that The encoding process of the first type of words and the to-be-processed text to obtain text word vectors corresponding to the first type of words and the to-be-processed text includes: splicing the first type of words and the text to be processed to form a spliced text; Input the concatenated text into the pre-trained MRC model, The concatenated text is encoded by the encoding module of the MRC model to obtain text word vectors corresponding to the first type of words and the text to be processed; The MRC model is trained by using sample words generated by a sample word generation method based on full-word masking.
7. The method according to claim 6, characterized in that The MRC model includes a first decoding module; The performing the hyponymy decoding process on the text word vector to obtain the confidence that each of the at least two participles has a hyponymy relationship with the first type of word, includes: The text word vector is decoded based on the first decoding parameter obtained by pre-training through the first decoding module to obtain the confidence that each of the at least two word segments has the hyponymy relationship with the first type of word.
8. The method according to claim 6, characterized in that The MRC model includes a second decoding module; The performing the hyponymy decoding process on the text word vector to obtain the confidence that each of the at least two participles has a hyponymy relationship with the first type of word, includes: By means of the second decoding module, based on the second decoding parameters obtained in advance through training, the text word vector is subjected to hyponym decoding processing to obtain a start confidence of each of the at least two participles as a start position of the second type of word and an end confidence of each participle as an end position of the second type of word; The step of determining, according to the confidence level, a second type word corresponding to each first type word from the at least two participles includes: The second type of word is determined from the at least two word segments according to the start confidence and the end confidence.
9. The method according to claim 8, characterized in that The determining the second type of word from the at least two participles according to the start confidence and the end confidence includes: Determine the word segment whose start confidence is greater than the first threshold as the start word; Determine the word segmentation whose ending confidence is greater than the second threshold as the ending word; Among all the start words and all the end words, determine the target start words and target end words whose positions are adjacent and the start words are located before the end words; In the text to be processed, the text segment between the target start word and the target end word is determined as the second type of word.
10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: Using the hyponym and hyponym pairs to construct an information database; Constructing a concept map of the target domain according to the hyponym and hyponym pairs in the information database; The received information search request is responded to based on the concept map to obtain a response result.
11. A text processing device, characterized in that: The device comprises: A recognition module, used for performing first type word recognition on the to-be-processed text through a pre-trained text recognition model to obtain at least one first type word; the model parameters in the text recognition model include pre-set constraints, and the constraints are conditions for constraining entity word types or concept word types; An encoding processing module, used for encoding each of the first type of words and the text to be processed to obtain a text word vector corresponding to the first type of words and the text to be processed; wherein the text to be processed includes at least two word segments; A decoding processing module, used for performing a hyponym decoding process on the text word vector to obtain a confidence that each of the at least two participles has a hyponym relationship with the first type of word; a determination module, configured to determine, from the at least two participles, a second type of word corresponding to each of the first type of words according to the confidence level; The association module is used to associate the first type of words with the second type of words to obtain at least one hyponym and hyponym pair corresponding to the text to be processed.
12. A text processing device, characterized in that: include: A memory for storing executable instructions; A processor, configured to implement the text processing method according to any one of claims 1 to 10 when executing the executable instructions stored in the memory.
13. A computer-readable storage medium, characterized in that: Executable instructions are stored, which are used to cause a processor to execute the executable instructions to implement the text processing method described in any one of claims 1 to 10.
