WO2021073179A1 - Named entity identification method and device, and computer-readable storage medium - Google Patents

Named entity identification method and device, and computer-readable storage medium Download PDF

Info

Publication number
WO2021073179A1
WO2021073179A1 PCT/CN2020/102094 CN2020102094W WO2021073179A1 WO 2021073179 A1 WO2021073179 A1 WO 2021073179A1 CN 2020102094 W CN2020102094 W CN 2020102094W WO 2021073179 A1 WO2021073179 A1 WO 2021073179A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
named entity
recognized
keyword
recognition model
Prior art date
Application number
PCT/CN2020/102094
Other languages
French (fr)
Chinese (zh)
Inventor
孟函可
祝官文
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021073179A1 publication Critical patent/WO2021073179A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition

Definitions

  • This application relates to the technical field of named entity recognition, in particular to the method and equipment of named entity recognition, and computing
  • Named entity recognition also known as entity recognition or NER
  • NER entity recognition
  • a named entity generally refers to an entity with a specific meaning or strong referentiality in the text, which usually includes the name of a person, place name, organization name, date and time, proper nouns, etc.
  • the NER system extracts the above entities from unstructured input text, and can identify more types of entities according to business needs.
  • the existing named entity recognition method in the related art usually only trains the named entity recognition model for a specific application scenario. For different scenarios, a large number of corpus corresponding to the scenario needs to be used for training, and multiple recognition models are trained separately to apply. In different scenarios, the training process is complicated, and the adaptability of the model is not strong.
  • This application provides a method and device for identifying a named entity, and a computer-readable storage medium, so that the named entity recognition model can be applied to different scenarios.
  • the named entity recognition model By embedding the scene information into the input information of the named entity model, it improves
  • the named entity recognition model recognizes the probability of a named entity in different usage scenarios.
  • this application provides a method for identifying named entities for identifying named entities in text.
  • Named Entity refers to an entity with specific meaning or strong referentiality in the text. It usually includes the name of a person, place name, organization name, date and time, proper nouns, etc., and more extensive entities also include Numbers, currencies, addresses, etc.
  • the method for recognizing named entities provided in this application can be applied to formal recognition scenarios, for example, to provide text-based named entity recognition for voice assistants.
  • the method for identifying named entities provided in this application can also be applied in the process of training the named entity recognition model.
  • the method provided in this application is used to identify the named entities in the training text
  • the pre-marked named entities in the training text are compared, and the parameters in the named entity recognition model are adjusted according to the comparison results.
  • the method for identifying named entities provided by the first aspect includes:
  • the text to be recognized may be text obtained after voice conversion into text, or a training sample text pre-marked with named entity tags.
  • the text to be recognized may include characters such as Chinese, numbers, symbols, and English.
  • the Named Entity Recongition (NER) model (also referred to as a named entity recognition system) can extract the named entity from the text to be recognized, and can identify more types of named entities according to business requirements.
  • the named entity recognition model can use the feature template-based method and neural network-based method in the existing related technologies.
  • the named entity recognition model can use Word Embedding (word embedding). +LSTM (Long Short Term Memory Network)/BiLSTM (Bidirectional Long Short Term Memory Network) + CRF (Conditional Random Field) model.
  • the scenario is the actual situation in which the named entity recognition model is applied.
  • the scenario type classification method of the named entity recognition model application can be classified according to the terminal type, and/or application software type, and/or usage type.
  • the terminal type may include Different types of terminal electronic devices such as TVs, mobile phones, car consoles, etc.
  • the application software types can be system or application software types (such as movies, music, etc.), and the use types can be divided into voice assistants or automatic response systems, etc.
  • the scene types are divided into multiple categories, for example, the application scenarios of the voice assistant of the TV system, the application scenarios of the automatic reply system of the shopping software, etc.
  • the application does not make specific restrictions on this.
  • the input information in addition to inputting the text to be recognized into the named entity recognition model, the input information also includes the named entity recognition model.
  • the applied scene type information by inputting the scene type information as the input information in the training process and/or recognition process of the named entity recognition model, makes the named entity recognition model applicable to different application scene types, for example, if the user is interested in the voice assistant Say "change to your name". For TV voice assistants, "your name” will be recognized as the name of the movie, while for mobile voice assistants, "your name” may not be recognized as the name of the movie. This is because the named entity recognition model is applied to different scene types.
  • the named entity recognition model is based on the scene type information of the input information, and the output recognition results may be different.
  • the method before inputting the to-be-recognized text and the scene type into the named entity recognition model, the method further includes: marking the to-be-recognized text in a content index according to a division unit, where , The division units with the same content are marked by the same content index; the scene type index corresponding to the scene type is determined; the scene type index is marked for each division unit, that is, each division unit ( For example, each word or each word segmentation) is marked with the scene type index to which it is applied.
  • the inputting the text to be recognized and the scene type into the named entity recognition model includes: inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
  • the above division unit refers to the basic unit of sentence division.
  • a single Chinese character can be used as the most basic division unit, or the word after word segmentation processing can be used as the most basic division unit.
  • word segmentation tools in related technologies, such as the jieba word segmentation tool.
  • the goal of word segmentation processing is to divide a sentence into multiple word segments.
  • Each segmentation unit in the text to be recognized will be marked with a corresponding content index (also called a word index) Or word index), the index of the same word or word is the same, for example, the index of " ⁇ " is 15, the index of "Name” is 92, and so on.
  • the method for determining the scene type index corresponding to the above scene type may be manually configured in advance.
  • the scene type index is set in the factory according to the type of terminal device to be applied.
  • the indexes corresponding to different types of scenes may be pre-configured mappings. For example, for an application scenario of a voice assistant applied to a mobile phone terminal, the scene type index is 1, for an application scenario of a voice assistant applied to a TV terminal, the scenario type index is 2, and so on.
  • the processing method of the named entity recognition model includes: The division unit is to convert the different types of indexes to be labeled into multi-dimensional vectors; for each of the division units, multiple multi-dimensional vectors after the conversion of different types of indexes are sequentially spliced; and the output result of the sequence labeling model is obtained , To obtain the label information of the named entity in the text to be recognized.
  • the conversion (mapping) of the index into a vector can use the related prior art word embedding (Word Embedding), distributed vector (Distributional Vectors), one-hot (one-hot) and other algorithms or improved algorithms.
  • An index or other type of index used to represent the division unit (character or word segmentation) of natural language is converted into a multidimensional vector that can be recognized by the machine.
  • the vector of content index conversion and the scene type vector are spliced in order to obtain the splicing vector of each word.
  • the content index is 15, which is converted into a 50-dimensional vector w1 .
  • the application scenario of the named entity recognition model is the voice assistant of the mobile phone terminal, the index is 1, and it is converted into a 10-dimensional vector w2, then the stitching vector of the word " ⁇ " is [w1, w2].
  • sequence labeling model is a model for performing sequence labeling tasks.
  • the input of the sequence labeling model is a sequence of multiple splicing vectors, and each splicing vector in the sequence corresponds to the division unit of the corresponding position.
  • the output is the label corresponding to each splicing vector, and the label is used to indicate whether the corresponding division unit is a named entity.
  • tags can also be used to indicate whether the named entity type and/or the corresponding division unit is the starting position.
  • the text to be recognized is "Play your name”
  • the word segmentation result is "Play/ You/ ⁇ /Name”
  • the scene type index is 1, input the splicing vector into the sequence labeling model, and the output result is "O B-movie I-movie I-movie”
  • the label "O” represents the corresponding division unit " "Play” is not a named entity
  • the label "B-movie” indicates that the corresponding division unit "you” is a named entity
  • the type is movie (movie)
  • the label "I-movie” indicates the corresponding division
  • the units "of” and "name” are named entities, the type is movie (movie), and they are not the starting position of the named entity.
  • the sequence labeling model is a deep learning model, for example, RNN (cyclic neural network) + CRF model.
  • the deep learning model includes one or more layers of cyclic neural networks and conditions Random field.
  • each layer of the recurrent neural network uses a neural network calculation unit to sequentially calculate the splicing vector of each division unit in the text to be recognized to output A calculation result vector corresponding to each division unit; a conditional random field is used to receive a vector sequence, the vector sequence includes a plurality of the calculation result vectors arranged in order, and the plurality of calculation result vectors are the one layer
  • the last layer of the recurrent neural network in the multi-layer recurrent neural network calculates a result vector for all the division units to output a label used to identify whether each division unit is a named entity.
  • the RNN can select LSTM or BiLSTM.
  • the aforementioned deep learning model may be a model obtained by unsupervised pre-training using corpus.
  • Unsupervised pre-training is a way to train the model using unlabeled corpus.
  • the training method can be to encode the original corpus.
  • the training goal is that when the input is the encoded original corpus, the output of the model is the original corpus ( That is, to predict the original corpus), or, in the case where the deep learning model is an LSTM+CRF model, the training goal of the deep learning model can be to input a word and output the next word (that is, predict the next word) .
  • the method before inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, the method further includes: for each of the to-be-recognized texts.
  • Each of the division units is marked with a part-of-speech index.
  • the part-of-speech index is used to indicate the part-of-speech of the corresponding division unit, such as verbs, nouns, adverbs, conjunctions, etc.; correspondingly, each division unit entered into the named entity recognition model is
  • the marked index includes the part-of-speech index.
  • an index into a vector when converting an index into a vector, it also includes converting a part-of-speech index into a multi-dimensional vector.
  • a splicing vector for each division unit, all types of indexes (including content index, part-of-speech index, scene index) The vector is spliced into a vector as the splicing vector of the corresponding division unit.
  • the method before inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, the method further includes: combining the to-be-recognized text with a preset Named entity dictionary matching in the to-be-recognized text to determine all the named entities that are matched in the text to be recognized; for each of the division units in the text to be recognized, a knowledge index is marked, where the knowledge index is used to indicate the corresponding The information of the named entity matched by the division unit in the named entity recognition model, and correspondingly, the index marked for each division unit input to the named entity recognition model includes the knowledge index.
  • the matching result information is marked by the knowledge index.
  • the knowledge index can mark the type and/or starting position and/or matching times of the named entity, for example, "you", "name”, "in your name” "Your name” matches the movie name entity in the named entity dictionary, so mark “you” with the index B2-I0-movie to indicate that "you” is the movie name named entity that matches twice as the starting position.
  • the "name” label B1-I1-movie indicates that the "name” is a named entity that matches the movie name once as the starting position and once as the non-starting position.
  • the method before the text to be recognized and the scene type are input into the named entity recognition model, the method further includes: obtaining the first text to be recognized corresponding to the current round of conversation, and the conversation It can be a voice conversation or a text conversation.
  • the current round of conversation described in the embodiment of this application refers to the latest conversation sent by another party corresponding to the executor of the embodiment of this application.
  • the waiting session is obtained. Recognized first text; detect whether there is a first keyword in the first text, for example, "change”, "replace”, etc., the first keyword is used to indicate that the first text and multiple Round conversation scenes are related.
  • Multi-round conversation scenes refer to contextual scenes.
  • the first The keyword is also used to indicate that the intent corresponding to the first text is incomplete; if the first keyword exists in the first text, the first keyword in the first text is Replace with the second keyword, for example, replace “change” with “play” to obtain the second text to be recognized; correspondingly, the named entity recognition model is also used to at least according to the second keyword and the The scene type, the named entity is identified in the second text, the second keyword is related to the entity category corresponding to the identified named entity, and the second keyword "play” in the above example is related to the movie category
  • the entity category of the named entity recognition model receives the second text containing the second keyword, and the entity category of the identified named entity is related to the entity category corresponding to the second keyword, that is, the second keyword is related to The entity category of the identified named entity is related.
  • the method before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session.
  • the executor of the embodiment of the present application can obtain the intent analysis result of the previous round of conversation, and obtain the corresponding intent type, for example, It can be the intent type of the search video category, etc.; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type, then detect Whether the first keyword exists in the first text, that is, it is necessary to detect whether the first keyword exists in the first text only when the intent type in the previous round is a specific one or several intent types .
  • the second keyword is determined according to the intent analysis result corresponding to the previous session of the current session.
  • each intent type may correspond to one or more keywords, and one keyword is selected from these keywords.
  • the second keyword or, the second keyword may be a word extracted from the previous round of conversation, for example, a verb (such as "play"), or a name related to the entity category (such as "movie").
  • the second keyword is a verb and/or noun.
  • detecting whether the first keyword exists in the first text includes: using a preset regular expression to match in the first text, and determining whether the first text is The first keyword exists.
  • the regular expression is ([I want only]? Want
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/ Or “movie”; the second keyword corresponding to the entity category of the music category is "listening" and/or "music”.
  • the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
  • the purpose of the above embodiment is to prevent the identified named entity from not being in the original text.
  • the first text is "Change to ABC”
  • the second text is "Play ABC”
  • the recognized named entity is "Put AB”, which is not in the original text of the first text. This is due to the replacement of keywords. Error in identifying named entities.
  • the above-mentioned scene types are classified according to the type of terminal and/or the type of application software to which the named entity recognition model is applied.
  • the method is applied to an electronic device equipped with a sound receiver, such as a mobile phone terminal or a TV terminal, and the obtaining of the text to be recognized includes: obtaining the voice collected by the sound receiver , Such as a voice command issued by the user; convert the voice into text to obtain the text to be recognized.
  • a sound receiver such as a mobile phone terminal or a TV terminal
  • the present application also provides a method for identifying named entities.
  • the method includes: obtaining a first text to be recognized corresponding to this round of conversation; detecting whether there is a first keyword in the first text, said The first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; if the first keyword exists in the first text, the first key in the first text is Word is replaced with a second keyword to obtain the second text to be recognized; at least according to the second keyword, a named entity recognition model is used to identify a named entity in the second text, and the second keyword is the same as the The entity category corresponding to the identified named entity is related.
  • the named entity recognition model can be combined with the scene type applied by the named entity recognition model, and before the named entity recognition model is used to identify the named entity in the second text, the scene type applied by the named entity recognition model is obtained, At least according to the second keyword and the scene type to identify the named entity in the second text, those skilled in the art have the ability to combine the embodiments provided in the first aspect and the embodiments provided in the second aspect.
  • the method before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session Intent analysis result of the third text to obtain the intent type of the third text; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent Type, then it is detected whether there is a first keyword in the first text.
  • the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the text to be recognized to determine whether the first keyword exists in the first text.
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category of the music category is "listen” and/or "music”.
  • the present application provides a device for identifying a named entity.
  • the device includes: a first acquiring module for acquiring a text to be recognized; a first determining module for determining a device used to identify the text to be recognized The type of scene to which the named entity recognition model of the named entity is applied; an input module for inputting the text to be recognized and the type of scene into the named entity recognition model; an execution module for obtaining information about the named entity recognition model Output information to determine the named entity recognized by the named entity recognition model in the to-be-recognized text for the scene type.
  • the device further includes: a division module, configured to divide the text to be recognized according to a division unit before inputting the text to be recognized and the scene type into the named entity recognition model Annotated content index, wherein the division units with the same content are marked by the same content index; the second determining module is configured to determine the scene type index corresponding to the scene type; and mark the division unit for each of the division units.
  • Scene type index correspondingly, the input module includes: a first input unit, configured to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
  • the named entity recognition model includes: a first conversion unit, configured to input the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, For each of the division units, respectively convert the marked indexes of different types into multi-dimensional vectors; a splicing unit is used for sequentially splicing multiple multi-dimensional vectors after conversion of different types of indexes for each of the division units; The second input unit is used to input the stitching vectors of all the division units in the text to be recognized into the sequence labeling model; the first obtaining unit is used to obtain the output result of the sequence labeling model to obtain the to be recognized The label information of the named entity in the text.
  • the sequence labeling model is a deep learning model
  • the deep learning model includes: one or more layers of recurrent neural networks, and each layer of the recurrent neural network uses neural network computing units to sequentially pair The stitching vector of each division unit in the text to be recognized is calculated to output a calculation result vector corresponding to each division unit; a conditional random field is used to receive a vector sequence, and the vector sequence includes a sequence of The plurality of calculation result vectors are the calculation result vectors of the last layer of the recurrent neural network in the one or more layers of the recurrent neural network for all the division units for output A label to identify whether each of the division units is a named entity.
  • the cyclic neural network is a long- and short-term memory neural network, or a bidirectional long- and short-term memory neural network.
  • the deep learning model is a model obtained by unsupervised pre-training using corpus.
  • the device further includes: a first labeling module, configured to, before inputting the labelled indexes of all the division units in the to-be-recognized text into the named entity recognition model, target all the Each of the division units in the text to be recognized is annotated with a part-of-speech index; correspondingly, the index of each of the division units input into the named entity recognition model includes the part-of-speech index.
  • a first labeling module configured to, before inputting the labelled indexes of all the division units in the to-be-recognized text into the named entity recognition model, target all the Each of the division units in the text to be recognized is annotated with a part-of-speech index; correspondingly, the index of each of the division units input into the named entity recognition model includes the part-of-speech index.
  • the device further includes: a third determining module, configured to input all the marked indexes of the division units in the to-be-recognized text into the named entity recognition model.
  • the text to be recognized is matched with a preset named entity dictionary to determine all named entities that are matched in the text to be recognized;
  • the second tagging module is used to tag each of the division units in the text to be recognized Knowledge index, wherein the knowledge index is used to represent the information of the named entity matched by the corresponding division unit in the named entity recognition model; correspondingly, input each of the named entity recognition models
  • the index to which the division unit is marked includes the knowledge index.
  • the device further includes: a second acquiring module, configured to acquire the pending session corresponding to the current round of the conversation before inputting the to-be-recognized text and the scene type into the named entity recognition model. Recognized first text; a detection module for detecting whether there is a first keyword in the first text, the first keyword for indicating that the first text is related to multiple rounds of conversation scenarios; a replacement module, using In the case where the first keyword exists in the first text, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized; corresponding ,
  • the named entity recognition model is also used to identify a named entity in the second text at least according to the second keyword and the scene type, and the second keyword is related to the identified named entity.
  • the corresponding entity category is related.
  • the device before detecting whether the first keyword exists in the first text, the device further includes: a third obtaining module, configured to obtain the previous session correspondence of the current session The intent analysis result of the third text to be recognized to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the The intent type of the third text is the specified intent type, and the detection module executes to detect whether the first keyword exists in the first text.
  • a third obtaining module configured to obtain the previous session correspondence of the current session The intent analysis result of the third text to be recognized to obtain the intent type of the third text
  • the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the The intent type of the third text is the specified intent type, and the detection module executes to detect whether the first keyword exists in the first text.
  • the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text.
  • the named entity recognition model is for a named entity recognized by the second text;
  • a fourth determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text;
  • the fifth determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • the detection module includes: a matching unit, configured to perform matching in the first text by using a preset regular expression, and determine whether the first text exists in the first text. Key words.
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category of the music category is "listen” and/or "music”.
  • the scene type is classified according to the type of terminal to which the named entity recognition model is applied and/or the type of application software.
  • the device is applied to an electronic device equipped with a sound receiver
  • the acquisition module includes: a second acquisition unit configured to acquire the voice collected by the sound receiver; and a second conversion The unit is used to convert the speech into text to obtain the text to be recognized.
  • an embodiment of the present application also provides a device for identifying a named entity.
  • the device includes: a first obtaining module, configured to obtain the first text to be recognized corresponding to the current session; and a detection module, configured to detect Whether there is a first keyword in the first text, the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; the replacement module is used to indicate that the first text is present in the first text In the case of a keyword, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized; the recognition module is configured to at least according to the second keyword, A named entity recognition model is used to recognize a named entity in the second text, and the second keyword is related to the entity category corresponding to the recognized named entity.
  • the device further includes: a second obtaining module, configured to obtain the previous session correspondence of the current session before detecting whether the first keyword exists in the first text
  • the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the If the intent type of the third text is the specified intent type, the detection module performs detection of whether the first keyword exists in the first text.
  • the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text.
  • the named entity recognition model is for the named entity recognized by the second text;
  • a first determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text;
  • the second determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • the detection module includes: a matching unit, configured to use a preset regular expression to perform matching in the text to be recognized, and determine whether the first keyword exists in the first text .
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category of the music category is "listen” and/or "music”.
  • the present application provides a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer executes the method as described in the first aspect.
  • the present application provides a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer executes the method described in the second aspect.
  • the present application provides a computer program, when the computer program is executed by a computer, it is used to execute the method described in the first aspect.
  • the present application provides a computer program, when the computer program is executed by a computer, it is used to execute the method described in the second aspect.
  • the program in the seventh aspect or the eighth aspect may be stored in whole or in part on a storage medium that is packaged with the processor, or may be stored in part or all in a storage medium that is not packaged with the processor. On the memory.
  • this application provides a named entity identification device, the device comprising: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computers A program is stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the method as described in the first aspect.
  • the present application provides a named entity identification device, the device includes: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computers A program is stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the method as described in the second aspect.
  • FIG. 1 is a schematic diagram of an application scenario provided by an embodiment of the application
  • FIG. 2 is a schematic flowchart of a method for identifying named entities provided by this application
  • Figure 3 is a schematic structural diagram of a named entity recognition model provided by this application.
  • FIG. 4 is a schematic flowchart of another method for identifying named entities provided by this application.
  • FIG. 5 is a schematic flowchart of another method for identifying named entities provided by this application.
  • FIG. 6 is a schematic structural diagram of a named entity identification device provided by an embodiment of this application.
  • FIG. 7 is a schematic structural diagram of another named entity identification device provided by an embodiment of this application.
  • Some embodiments provided in this application can be applied to speech recognition in the field of artificial intelligence (AI), related to natural language processing (NLP) technology, and can be specifically applied to applications such as voice assistants.
  • AI artificial intelligence
  • NLP natural language processing
  • Named Entity refers to an entity with specific meaning or strong referentiality in the text. It usually includes the name of a person, place name, organization name, date and time, proper nouns, etc., and more extensive entities also include Numbers, currencies, addresses, etc.
  • the method for recognizing named entities provided in this application can be applied to formal recognition scenarios, for example, to provide text-based named entity recognition for artificial intelligence voice assistants.
  • a system architecture applied to voice assistants is provided. Users enter the voice assistant mode through vehicle-mounted terminals, computer terminals, and mobile phone terminals.
  • the voice assistant obtains voice and uses automatic speech recognition technology (Automatic Speech Recognition).
  • the Recognition (ASR) module converts speech into text, and the text is input into the Dialog Management (DM) module, and the dialog management module distributes the text to the Natural Language Understand (NLU) module, and the NLU module receives it To the current sentence and beyond, perform named entity recognition for the current sentence.
  • ASR Automatic Speech Recognition
  • DM Dialog Management
  • NLU Natural Language Understand
  • the named entity recognition module executes an example of the named entity recognition method provided in the embodiment of this application, including word segmentation, part-of-speech tagging, and named entity tagging
  • the sequence labeling model in the named entity recognition method provided by this application in addition, also includes modules such as intention recognition classification, slot filling, etc., to understand the semantics in the text, and then the NLU module returns the analysis result to the DM module.
  • the DM module uses the Natural Language Generation (NLG) module to generate the reply dialogue text according to the recognized semantics, and the reply dialogue text is generated by the speech synthesis (Text-To-Speech) module and broadcast to the user.
  • NLG Natural Language Generation
  • the method for recognizing named entities provided in this application can also be applied to a scenario where a named entity recognition model is trained.
  • a named entity recognition model is trained.
  • the following describes the method for identifying a named entity in an embodiment of the present application in detail with reference to FIG. 2.
  • the method shown in FIG. 2 includes steps 101 to 104, and these steps are respectively described in detail below.
  • Step 101 Obtain the text to be recognized.
  • the text to be recognized may be text obtained after voice conversion into text, or a training sample text pre-marked with named entity tags.
  • the text to be recognized may include characters such as Chinese, numbers, symbols, and English.
  • the method for identifying a named entity provided in the embodiment of the present application is applied to an electronic device equipped with a sound receiver.
  • the electronic device may specifically be a mobile terminal (for example, a smart phone), a computer, or a personal digital assistant. , Wearable devices, in-vehicle devices, Internet of Things devices or other electronic devices that can receive sound.
  • the voice collected by the sound receiver is converted into text by the voice-to-text module shown in FIG. 1 to obtain the text to be recognized.
  • Step 102 Determine the scene type to which the named entity recognition model used to recognize the named entity in the text to be recognized is applied.
  • the Named Entity Recongition (NER) model (also referred to as a named entity recognition system) can extract the named entity from the text to be recognized, and can identify more types of named entities according to business requirements.
  • the named entity recognition model can use the feature template-based method and neural network-based method in the existing related technologies.
  • the named entity recognition model can use Word Embedding (word embedding). +LSTM (Long Short Term Memory Network)/BiLSTM (Bidirectional Long Short Term Memory Network) + CRF (Conditional Random Field) model.
  • a scenario refers to a business requirement scenario that requires a named entity recognition model to identify a named entity.
  • the scenario type can be divided into different types according to the terminal type and/or application software type to which the named entity recognition model is applied.
  • the terminal may include different types of terminal electronic equipment such as televisions, mobile phones, and car consoles.
  • the application software may be at the system level or the type of application software installed in the terminal's operating system (such as video, music, etc.). Use types can be divided into voice assistants or automatic response systems, etc.
  • the scene types can be divided into multiple categories, for example, voice assistants for TV systems, manuals for shopping software
  • voice assistants for TV systems There are multiple application scenarios such as smart customer service, voice assistants for video applications, and artificial intelligence voice assistants for smart home appliances. This application does not specifically limit the specific categories of scenarios into which they can be configured according to actual conditions.
  • Step 103 Input the text to be recognized and the scene type into the named entity recognition model.
  • Step 104 Obtain output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
  • the input information is also Including the scene type information applied by the named entity recognition model.
  • the named entity recognition model can be applied to different application scene types, for example, If the user says "change your name” to the voice assistant, the TV voice assistant will recognize "your name” as the name of the movie, while for the mobile phone voice assistant, it may not recognize "your name” It is the name of the movie. This is because the named entity recognition model uses different scene types.
  • the named entity recognition model is based on the scene type information of the input information, and the output recognition results may be different.
  • step 103 before the text to be recognized and the scene type are input into the named entity recognition model, the method further includes performing the following steps 11 to 13:
  • Step 11 Mark the content index of the text to be recognized according to the division unit, wherein the division units with the same content are marked by the same content index.
  • the above division unit refers to the basic unit of sentence division.
  • a single Chinese character can be used as the most basic division unit, or the word after word segmentation processing can be used as the most basic division unit.
  • word segmentation tools in related technologies, such as the jieba word segmentation tool.
  • the goal of word segmentation processing is to divide a sentence into multiple word segments.
  • Each segmentation unit in the text to be recognized will be marked with a corresponding content index (also called a word index) Or word index), the index of the same word or word is the same, for example, the index of " ⁇ " is 15, the index of "Name” is 92, and so on.
  • Step 12 Determine the scene type index corresponding to the scene type.
  • the method for determining the scene type index corresponding to the above scene type may be manually configured in advance.
  • the scene type index is set in the factory according to the type of terminal device to be applied.
  • the indexes corresponding to different types of scenes may be pre-configured mappings.
  • the scene type index is 1, for an application scenario of a voice assistant applied to a TV terminal, the scenario type index is 2, and so on.
  • the scene type index can be floating-point float data.
  • the index of general scenes is 0, and the index of high recall scenes is 1.0, so that the scene type index can be adjusted to change between 0 and 1 to make the naming
  • the entity recognition model is actively migrated to the new scene.
  • Step 13 Mark the scene type index for each division unit.
  • each division unit for example, each word or each word segmentation
  • each division unit is marked with an applied scene type index.
  • step 103 inputs the text to be recognized and the scene type into the named entity recognition model, including:
  • Step 14 Input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
  • the processing method of the named entity recognition model may include the following steps 21 to 23:
  • Step 21 For each division unit, convert the marked indexes of different types into multi-dimensional vectors.
  • Step 22 For each division unit, a plurality of multi-dimensional vectors converted by different types of indexes are sequentially spliced.
  • Step 23 Obtain the output result of the sequence annotation model to obtain the annotation information of the named entity in the text to be recognized.
  • the conversion (mapping) of the index into a vector can use the related prior art word embedding (Word Embedding), distributed vector (Distributional Vectors), one-hot (one-hot) and other algorithms or improved algorithms.
  • An index or other type of index used to represent the division unit (character or word segmentation) of natural language is converted into a multidimensional vector that can be recognized by the machine.
  • the vector of content index conversion and the scene type vector are spliced in order to obtain the splicing vector of each word.
  • the content index is 15, which is converted into a 50-dimensional vector w1 .
  • the application scenario of the named entity recognition model is the voice assistant of the mobile phone terminal, the index is 1, and it is converted into a 20-dimensional vector w2, then the stitching vector of the word " ⁇ " is [w1, w2].
  • sequence labeling model is a model for performing sequence labeling tasks.
  • the input of the sequence labeling model is a sequence of multiple splicing vectors, and each splicing vector in the sequence corresponds to the division unit of the corresponding position.
  • the output is the label corresponding to each splicing vector, and the label is used to indicate whether the corresponding division unit is a named entity.
  • tags can also be used to mark whether the named entity type and/or the corresponding division unit is the starting position.
  • the text to be recognized is "Play your name”
  • the word segmentation result is "Play / ⁇ / ⁇ /name”
  • the scene type index is 1, input the splicing vector into the sequence labeling model, and the output result is "O B-movie I-movie I-movie”
  • the label "O” represents the corresponding division unit "Play” is not a named entity
  • the label "B-movie” indicates that the corresponding division unit "you” is a named entity
  • the type is movie (movie)
  • the label "I-movie” indicates the corresponding
  • the division unit "of” and "name” are named entities, the type is movie, and they are not the starting position of the named entity.
  • the input information input to the named entity recognition model may also include part-of-speech index and/or knowledge index.
  • the method before inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the method further includes: marking the part-of-speech index for each division unit in the text to be recognized.
  • the index is used to indicate the part-of-speech of the corresponding division unit, such as verb, noun, adverb, conjunction, etc.; correspondingly, the index marked for each division unit input to the named entity recognition model includes a part-of-speech index.
  • when converting an index into a vector it also includes converting a part-of-speech index into a multi-dimensional vector.
  • the method before inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the method further includes: matching the text to be recognized with a preset named entity dictionary to determine the Recognize all named entities that are matched in the text; label a knowledge index for each division unit in the text to be recognized, where the knowledge index is used to indicate the information of the named entity matched by the corresponding division unit in the named entity recognition model
  • the index marked for each division unit of the input named entity recognition model includes a knowledge index.
  • the matching result information is marked by the knowledge index.
  • the knowledge index can mark the type and/or starting position and/or matching times of the named entity, for example, "you", "name”, "in your name” "Your name” matches the movie name entity in the named entity dictionary, so mark “you” with the index B2-I0-movie to indicate that "you” is the movie name named entity that matches twice as the starting position.
  • the "name” label B1-I1-movie indicates that the "name” is a named entity that matches the movie name once as the starting position and once as the non-starting position.
  • the sequence labeling model is a deep learning model, for example, an RNN (recurrent neural network) + CRF model.
  • the deep learning model includes one or more layers of recurrent neural networks and conditional random fields.
  • each layer of recurrent neural network uses neural network computing units to calculate the stitching vector of each division unit in the recognized text in order to output the calculation corresponding to each division unit The result vector.
  • the conditional random field is used to receive the vector sequence.
  • the vector sequence includes multiple calculation result vectors arranged in order.
  • the multiple calculation result vectors are the calculation results of the last layer of the recurrent neural network in one or more layers of the recurrent neural network for all division units.
  • the RNN can select LSTM or BiLSTM.
  • the LSTM (Long Short-Term Memory) model is a type of RNN (Recurrent Neural Network).
  • BiLSTM (Bi-directional Long Short-Term Memory) model is a combination of forward LSTM and backward LSTM. Both LSTM and BiLSTM are often used to model contextual information in natural language processing tasks.
  • Fig. 3 is a schematic structural diagram of an example of a named entity recognition model using BiLSTM+CRF.
  • the named entity recognition model 300 includes a vector conversion module, a vector splicing module, and a sequence labeling module 301.
  • the sequence labeling module 301 includes bidirectional long and short-term memory BiLSTM and CRF.
  • the input of the vector conversion module is various indexes of each word (division unit), including scene (type) index, part-of-speech index, and word (content) index.
  • the vector conversion module uses Word embedding technology to map each index into a vector.
  • the vector stitching module stitches together multiple vectors of each division unit, and inputs BiLSTM.
  • BiLSTM includes a forward LSTM network and a backward LSTM network. Each layer of LSTM network includes multiple repeated LSTM neural units. The neural unit is used to calculate the input vector. For each division unit, splice the outputs of the forward LSTM neural unit and the backward LSTM neural unit together to obtain the calculation result vector of the corresponding division unit, arrange all the calculation result vectors in order into a vector sequence, input the CRF, and get the final
  • the output tags t1, t2..., each tag is used to indicate whether the corresponding division unit belongs to a named entity, and can also identify whether the corresponding division unit is at the starting position in the named entity.
  • Transfer learning is a machine learning method that refers to a pre-trained model being reused in another task.
  • the model developed for task A is used as the initial point and reused in the process of developing the model for task B .
  • unsupervised pre-training is a way to train the model using unlabeled corpus.
  • the task of unsupervised pre-training can be any of the following:
  • the training task is the traditional language model task: predict the next word.
  • the method before inputting the text to be recognized and the scene type into the named entity recognition model, the method further includes: obtaining the first text to be recognized corresponding to the current round of conversation.
  • the conversation may be a voice conversation or a text.
  • Conversation the current round of conversations in this embodiment of this application refers to the latest conversation sent by another party corresponding to the executor of this embodiment of this application.
  • the voice or text of this round of conversation the first text to be recognized is obtained; Whether there is a first keyword in a text, for example, "change", "replace”, etc.
  • the first keyword is used to indicate that the first text is related to a multi-round conversation scene, which means that there is context Contextual scenarios, for example, the user says “please play it all well” and then "change to your name".
  • the first keyword is also used to indicate that the intent corresponding to the first text is incomplete;
  • the named entity recognition model is also used to identify named entities in the second text at least according to the second keywords and scene types.
  • the second keywords are related to the entity category corresponding to the identified named entity, the above example
  • the second keyword "play” is related to the entity category of the movie category.
  • the named entity recognition model receives the second text containing the second keyword, and the entity category of the identified named entity corresponds to the second keyword
  • the entity category is related, that is, the second keyword is related to the entity category of the identified named entity.
  • the method before detecting whether the first keyword exists in the first text, the method further includes: obtaining an intent analysis result of the third text to be recognized corresponding to the previous conversation of the current round of conversation,
  • the intent type of the third text it should be noted that the executor of the embodiment of the present application can obtain the intent analysis result of the previous round of conversation, and obtain the corresponding intent type. For example, it may be an intent to search for a video category.
  • the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type, check whether the first keyword exists in the first text, that is , Only when the intent type in the previous round is a specific one or several intent types, it is necessary to detect whether the first keyword exists in the first text.
  • the second keyword is determined according to the intent analysis result corresponding to the previous session of the current session.
  • each intent type can correspond to one or more keywords, and one keyword is selected as the first keyword among these keywords.
  • the second keyword may be a word extracted from the previous round of conversation, for example, a verb (such as "play"), or a name related to the entity category (such as "movie”).
  • the second keyword is a verb and/or noun.
  • detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the first text to determine whether the first keyword exists in the first text.
  • the regular expression is ([I want only]? Want
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category is "listening" and/or "music”.
  • the method further includes: in the first text, searching for the named entity recognized by the named entity recognition model for the second text; If the named entity is not found in the first text, then the corresponding named entity is determined to be invalid; if the named entity is found in the first text, then the corresponding named entity is determined to be valid.
  • the purpose of the above embodiment is to prevent the identified named entity from not being in the original text.
  • the first text is "Change to ABC”
  • the second text is "Play ABC”
  • the recognized named entity is "Put AB”, which is not in the original text of the first text. This is due to the replacement of keywords. Error in identifying named entities.
  • the above-mentioned scene types are classified according to the type of terminal and/or the type of application software to which the named entity recognition model is applied.
  • the embodiment of the present application also provides an embodiment of another named entity identification method. It should be understood that for parts that are not described in detail in this embodiment, reference may be made to the specific description of the corresponding part in the foregoing embodiment.
  • the method provided in this embodiment includes the following steps 32 to 38:
  • Step 32 Obtain the first text to be recognized corresponding to this round of conversation
  • Step 34 Detect whether there is a first keyword in the first text, and the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios;
  • Step 36 If the first keyword exists in the first text, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized;
  • Step 38 Use a named entity recognition model to identify a named entity in the second text according to at least the second keyword, where the second keyword is related to the entity category corresponding to the identified named entity.
  • the named entity recognition model can be combined with the scene type applied by the named entity recognition model, and before the named entity recognition model is used to identify the named entity in the second text, the scene type applied by the named entity recognition model is obtained, At least according to the second keyword and the scene type to identify the named entity in the second text, those skilled in the art have the ability to combine the embodiments provided in the first aspect and the embodiments provided in the second aspect.
  • the method before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session Intent analysis result of the third text to obtain the intent type of the third text; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent Type, then it is detected whether there is a first keyword in the first text.
  • the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the text to be recognized to determine whether the first keyword exists in the first text.
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category of the music category is "listen” and/or "music”.
  • FIG. 4 is a schematic diagram of an optional process of a named entity identification method provided by an embodiment of the application. As shown in FIG. 4, the method includes:
  • keywords and multiple rounds of sentence patterns are collected manually or from corpus in a certain type of scene.
  • the keywords for the movie genre can be "play” and “movie”, and the keywords for the music genre can be "listen” and "song".
  • Each type of keyword collected can correspond to a special above scene.
  • the enhanced feature of named entity recognition in the use scene improves the probability of identifying related named entities.
  • movie keywords can correspond to scene types such as voice assistants on TV terminals
  • music keywords can correspond to mobile phones.
  • Scene types such as terminal music software.
  • the multi-round sentence pattern described in the embodiments of this application refers to a sentence pattern that contains incomplete intention information and needs to be supplemented by the above intention information.
  • the multi-round sentence pattern can be "as long as Iron Man”, “ Choose tomorrow”, “Change to your name”, “Choose all very well” and so on.
  • the regular expression can be ([I want only]? Want
  • the text is input into the recognition model of the named entity provided in the embodiment of the present application.
  • it can include splicing keywords and/or replacing keywords, that is, Join keywords in the original sentence, and/or replace part of the words in the original sentence with keywords.
  • the input text to be recognized is "replace your name", and after the regular expression is matched, replace it with "play your name”.
  • the recognition model of named entities first perform word segmentation processing on the replaced text to get "play/you/ ⁇ /name", mark each word segmentation index (including word index, part-of-speech index, scene index), and secondly, Each index is mapped to a vector, and after the vectors of multiple indexes of each word segmentation are spliced, the sequence labeling model is input.
  • the sequence labeling model can adopt the structure of the above-mentioned BiLSTM+CRF model.
  • each word segmentation is determined to be "O B-movie I-movie I-movie", and each label represents whether it is a named entity or a named entity.
  • the unstructured named entity is matched in the original text to be recognized to verify whether the recognized named entity exists in the original text, and to avoid combining the replaced keywords with the original text to identify a named entity that does not exist in the original text. If it exists, confirm that the identified named entity is valid.
  • FIG. 5 is a schematic diagram of another optional process of the method for identifying a named entity provided by an embodiment of the application. As shown in FIG. 5, the method is divided into two parts: a training process and a recognition process.
  • the training process is the process of training the actual named entity recognition model
  • the recognition process is the process of using the named entity recognition model.
  • the training process and the recognition process can be relatively independent, and the recognition model of the named entity trained in the training process is used as the recognition model of the named entity used in the recognition process.
  • the collected training corpus can be processed with corpus enhancement.
  • the corpus enhancement is to replace some keywords of the corpus with the above-mentioned multi-round sentence pattern to expand the processing method of the corpus.
  • the text of the corpus is "Play your name”
  • the text of the enhanced corpus is "Change your name”.
  • Corpus enhancement can be regarded as the reverse method of matching regular expressions and replacing keywords in the text to be recognized.
  • the preprocessing of the corpus includes word segmentation, knowledge extraction, part-of-speech judgment, index labeling and so on. Word segmentation is used to segment the corpus, and knowledge extraction is used to match in the corpus using a preset named entity dictionary.
  • the matched named entity can be used as known knowledge and input into the named entity recognition model for training, and part of speech judgment Used to determine the part of speech of each word segmentation, the index tagging can mark the content of the word itself (text), it can also index the part of speech tag, and it can also index the scene type and/or knowledge.
  • the corpus preprocessing can process the original corpus or the enhanced corpus, depending on the current training goal.
  • the basic model can be configured as BiLSTM+CRF model.
  • the input of the model includes at least the scene type index and the word index of each word segmentation.
  • the output is the label of the sequence label, which is the named entity label of each word.
  • the above intention or slot information can be obtained first.
  • the above intention can be recognized by the intention recognition module and the slot filling module shown in Figure 1 when processing the last round or last n rounds of sentences.
  • Out the intention and slot information you can determine whether the intention is related to the current entity.
  • the above intention is to play a movie: your name, when the text (a sentence) to be recognized is obtained in this round , You can first use the named entity dictionary to identify whether there is an entity in the current text, such as "It’s good to change it", and the TV series “very good” is matched in the named entity dictionary, indicating that the entity in the current text to be recognized is the same as the above intention Related, need to use keywords for enhancement.
  • regular expressions can also be used for direct matching. If the regular expressions cannot be matched, it means that there is no need to enhance the features of the keywords in the text to be recognized. If the regular expressions are matched, then the enhancements are performed.
  • the enhanced method is to use regular expression search to match the above-mentioned multiple rounds of sentence patterns and replace them with sentence patterns that contain keywords. For example, replace "Replace your name” with "Play your name”.
  • the index obtained after the preprocessing and the index of the scene type are input into the recognition model of the named entity to obtain the labeling sequence.
  • the labeling sequence is used to label whether each word segmentation is an entity.
  • post-processing that is, check whether the labeled named entity exists in the original text before replacement. If it does not exist, it is misrecognized. If it exists, the entity is structured and output to the subsequent Downstream modules, such as the intent recognition module and slot filling module in Figure 1.
  • the named entity recognition method provided in the embodiments of this application can use the same named entity recognition model to apply to different scenarios, and is suitable for voice recognition in the field of artificial intelligence, for example, voice assistants of terminal systems or application software, AI customer service, AI
  • the method for identifying named entities provided in the embodiments of this application is related to natural language processing technology, which can effectively identify named entities in corresponding scenarios for different scenarios, which helps to improve the semantic recognition capabilities of natural language processing and reduce collection
  • the labor cost required for the corpus improves the generalization ability of semantic recognition.
  • the embodiment of the application adds the input of the "scene type” information to the input of the named entity recognition model, so that the input value of the "scene type” can be dynamically adjusted when the named entity is recognized, so as to adjust the entity recognition result to adapt to different scenarios. Provide users with more accurate recognition results that are more in line with the application scenario.
  • the named entity recognition device 600 includes a first acquisition module 601, a first determination module 602, an input module 603, and an execution module 604.
  • the first obtaining module is used to obtain the text to be recognized; the first determining module is used to determine the scene type applied by the named entity recognition model used to recognize the named entity in the text to be recognized; the input module is used to transfer the The recognition text and scene type are input to the named entity recognition model; the execution module is used to obtain the output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
  • the device further includes: a division module, which is used to mark the content index of the text to be recognized according to the division unit before inputting the text to be recognized and the scene type into the named entity recognition model, wherein the content of the same content is indexed.
  • the division units are marked by the same content index;
  • the second determination module is used to determine the scene type index corresponding to the scene type;
  • the scene type index is marked for each division unit;
  • the input module includes: a first input unit, To input the marked index of all the division units in the text to be recognized into the named entity recognition model.
  • the named entity recognition model includes: a first conversion unit, configured to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model, and for each division unit, respectively The marked different types of indexes are converted into multi-dimensional vectors; the splicing unit is used to sequentially splice multiple multi-dimensional vectors after the conversion of different types of indexes for each division unit; the second input unit is used to convert the text to be recognized The splicing vectors of all the division units are input to the sequence labeling model; the first obtaining unit is used to obtain the output result of the sequence labeling model to obtain the labeling information of the named entity in the text to be recognized.
  • the sequence labeling model is a deep learning model
  • the deep learning model includes: one or more layers of recurrent neural networks, and each layer of recurrent neural networks uses neural network computing units to treat each segment of the recognized text in order
  • the stitching vector of the unit is calculated to output the calculation result vector corresponding to each division unit; the conditional random field is used to receive the vector sequence.
  • the vector sequence includes multiple calculation result vectors arranged in order, and multiple calculation result vectors are one layer Or the last layer of the recurrent neural network in the multi-layer recurrent neural network calculates the result vector for all the division units to output a label used to identify whether each division unit is a named entity.
  • the cyclic neural network is a long and short-term memory neural network, or a bidirectional long- and short-term memory neural network.
  • the deep learning model is a model obtained by unsupervised pre-training using corpus.
  • the device further includes: a first labeling module, configured to, before inputting the labelled index of all the division units in the text to be recognized into the named entity recognition model, for each division unit in the text to be recognized Mark the part-of-speech index; correspondingly, the index marked for each division unit of the input named entity recognition model includes the part-of-speech index.
  • a first labeling module configured to, before inputting the labelled index of all the division units in the text to be recognized into the named entity recognition model, for each division unit in the text to be recognized Mark the part-of-speech index; correspondingly, the index marked for each division unit of the input named entity recognition model includes the part-of-speech index.
  • the device further includes: a third determining module, configured to combine the text to be recognized with a preset name before inputting the index of all the division units in the text to be recognized into the named entity recognition model.
  • Entity dictionary matching is used to determine all named entities that are matched in the text to be recognized;
  • the second labeling module is used to label the knowledge index for each division unit in the text to be recognized, where the knowledge index is used to indicate that the corresponding division unit is in The information of the matched named entity in the named entity recognition model; correspondingly, the index marked for each division unit of the input named entity recognition model includes a knowledge index.
  • the device further includes: a second acquiring module, configured to acquire the first text to be recognized corresponding to the current session before inputting the text and scene type into the named entity recognition model; and detecting The module is used to detect whether the first keyword exists in the first text, the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; the replacement module is used when the first keyword exists in the first text Next, replace the first keyword in the first text with the second keyword to obtain the second text to be recognized; correspondingly, the named entity recognition model is also used to at least according to the second keyword and scene type, in the second The named entity is recognized in the text, and the second keyword is related to the entity category corresponding to the recognized named entity.
  • the device before detecting whether the first keyword exists in the first text, the device further includes: a third acquiring module, configured to acquire the first to be identified corresponding to the previous session of the current round of conversation The intent analysis result of the three texts to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type , The detection module performs detection of whether the first keyword exists in the first text.
  • a third acquiring module configured to acquire the first to be identified corresponding to the previous session of the current round of conversation The intent analysis result of the three texts to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type , The detection module performs detection of whether the first keyword exists in the first text.
  • the device further includes: a search module, which is used to search for the named entity recognition model for the second text in the first text after the named entity recognition model is used to identify the named entity in the second text. The identified named entity; the fourth determining module is used to determine that the corresponding named entity is invalid if the named entity is not found in the first text; the fifth determining module is used to determine if the named entity is found in the first text , The corresponding named entity is determined to be valid.
  • a search module which is used to search for the named entity recognition model for the second text in the first text after the named entity recognition model is used to identify the named entity in the second text. The identified named entity; the fourth determining module is used to determine that the corresponding named entity is invalid if the named entity is not found in the first text; the fifth determining module is used to determine if the named entity is found in the first text , The corresponding named entity is determined to be valid.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • the detection module includes: a matching unit, configured to perform matching in the first text by using a preset regular expression to determine whether the first keyword exists in the first text.
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; the second keyword corresponding to the entity category of the music
  • the second key word is "listening" and/or "music”.
  • the scene type is classified according to the type of terminal to which the named entity recognition model is applied and/or the type of application software.
  • the device is applied to an electronic device equipped with a sound receiver
  • the acquisition module includes: a second acquisition unit for acquiring the voice collected by the sound receiver; and a second conversion unit for converting the voice Convert to text to get the text to be recognized.
  • the named entity identification device 700 includes a first acquisition module 701, a detection module 702, a replacement module 703, and an identification module 704.
  • the first obtaining module is used to obtain the first text to be recognized corresponding to the current session; the detection module is used to detect whether there is a first keyword in the first text, and the first keyword is used to indicate the The first text is related to multiple rounds of conversation scenarios; the replacement module is used to replace the first keyword in the first text with the first keyword when the first keyword exists in the first text Two keywords to obtain the second text to be recognized; the recognition module is used to recognize named entities in the second text using a named entity recognition model at least according to the second keywords, and the second keywords are It is related to the entity category corresponding to the identified named entity.
  • the device further includes: a second obtaining module, configured to obtain the previous session correspondence of the current session before detecting whether the first keyword exists in the first text
  • the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the If the intent type of the third text is the specified intent type, the detection module performs detection of whether the first keyword exists in the first text.
  • the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text.
  • the named entity recognition model is for the named entity recognized by the second text;
  • a first determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text;
  • the second determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
  • the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
  • the second keyword is a verb and/or noun.
  • the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  • the detection module includes: a matching unit, configured to use a preset regular expression to perform matching in the text to be recognized, and determine whether the first keyword exists in the first text .
  • the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play” and/or “movie”; The second keyword corresponding to the entity category of the music category is "listen” and/or "music”.
  • the division of the various modules of the device shown in FIG. 6 or FIG. 7 is only a division of logical functions, and may be fully or partially integrated into one physical entity during actual implementation, or may be physically separated.
  • these modules can all be implemented in the form of software called by processing elements; they can also be implemented in the form of hardware; part of the modules can be implemented in the form of software called by the processing elements, and some of the modules can be implemented in the form of hardware.
  • the determination module may be a separately established processing element, or it may be integrated in a communication device, such as a certain chip of a terminal, and it may also be stored in the memory of the communication device in the form of a program.
  • the processing element calls and executes the functions of the above modules.
  • each step of the above method or each of the above modules may be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
  • the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital singnal processor, DSP), or, one or more Field Programmable Gate Array (Field Programmable Gate Array, FPGA), etc.
  • ASIC application specific integrated circuits
  • DSP digital singnal processor
  • FPGA Field Programmable Gate Array
  • the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call programs.
  • these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • SOC system-on-a-chip
  • At least one refers to one or more, and “multiple” refers to two or more.
  • “And/or” describes the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone, where A, B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an “or” relationship.
  • the following at least one item (a)” or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a).
  • at least one item (a) of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
  • the embodiments of the present application also provide a computer-readable storage medium in which a computer program is stored, and when the computer program is run on a computer, the computer executes the method described in the above-mentioned embodiment.
  • embodiments of the present application also provide a computer program product, which includes a computer program, which when running on a computer, causes the computer to execute the method described in the foregoing embodiment.
  • the computer may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium, (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Machine Translation (AREA)

Abstract

A named entity identification method and device, which are related to natural language processing (NLP) technology, can be applied to speech recognition in the field of artificial intelligence (AI), and can be specifically applied to an application, such as a voice assistant. The named entity identification method comprises: acquiring text to be identified (101); determining a scenario type used by a named entity identification model for identifying a named entity in said text (102); inputting said text and the scenario type into the named entity identification model (103); and acquiring output information of the named entity identification model to determine a named entity identified from said text by means of the named entity identification model with respect to the scenario type (104). In the method, the probability of a named entity identification model identifying a named entity under different usage scenarios is improved by means of embedding scenario information into input information of the named entity identification model.

Description

命名实体的识别方法和设备、以及计算机可读存储介质Method and device for identifying named entity, and computer readable storage medium 技术领域Technical field
本申请涉及命名实体识别技术领域,特别涉及命名实体的识别方法和设备、以及计This application relates to the technical field of named entity recognition, in particular to the method and equipment of named entity recognition, and computing
算机可读存储介质。Computer readable storage medium.
背景技术Background technique
命名实体识别,又名实体识别或NER,是自然语言处理中的一项基础任务,应用范围非常广泛。命名实体一般指的是文本中具有特定意义或者指代性强的实体,通常包括人名、地名、组织机构名、日期时间、专有名词等。NER系统就是从非结构化的输入文本中抽取出上述实体,并且可以按照业务需求识别出更多类别的实体。现有相关技术中的命名实体的识别方法,通常仅针对某种特定的应用场景训练命名实体识别模型,针对不同的场景需要采用大量对应场景下的语料进行训练,分别训练多个识别模型以适用于不同场景,训练过程复杂,模型的适应性不强。Named entity recognition, also known as entity recognition or NER, is a basic task in natural language processing and has a wide range of applications. A named entity generally refers to an entity with a specific meaning or strong referentiality in the text, which usually includes the name of a person, place name, organization name, date and time, proper nouns, etc. The NER system extracts the above entities from unstructured input text, and can identify more types of entities according to business needs. The existing named entity recognition method in the related art usually only trains the named entity recognition model for a specific application scenario. For different scenarios, a large number of corpus corresponding to the scenario needs to be used for training, and multiple recognition models are trained separately to apply. In different scenarios, the training process is complicated, and the adaptability of the model is not strong.
申请内容Application content
本申请提供了一种命名实体的识别方法和设备、以及计算机可读存储介质,以用于使命名实体识别模型能够应用在不同的场景,通过将场景信息嵌入至命名实体模型的输入信息,提高了命名实体识别模型在不同使用场景下识别出命名实体的概率。This application provides a method and device for identifying a named entity, and a computer-readable storage medium, so that the named entity recognition model can be applied to different scenarios. By embedding the scene information into the input information of the named entity model, it improves The named entity recognition model recognizes the probability of a named entity in different usage scenarios.
第一方面,本申请提供了一种命名实体的识别方法,以用于识别文本中的命名实体。命名实体(Named Entity,或简称实体)指的是文本中具有特定意义或者指代性强的实体,通常包括人名、地名、组织机构名、日期时间、专有名词等,更广泛的实体还包括数字、货币、地址等。In the first aspect, this application provides a method for identifying named entities for identifying named entities in text. Named Entity (or entity for short) refers to an entity with specific meaning or strong referentiality in the text. It usually includes the name of a person, place name, organization name, date and time, proper nouns, etc., and more extensive entities also include Numbers, currencies, addresses, etc.
本申请提供的命名实体的识别方法可以应用于正式的识别场景类型中,例如,为语音助手提供文本的命名实体识别。The method for recognizing named entities provided in this application can be applied to formal recognition scenarios, for example, to provide text-based named entity recognition for voice assistants.
本申请提供的命名实体的识别方法还可以应用于对命名实体识别模型进行训练的过程中,在应用于训练过程中时,在应用本申请提供的方法识别出训练文本中的命名实体之后,与训练文本中预先标注出的命名实体进行对比,根据对比结果调整命名实体识别模型中的参数。The method for identifying named entities provided in this application can also be applied in the process of training the named entity recognition model. When applied to the training process, after the method provided in this application is used to identify the named entities in the training text, The pre-marked named entities in the training text are compared, and the parameters in the named entity recognition model are adjusted according to the comparison results.
具体而言,第一方面提供的命名实体的识别方法包括:Specifically, the method for identifying named entities provided by the first aspect includes:
获取待识别文本;确定用于识别所述待识别文本中的命名实体的命名实体识别模型所应用的场景类型;将所述待识别文本和所述场景类型输入所述命名实体识别模型;获取所述命名实体识别模型的输出信息,以确定所述命名实体识别模型针对所述场景类型在所述待识别文本中识别出的命名实体。可选的,待识别文本可以是通过语音转换成文本之后得到的文本,也可以是预先标注有命名实体标签的训练样本文本,待识别文本可以包括中文、数字、符号、英文等字符。Obtain the text to be recognized; determine the scene type applied by the named entity recognition model used to identify the named entity in the text to be recognized; input the text to be recognized and the scene type into the named entity recognition model; obtain all Output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type. Optionally, the text to be recognized may be text obtained after voice conversion into text, or a training sample text pre-marked with named entity tags. The text to be recognized may include characters such as Chinese, numbers, symbols, and English.
命名实体识别(Named Entity Recongition,简称NER)模型(也可以称为命名实体识别系统)可以从上述待识别文本中抽取出上述命名实体,并且可以按照业务需求识别出更多类别的命名实体。命名实体识别模型可以采用现有相关技术中基于特征模板的方法、基于神经网络的方法等实施方式的模型等,在一种可选的示例中,命名实体识别模型可以采用Word Embedding(词嵌入)+LSTM(长短期记忆网络)/BiLSTM(双向长短期记忆网络)+CRF(条件随机场)的模型。The Named Entity Recongition (NER) model (also referred to as a named entity recognition system) can extract the named entity from the text to be recognized, and can identify more types of named entities according to business requirements. The named entity recognition model can use the feature template-based method and neural network-based method in the existing related technologies. In an optional example, the named entity recognition model can use Word Embedding (word embedding). +LSTM (Long Short Term Memory Network)/BiLSTM (Bidirectional Long Short Term Memory Network) + CRF (Conditional Random Field) model.
场景是命名实体识别模型所应用的实际情况,例如,命名实体识别模型应用的场景类型分类方式可以按照终端类型、和/或应用软件类型、和/或用途类型进行分类,例如,终端类型可以包括电视、手机、汽车中控台等不同类型的终端电子设备,应用软件类型可以是系统的或应用软件的种类(如电影类、音乐类等),用途类型可以分为语音助手或自动回复系统等,通过以上任意一种分类方式或多种分类方式的结合,将场景类型分为多类,例如,电视的系统语音助手的应用场景,购物类软件的自动回复系统的应用场景,等等,本申请对此不作具体限定。The scenario is the actual situation in which the named entity recognition model is applied. For example, the scenario type classification method of the named entity recognition model application can be classified according to the terminal type, and/or application software type, and/or usage type. For example, the terminal type may include Different types of terminal electronic devices such as TVs, mobile phones, car consoles, etc. The application software types can be system or application software types (such as movies, music, etc.), and the use types can be divided into voice assistants or automatic response systems, etc. , Through any one of the above classification methods or a combination of multiple classification methods, the scene types are divided into multiple categories, for example, the application scenarios of the voice assistant of the TV system, the application scenarios of the automatic reply system of the shopping software, etc. The application does not make specific restrictions on this.
上述的命名实体识别模型与相关现有技术中的命名实体识别模型不同的是,在本申请提供的方法中,除了向命名实体识别模型输入待识别文本之外,输入信息还包括命名实体识别模型所应用的场景类型信息,通过输入场景类型信息作为命名实体识别模型在训练过程和/或识别过程中的输入信息,使得命名实体识别模型能够适用不同的应用场景类型,例如,如果用户对语音助手说出“改为你的名字”,对于电视语音助手,会将“你的名字”识别为电影的名字,而对于手机语音助手,则可能不会将“你的名字”识别为电影的名字,这是由于命名实体识别模型所应用的场景类型不同,命名实体识别模型基于输入信息的场景类型信息,输出的识别结果可能会不同。The above named entity recognition model is different from the named entity recognition model in the related prior art. In the method provided in this application, in addition to inputting the text to be recognized into the named entity recognition model, the input information also includes the named entity recognition model. The applied scene type information, by inputting the scene type information as the input information in the training process and/or recognition process of the named entity recognition model, makes the named entity recognition model applicable to different application scene types, for example, if the user is interested in the voice assistant Say "change to your name". For TV voice assistants, "your name" will be recognized as the name of the movie, while for mobile voice assistants, "your name" may not be recognized as the name of the movie. This is because the named entity recognition model is applied to different scene types. The named entity recognition model is based on the scene type information of the input information, and the output recognition results may be different.
在一种可能的实施方式中,在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,所述方法还包括:将所述待识别文本按照划分单位标注内容索引,其中,内容相同的所述划分单位通过相同的内容索引进行标注;确定所述场景类型所对应的场景类型索引;针对每个所述划分单位标注所述场景类型索引,也即,每个划分单位(如每个字或每个分词)都被标注有所应用的场景类型索引。In a possible implementation manner, before inputting the to-be-recognized text and the scene type into the named entity recognition model, the method further includes: marking the to-be-recognized text in a content index according to a division unit, where , The division units with the same content are marked by the same content index; the scene type index corresponding to the scene type is determined; the scene type index is marked for each division unit, that is, each division unit ( For example, each word or each word segmentation) is marked with the scene type index to which it is applied.
相应的,所述将所述待识别文本和所述场景类型输入所述命名实体识别模型,包括:将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型。Correspondingly, the inputting the text to be recognized and the scene type into the named entity recognition model includes: inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
上述划分单位是指句子划分的基本单位,例如,对于中文,可以以单个汉字作为最基本的划分单位,也可以以执行分词处理后的词作为最基本的划分单位,其中,分词处理可以采用现有相关技术中的分词工具,如jieba分词工具等,分词处理的目标是将句子划分为多个分词,待识别文本中的每个划分单位会被标注对应的内容索引(也可以称为字索引或词索引),相同的字或词的索引是相同的,例如,“的”字的索引为15,“名字”的索引为92,等等。The above division unit refers to the basic unit of sentence division. For example, for Chinese, a single Chinese character can be used as the most basic division unit, or the word after word segmentation processing can be used as the most basic division unit. There are word segmentation tools in related technologies, such as the jieba word segmentation tool. The goal of word segmentation processing is to divide a sentence into multiple word segments. Each segmentation unit in the text to be recognized will be marked with a corresponding content index (also called a word index) Or word index), the index of the same word or word is the same, for example, the index of "的" is 15, the index of "Name" is 92, and so on.
上述场景类型所对应的场景类型索引的确定方式可以是预先人工配置,例如,根据所应用的终端设备的类型在出厂设置场景类型索引,不同类型的场景所对应的索引可以是预先配置的映射,例如,对于应用于手机终端的语音助手的应用场景,场景类型索引为1,对于应用于电视终端的语音助手的应用场景,场景类型索引为2,等等。The method for determining the scene type index corresponding to the above scene type may be manually configured in advance. For example, the scene type index is set in the factory according to the type of terminal device to be applied. The indexes corresponding to different types of scenes may be pre-configured mappings. For example, for an application scenario of a voice assistant applied to a mobile phone terminal, the scene type index is 1, for an application scenario of a voice assistant applied to a TV terminal, the scenario type index is 2, and so on.
在一种可能的实施方式中,在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之后,所述命名实体识别模型的处理方法包括:针对每个所述划分单位,分别将被标注的不同类型的索引转换为多维向量;针对每个所述划分单位,按序拼接不同类型的索引转换后的多个多维向量;获取所述序列标注模型的输出结果,以得到所述待识别文本中的命名实体的标注信息。In a possible implementation manner, after inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the processing method of the named entity recognition model includes: The division unit is to convert the different types of indexes to be labeled into multi-dimensional vectors; for each of the division units, multiple multi-dimensional vectors after the conversion of different types of indexes are sequentially spliced; and the output result of the sequence labeling model is obtained , To obtain the label information of the named entity in the text to be recognized.
可选的,将索引转换(映射)为向量可以采用相关现有技术中的词嵌入(Word Embedding)、分布式向量(Distributional Vectors)、独热(one-hot)等算法或改进的算法,将用于表示自然语言的划分单位(字或分词)的索引或其它类型的索引转换为机器能够识别的多维向量。Optionally, the conversion (mapping) of the index into a vector can use the related prior art word embedding (Word Embedding), distributed vector (Distributional Vectors), one-hot (one-hot) and other algorithms or improved algorithms. An index or other type of index used to represent the division unit (character or word segmentation) of natural language is converted into a multidimensional vector that can be recognized by the machine.
进而,在得到不同类型的索引转换后的多个多维向量之后,按照上述划分单位进行拼接。举例来说,针对每个字,将内容索引转换的向量和场景类型向量按序拼接,得到每个字的拼接向量,例如,对于“的”字,内容索引为15,转换为50维向量w1,命名实体识别模型的应用场景为手机终端的语音助手,索引为1,转换为10维向量w2,则“的”字的拼接向量为[w1,w2]。Furthermore, after obtaining multiple multi-dimensional vectors converted by different types of indexes, they are spliced according to the above-mentioned division unit. For example, for each word, the vector of content index conversion and the scene type vector are spliced in order to obtain the splicing vector of each word. For example, for the word "的", the content index is 15, which is converted into a 50-dimensional vector w1 , The application scenario of the named entity recognition model is the voice assistant of the mobile phone terminal, the index is 1, and it is converted into a 10-dimensional vector w2, then the stitching vector of the word "的" is [w1, w2].
需要说明的是,上述序列标注模型是用于执行序列标注任务的模型,在本申请中,序列标注模型的输入是多个拼接向量的序列,序列中每个拼接向量对应于对应位置的划分单位,输出是每个拼接向量对应的标签,标签用于表示对应的划分单位是否为命名实体。It should be noted that the above sequence labeling model is a model for performing sequence labeling tasks. In this application, the input of the sequence labeling model is a sequence of multiple splicing vectors, and each splicing vector in the sequence corresponds to the division unit of the corresponding position. , The output is the label corresponding to each splicing vector, and the label is used to indicate whether the corresponding division unit is a named entity.
一种可能的示例中,还可以利用不同的标签标注出命名实体类型和/或对应的划分单位是否为起始位置,例如,待识别文本为“播放你的名字”,分词结果为“播放/你/的/名字”,场景类型索引为1,将拼接向量输入序列标注模型,得到输出结果为“O B-movie I-movie I-movie”,其中,标签“O”表示对应的划分单位“播放”不是命名实体,标签“B-movie”表示对应的划分单位“你”是命名实体,类型为movie(电影),且是命名实体的起始位置,标签“I-movie”表示对应的划分单位“的”和“名字”是命名实体,类型为movie(电影),且不是命名实体的起始位置。In a possible example, different tags can also be used to indicate whether the named entity type and/or the corresponding division unit is the starting position. For example, the text to be recognized is "Play your name", and the word segmentation result is "Play/ You/的/Name", the scene type index is 1, input the splicing vector into the sequence labeling model, and the output result is "O B-movie I-movie I-movie", where the label "O" represents the corresponding division unit " "Play" is not a named entity, the label "B-movie" indicates that the corresponding division unit "you" is a named entity, the type is movie (movie), and it is the starting position of the named entity, the label "I-movie" indicates the corresponding division The units "of" and "name" are named entities, the type is movie (movie), and they are not the starting position of the named entity.
在一种可能的实施方式中,所述序列标注模型为深度学习模型,例如,RNN(循环神经网络)+CRF模型,具体的,所述深度学习模型包括一层或多层循环神经网络和条件随机场。具体而言,在一层或多层循环神经网络中,每层所述循环神经网络利用神经网络计算单元按序对所述待识别文本中每个所述划分单位的拼接向量进行计算,以输出每个所述划分单位对应的计算结果向量;条件随机场用于接收向量序列,所述向量序列包括按序排列的多个所述计算结果向量,所述多个计算结果向量为所述一层或多层循环神经网络中最后一层所述循环神经网络针对所有所述划分单位的计算结果向量,以输出用于标识每个所述划分单位是否为命名实体的标注标签。在一种可能的实施方式中,RNN可以选择LSTM或者BiLSTM。In a possible implementation, the sequence labeling model is a deep learning model, for example, RNN (cyclic neural network) + CRF model. Specifically, the deep learning model includes one or more layers of cyclic neural networks and conditions Random field. Specifically, in one or more layers of recurrent neural networks, each layer of the recurrent neural network uses a neural network calculation unit to sequentially calculate the splicing vector of each division unit in the text to be recognized to output A calculation result vector corresponding to each division unit; a conditional random field is used to receive a vector sequence, the vector sequence includes a plurality of the calculation result vectors arranged in order, and the plurality of calculation result vectors are the one layer Or, the last layer of the recurrent neural network in the multi-layer recurrent neural network calculates a result vector for all the division units to output a label used to identify whether each division unit is a named entity. In a possible implementation manner, the RNN can select LSTM or BiLSTM.
在一种可能的实施方式中,上述深度学习模型可以是利用语料进行无监督预训练得到的模型。无监督预训练是利用未标注标签的语料对模型进行训练的方式,训练方式可以是针对原语料进行编码,训练目标为在输入为编码后的原语料的情况下,模型的输出为原语料(也即,预测原语料),或者,在深度学习模型为LSTM+CRF模型的情况下,深度学习模型的训练目标可以是在输入一个词之后输出为下一个词(也即,预测下一个词)。In a possible implementation manner, the aforementioned deep learning model may be a model obtained by unsupervised pre-training using corpus. Unsupervised pre-training is a way to train the model using unlabeled corpus. The training method can be to encode the original corpus. The training goal is that when the input is the encoded original corpus, the output of the model is the original corpus ( That is, to predict the original corpus), or, in the case where the deep learning model is an LSTM+CRF model, the training goal of the deep learning model can be to input a word and output the next word (that is, predict the next word) .
在一种可能的实施方式中,在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,所述方法还包括:针对所述待识别文本中的每个所述划分单位标注词性索引,词性索引用于表示对应划分单位的词性,如,动词、名词、副词、连词等等;相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述词性索引。相应的,在将索引转换为向量时,也包括将词性索引转换为多维向量,在生成拼接向量时,针对每个划分单位,将所有类型的索引(包括内容索引、词性索引、场景索引)的向量拼接为一个向量,作为对应的划分单位的拼接向量。In a possible implementation manner, before inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, the method further includes: for each of the to-be-recognized texts. Each of the division units is marked with a part-of-speech index. The part-of-speech index is used to indicate the part-of-speech of the corresponding division unit, such as verbs, nouns, adverbs, conjunctions, etc.; correspondingly, each division unit entered into the named entity recognition model is The marked index includes the part-of-speech index. Correspondingly, when converting an index into a vector, it also includes converting a part-of-speech index into a multi-dimensional vector. When generating a splicing vector, for each division unit, all types of indexes (including content index, part-of-speech index, scene index) The vector is spliced into a vector as the splicing vector of the corresponding division unit.
在一种可能的实施方式中,在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,所述方法还包括:将所述待识别文本与预设的命名实体字典匹配,确定所述待识别文本中匹配到的所有命名实体;针对所述待识别文本中的每个所述划分单位,标注知识索引,其中,所述知识索引用于表示对应的所述划分单位在所述命名实体识别模型中所匹配到的命名实体的信息,相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述知识索引。In a possible implementation manner, before inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, the method further includes: combining the to-be-recognized text with a preset Named entity dictionary matching in the to-be-recognized text to determine all the named entities that are matched in the text to be recognized; for each of the division units in the text to be recognized, a knowledge index is marked, where the knowledge index is used to indicate the corresponding The information of the named entity matched by the division unit in the named entity recognition model, and correspondingly, the index marked for each division unit input to the named entity recognition model includes the knowledge index.
应理解,由于命名实体字典是已知的知识,将待识别文本在命名实体字典中匹配,匹配结果可以作为已知的知识输入命名实体识别模型,以提高命名实体识别模型的识别成功率,输入匹配结果信息的方式为通过知识索引标注,知识索引可以标注出命名实体的类型和/或起始位置和/或匹配次数等,例如,“你的名字”中“你”、“名字”、“你的名字”在命名实体字典中都匹配到电影名称实体,则对“你”标注索引B2-I0-movie,以表示“你”是匹配到两次作为起始位置的电影名称命名实体,对“名字”标注B1-I1-movie表示“名字”是匹配到一次作为起始位置和一次作为非起始位置的电影名称命名实体。It should be understood that since the named entity dictionary is known knowledge, the text to be recognized is matched in the named entity dictionary, and the matching result can be used as the known knowledge input into the named entity recognition model to improve the recognition success rate of the named entity recognition model. The matching result information is marked by the knowledge index. The knowledge index can mark the type and/or starting position and/or matching times of the named entity, for example, "you", "name", "in your name" "Your name" matches the movie name entity in the named entity dictionary, so mark "you" with the index B2-I0-movie to indicate that "you" is the movie name named entity that matches twice as the starting position. The "name" label B1-I1-movie indicates that the "name" is a named entity that matches the movie name once as the starting position and once as the non-starting position.
在一种可能的实施方式中,在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,所述方法还包括:获取本轮会话对应的待识别的第一文本,会话可以是语音会话或文本会话,本申请实施例所述的本轮会话是指与本申请实施例执行方相对应的另一方发出的最新一次的会话,根据本轮会话的语音或文本,得到待识别的第一文本;检测所述第一文本中是否存在第一关键词,例如,“改为”、“换成”等等,所述第一关键词用于指示所述第一文本与多轮会话场景相关,多轮会话场景是指有上下文语境的场景,例如,用户说出“请播放都挺好”,然后再说出“改为你的名字”,可选的,所述第一关键词还用于指示所述第一文本所对应的意图不完整;在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,例如,将“改为”替换为“播放”,得到待识别的第二文本;相应的,所述命名实体识别模型还用于至少根据所述第二关键词和所述场景类型,在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关,上述举例的第二关键词“播放”是与电影类的实体类别相关,命名实体识别模型接收到包含有第二关键词的第二文本,所识别出的命名实体的实体类别与第二关键词对应的实体类别相关,也即,第二关键词与识别出的命名实体的实体类别相关。In a possible implementation manner, before the text to be recognized and the scene type are input into the named entity recognition model, the method further includes: obtaining the first text to be recognized corresponding to the current round of conversation, and the conversation It can be a voice conversation or a text conversation. The current round of conversation described in the embodiment of this application refers to the latest conversation sent by another party corresponding to the executor of the embodiment of this application. According to the voice or text of the current round of conversation, the waiting session is obtained. Recognized first text; detect whether there is a first keyword in the first text, for example, "change", "replace", etc., the first keyword is used to indicate that the first text and multiple Round conversation scenes are related. Multi-round conversation scenes refer to contextual scenes. For example, the user says “please play it all well” and then “change your name”. Optionally, the first The keyword is also used to indicate that the intent corresponding to the first text is incomplete; if the first keyword exists in the first text, the first keyword in the first text is Replace with the second keyword, for example, replace “change” with “play” to obtain the second text to be recognized; correspondingly, the named entity recognition model is also used to at least according to the second keyword and the The scene type, the named entity is identified in the second text, the second keyword is related to the entity category corresponding to the identified named entity, and the second keyword "play" in the above example is related to the movie category The entity category of the named entity recognition model receives the second text containing the second keyword, and the entity category of the identified named entity is related to the entity category corresponding to the second keyword, that is, the second keyword is related to The entity category of the identified named entity is related.
在一种可能的实施方式中,在检测所述第一文本中是否存在第一关键词之前,所述方法还包括:获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型,需要说明的是,本申请实施例的执行方可以获取到对上一轮会话的意图分析结果,得到其对应的意图类型,例如,可以是搜索视频类的意图类型, 等等;判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则检测所述第一文本中是否存在第一关键词,也即,只有在上一轮意图类型是特定的一种或几种意图类型的情况下,才需要检测第一文本中是否存在第一关键词。可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定,例如,每个意图类型可以对应一个或多个关键词,在这些关键词中选择一个关键词作为第二关键词,或者,第二关键词可以是从前一轮会话中提取出的词,例如,动词(如“播放”)、或与实体类别相关的名字(如“电影”)。可选的,所述第二关键词是动词和/或名词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session In order to obtain the intent type of the third text, it should be noted that the executor of the embodiment of the present application can obtain the intent analysis result of the previous round of conversation, and obtain the corresponding intent type, for example, It can be the intent type of the search video category, etc.; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type, then detect Whether the first keyword exists in the first text, that is, it is necessary to detect whether the first keyword exists in the first text only when the intent type in the previous round is a specific one or several intent types . Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous session of the current session. For example, each intent type may correspond to one or more keywords, and one keyword is selected from these keywords. As the second keyword, or, the second keyword may be a word extracted from the previous round of conversation, for example, a verb (such as "play"), or a name related to the entity category (such as "movie"). Optionally, the second keyword is a verb and/or noun.
在一种可能的实施方式中,检测所述第一文本中是否存在第一关键词,包括:利用预设的正则表达式在所述第一文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。例如,正则表达式为([想只需]?要|选[择取出]?|[筛挑]选?|[改换变][为成]).*,其中,“[]”表示匹配到括号内的任意一个字符即可,“?”表示对应的字符是可以被舍弃的,“|”表示或者,“.*”表示任意字符串,也即,对于该正则表达式,句式“只要xxx”“选出xxx”“改成xxx”“选xxx”等都可以匹配成功。In a possible implementation manner, detecting whether the first keyword exists in the first text includes: using a preset regular expression to match in the first text, and determining whether the first text is The first keyword exists. For example, the regular expression is ([I want only]? Want|select [select out]?|[screen pick]select?|[变变变][为成]).*, where "[]" means match to Any one of the characters in the brackets is sufficient, "?" means that the corresponding character can be discarded, "|" means or, and ".*" means any character string, that is, for the regular expression, the sentence "as long as "xxx", "select xxx", "change to xxx", "select xxx", etc. can be matched successfully.
在一种可能的实施方式中,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。In a possible implementation manner, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/ Or "movie"; the second keyword corresponding to the entity category of the music category is "listening" and/or "music".
在一种可能的实施方式中,在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,所述方法还包括:在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, after the named entity recognition model is used to recognize the named entity in the second text, the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
上述实施方式的目的是,防止识别出的命名实体不在原文中。例如,第一文本为“改成ABC”,第二文本为“播放ABC”,识别出的命名实体为“放AB”,不在第一文本的原文中,这是由于在替换关键词后,导致识别命名实体错误。The purpose of the above embodiment is to prevent the identified named entity from not being in the original text. For example, the first text is "Change to ABC", the second text is "Play ABC", and the recognized named entity is "Put AB", which is not in the original text of the first text. This is due to the replacement of keywords. Error in identifying named entities.
在一种可能的实施方式中,上述场景类型根据所述命名实体识别模型所应用的终端类型和/或应用软件的类型分类。In a possible implementation manner, the above-mentioned scene types are classified according to the type of terminal and/or the type of application software to which the named entity recognition model is applied.
在一种可能的实施方式中,所述方法应用于配置有声音接收器的电子设备,如手机终端或电视终端等,所述获取待识别文本,包括:获取所述声音接收器采集到的语音,如用户发出的语音指令;将所述语音转换为文本,以得到所述待识别文本。In a possible implementation manner, the method is applied to an electronic device equipped with a sound receiver, such as a mobile phone terminal or a TV terminal, and the obtaining of the text to be recognized includes: obtaining the voice collected by the sound receiver , Such as a voice command issued by the user; convert the voice into text to obtain the text to be recognized.
第二方面,本申请还提供了一种命名实体的识别方法,该方法包括:获取本轮会话对应的待识别的第一文本;检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。需要说明的是,命名实体识别模型可以结合命名实体识别模型所应用的场景类型,在利用命名实体识别模型在所述第二文本中识别命名实体之前,获取命名实体识别模型所应用的场景类型,至少根据所述第二 关键词和所述场景类型在所述第二文本中识别命名实体,本领域技术人员有能力结合第一方面所提供的实施例和第二方面所提供的实施例。In a second aspect, the present application also provides a method for identifying named entities. The method includes: obtaining a first text to be recognized corresponding to this round of conversation; detecting whether there is a first keyword in the first text, said The first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; if the first keyword exists in the first text, the first key in the first text is Word is replaced with a second keyword to obtain the second text to be recognized; at least according to the second keyword, a named entity recognition model is used to identify a named entity in the second text, and the second keyword is the same as the The entity category corresponding to the identified named entity is related. It should be noted that the named entity recognition model can be combined with the scene type applied by the named entity recognition model, and before the named entity recognition model is used to identify the named entity in the second text, the scene type applied by the named entity recognition model is obtained, At least according to the second keyword and the scene type to identify the named entity in the second text, those skilled in the art have the ability to combine the embodiments provided in the first aspect and the embodiments provided in the second aspect.
在一种可能的实施方式中,在检测所述第一文本中是否存在第一关键词之前,所述方法还包括:获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则检测所述第一文本中是否存在第一关键词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session Intent analysis result of the third text to obtain the intent type of the third text; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent Type, then it is detected whether there is a first keyword in the first text.
在一种可能的实施方式中,在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,所述方法还包括:在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, after the named entity recognition model is used to recognize the named entity in the second text, the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,所述第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,所述第一关键词用于指示所述第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
可选的,检测所述第一文本中是否存在第一关键词包括:利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。Optionally, detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the text to be recognized to determine whether the first keyword exists in the first text.
可选的,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category of the music category is "listen" and/or "music".
第三方面,本申请提供一种命名实体的识别设备,所述设备包括:第一获取模块,用于获取待识别文本;第一确定模块,用于确定用于识别所述待识别文本中的命名实体的命名实体识别模型所应用的场景类型;输入模块,用于将所述待识别文本和所述场景类型输入所述命名实体识别模型;执行模块,用于获取所述命名实体识别模型的输出信息,以确定所述命名实体识别模型针对所述场景类型在所述待识别文本中识别出的命名实体。In a third aspect, the present application provides a device for identifying a named entity. The device includes: a first acquiring module for acquiring a text to be recognized; a first determining module for determining a device used to identify the text to be recognized The type of scene to which the named entity recognition model of the named entity is applied; an input module for inputting the text to be recognized and the type of scene into the named entity recognition model; an execution module for obtaining information about the named entity recognition model Output information to determine the named entity recognized by the named entity recognition model in the to-be-recognized text for the scene type.
在一种可能的实施方式中,所述装置还包括:划分模块,用于在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,将所述待识别文本按照划分单位标注内容索引,其中,内容相同的所述划分单位通过相同的内容索引进行标注;第二确定模块,用于确定所述场景类型所对应的场景类型索引;针对每个所述划分单位标注所述场景类型索引;相应的,所述输入模块包括:第一输入单元,用于将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型。In a possible implementation manner, the device further includes: a division module, configured to divide the text to be recognized according to a division unit before inputting the text to be recognized and the scene type into the named entity recognition model Annotated content index, wherein the division units with the same content are marked by the same content index; the second determining module is configured to determine the scene type index corresponding to the scene type; and mark the division unit for each of the division units. Scene type index; correspondingly, the input module includes: a first input unit, configured to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
在一种可能的实施方式中,所述命名实体识别模型包括:第一转换单元,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之后,针对每个所述划分单位,分别将被标注的不同类型的索引转换为多维向量;拼接单元,用于针对每个所述划分单位,按序拼接不同类型的索引转换后的多个多维向量;第二输入单元,用于将所述待识别文本中所有所述划分单位的拼接向量输入序列标注模型;第一获取单元,用于获取所述序列标注模型的输出结果,以得到所述待识别文本中的命名实体的标注信息。In a possible implementation manner, the named entity recognition model includes: a first conversion unit, configured to input the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, For each of the division units, respectively convert the marked indexes of different types into multi-dimensional vectors; a splicing unit is used for sequentially splicing multiple multi-dimensional vectors after conversion of different types of indexes for each of the division units; The second input unit is used to input the stitching vectors of all the division units in the text to be recognized into the sequence labeling model; the first obtaining unit is used to obtain the output result of the sequence labeling model to obtain the to be recognized The label information of the named entity in the text.
在一种可能的实施方式中,所述序列标注模型为深度学习模型,所述深度学习模型包括:一层或多层循环神经网络,每层所述循环神经网络利用神经网络计算单元按序对所述待识别文本中每个所述划分单位的拼接向量进行计算,以输出每个所述划分单位对应的计算结果向量;条件随机场,用于接收向量序列,所述向量序列包括按序排列的多个所述计算结果向量,所述多个计算结果向量为所述一层或多层循环神经网络中最后一层所述循环神经网络针对所有所述划分单位的计算结果向量,以输出用于标识每个所述划分单位是否为命名实体的标注标签。In a possible implementation manner, the sequence labeling model is a deep learning model, and the deep learning model includes: one or more layers of recurrent neural networks, and each layer of the recurrent neural network uses neural network computing units to sequentially pair The stitching vector of each division unit in the text to be recognized is calculated to output a calculation result vector corresponding to each division unit; a conditional random field is used to receive a vector sequence, and the vector sequence includes a sequence of The plurality of calculation result vectors are the calculation result vectors of the last layer of the recurrent neural network in the one or more layers of the recurrent neural network for all the division units for output A label to identify whether each of the division units is a named entity.
可选的,所述循环神经网络为长短期记忆神经网络、或双向长短期记忆神经网络。Optionally, the cyclic neural network is a long- and short-term memory neural network, or a bidirectional long- and short-term memory neural network.
可选的,所述深度学习模型为利用语料进行无监督预训练得到的模型。Optionally, the deep learning model is a model obtained by unsupervised pre-training using corpus.
在一种可能的实施方式中,所述装置还包括:第一标注模块,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,针对所述待识别文本中的每个所述划分单位标注词性索引;相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述词性索引。In a possible implementation manner, the device further includes: a first labeling module, configured to, before inputting the labelled indexes of all the division units in the to-be-recognized text into the named entity recognition model, target all the Each of the division units in the text to be recognized is annotated with a part-of-speech index; correspondingly, the index of each of the division units input into the named entity recognition model includes the part-of-speech index.
在一种可能的实施方式中,所述装置还包括:第三确定模块,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,将所述待识别文本与预设的命名实体字典匹配,确定所述待识别文本中匹配到的所有命名实体;第二标注模块,用于针对所述待识别文本中的每个所述划分单位,标注知识索引,其中,所述知识索引用于表示对应的所述划分单位在所述命名实体识别模型中所匹配到的命名实体的信息;相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述知识索引。In a possible implementation manner, the device further includes: a third determining module, configured to input all the marked indexes of the division units in the to-be-recognized text into the named entity recognition model. The text to be recognized is matched with a preset named entity dictionary to determine all named entities that are matched in the text to be recognized; the second tagging module is used to tag each of the division units in the text to be recognized Knowledge index, wherein the knowledge index is used to represent the information of the named entity matched by the corresponding division unit in the named entity recognition model; correspondingly, input each of the named entity recognition models The index to which the division unit is marked includes the knowledge index.
在一种可能的实施方式中,所述装置还包括:第二获取模块,用于在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,获取本轮会话对应的待识别的第一文本;检测模块,用于检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;替换模块,用于在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;相应的,所述命名实体识别模型还用于至少根据所述第二关键词和所述场景类型,在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。In a possible implementation manner, the device further includes: a second acquiring module, configured to acquire the pending session corresponding to the current round of the conversation before inputting the to-be-recognized text and the scene type into the named entity recognition model. Recognized first text; a detection module for detecting whether there is a first keyword in the first text, the first keyword for indicating that the first text is related to multiple rounds of conversation scenarios; a replacement module, using In the case where the first keyword exists in the first text, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized; corresponding , The named entity recognition model is also used to identify a named entity in the second text at least according to the second keyword and the scene type, and the second keyword is related to the identified named entity. The corresponding entity category is related.
在一种可能的实施方式中,在检测所述第一文本中是否存在第一关键词之前,所述装置还包括:第三获取模块,用于获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;判断模块,用于判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则检测模块执行检测所述第一文本中是否存在第一关键词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the device further includes: a third obtaining module, configured to obtain the previous session correspondence of the current session The intent analysis result of the third text to be recognized to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the The intent type of the third text is the specified intent type, and the detection module executes to detect whether the first keyword exists in the first text.
在一种可能的实施方式中,所述装置还包括:查找模块,用于在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;第四确定模块,用于如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;第五确定模块,用于如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text. The named entity recognition model is for a named entity recognized by the second text; a fourth determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text; The fifth determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,所述第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,所述第一关键词用于指示所述第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
在一种可能的实施方式中,所述检测模块包括:匹配单元,用于利用预设的正则表达式在所述第一文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。In a possible implementation manner, the detection module includes: a matching unit, configured to perform matching in the first text by using a preset regular expression, and determine whether the first text exists in the first text. Key words.
可选的,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category of the music category is "listen" and/or "music".
可选的,所述场景类型根据所述命名实体识别模型所应用的终端类型和/或应用软件的类型分类。Optionally, the scene type is classified according to the type of terminal to which the named entity recognition model is applied and/or the type of application software.
在一种可能的实施方式中,所述装置应用于配置有声音接收器的电子设备,所述获取模块包括:第二获取单元,用于获取所述声音接收器采集到的语音;第二转换单元,用于将所述语音转换为文本,以得到所述待识别文本。In a possible implementation manner, the device is applied to an electronic device equipped with a sound receiver, and the acquisition module includes: a second acquisition unit configured to acquire the voice collected by the sound receiver; and a second conversion The unit is used to convert the speech into text to obtain the text to be recognized.
第四方面,本申请实施例还提供了一种命名实体的识别设备,所述设备包括:第一获取模块,用于获取本轮会话对应的待识别的第一文本;检测模块,用于检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;替换模块,用于在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;识别模块,用于至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。In a fourth aspect, an embodiment of the present application also provides a device for identifying a named entity. The device includes: a first obtaining module, configured to obtain the first text to be recognized corresponding to the current session; and a detection module, configured to detect Whether there is a first keyword in the first text, the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; the replacement module is used to indicate that the first text is present in the first text In the case of a keyword, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized; the recognition module is configured to at least according to the second keyword, A named entity recognition model is used to recognize a named entity in the second text, and the second keyword is related to the entity category corresponding to the recognized named entity.
在一种可能的实施方式中,所述装置还包括:第二获取模块,用于在检测所述第一文本中是否存在第一关键词之前,获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;判断模块,用于判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则所述检测模块执行检测所述第一文本中是否存在第一关键词。In a possible implementation manner, the device further includes: a second obtaining module, configured to obtain the previous session correspondence of the current session before detecting whether the first keyword exists in the first text The intent analysis result of the third text to be recognized to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the If the intent type of the third text is the specified intent type, the detection module performs detection of whether the first keyword exists in the first text.
在一种可能的实施方式中,所述装置还包括:查找模块,用于在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;第一确定模块,用于如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;第二确定模块,用于如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text. The named entity recognition model is for the named entity recognized by the second text; a first determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text; The second determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,所述第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,所述第一关键词用于指示所述第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
在一种可能的实施方式中,所述检测模块包括:匹配单元,用于利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。In a possible implementation manner, the detection module includes: a matching unit, configured to use a preset regular expression to perform matching in the text to be recognized, and determine whether the first keyword exists in the first text .
可选的,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category of the music category is "listen" and/or "music".
第五方面,本申请提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第一方面所述的方法。In a fifth aspect, the present application provides a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer executes the method as described in the first aspect.
第六方面,本申请提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第二方面所述的方法。In a sixth aspect, the present application provides a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer executes the method described in the second aspect.
第七方面,本申请提供一种计算机程序,当所述计算机程序被计算机执行时,用于执行第一方面所述的方法。In a seventh aspect, the present application provides a computer program, when the computer program is executed by a computer, it is used to execute the method described in the first aspect.
第八方面,本申请提供一种计算机程序,当所述计算机程序被计算机执行时,用于执行第二方面所述的方法。In an eighth aspect, the present application provides a computer program, when the computer program is executed by a computer, it is used to execute the method described in the second aspect.
在一种可能的实施方式中,第七方面或第八方面中的程序可以全部或者部分存储在与处理器封装在一起的存储介质上,也可以部分或者全部存储在不与处理器封装在一起的存储器上。In a possible implementation manner, the program in the seventh aspect or the eighth aspect may be stored in whole or in part on a storage medium that is packaged with the processor, or may be stored in part or all in a storage medium that is not packaged with the processor. On the memory.
第九方面,本申请提供一种命名实体的识别设备,所述设备包括:一个或多个处理器;存储器;多个应用程序;以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述设备执行时,使得所述设备执行如第一方面所述的方法。In a ninth aspect, this application provides a named entity identification device, the device comprising: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computers A program is stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the method as described in the first aspect.
第十方面,本申请提供一种命名实体的识别设备,所述设备包括:一个或多个处理器;存储器;多个应用程序;以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述设备执行时,使得所述设备执行如第二方面所述的方法。In a tenth aspect, the present application provides a named entity identification device, the device includes: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computers A program is stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the method as described in the second aspect.
可见,在以上各个方面,通过将场景信息嵌入至命名实体模型的输入信息,提高了命名实体识别模型在不同使用场景下识别出命名实体的概率。It can be seen that in the above aspects, by embedding the scene information into the input information of the named entity model, the probability of the named entity recognition model identifying the named entity in different usage scenarios is improved.
附图说明Description of the drawings
图1为本申请实施例提供的一种应用场景示意图;FIG. 1 is a schematic diagram of an application scenario provided by an embodiment of the application;
图2为本申请提供的一种命名实体的识别方法的流程示意图;FIG. 2 is a schematic flowchart of a method for identifying named entities provided by this application;
图3为本申请提供的一种命名实体的识别模型的结构示意图;Figure 3 is a schematic structural diagram of a named entity recognition model provided by this application;
图4为本申请提供的另一种命名实体的识别方法的流程示意图;FIG. 4 is a schematic flowchart of another method for identifying named entities provided by this application;
图5为本申请提供的另一种命名实体的识别方法的流程示意图;FIG. 5 is a schematic flowchart of another method for identifying named entities provided by this application;
图6为本申请实施例提供的一种命名实体的识别设备的结构示意图;FIG. 6 is a schematic structural diagram of a named entity identification device provided by an embodiment of this application;
图7为本申请实施例提供的另一种命名实体的识别设备的结构示意图。FIG. 7 is a schematic structural diagram of another named entity identification device provided by an embodiment of this application.
具体实施方式Detailed ways
本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。本申请提供的一些实施例可以应用于人工智能(Artificial Intelligence,简称AI)领域的语音识别,和自然语言处理(Natural Language Processing,简称NLP)技术相关,具体可以应用于语音助手等应用。The terminology used in the implementation mode part of this application is only used to explain the specific embodiments of this application, and is not intended to limit this application. Some embodiments provided in this application can be applied to speech recognition in the field of artificial intelligence (AI), related to natural language processing (NLP) technology, and can be specifically applied to applications such as voice assistants.
下面将结合附图,对本申请中的技术方案进行描述。The technical solution in this application will be described below in conjunction with the accompanying drawings.
本申请提供了一种命名实体的识别方法,以用于识别文本中的命名实体。命名实体(Named Entity,或简称实体)指的是文本中具有特定意义或者指代性强的实体,通常包括人名、地名、组织机构名、日期时间、专有名词等,更广泛的实体还包括数字、货币、地址等。This application provides a method for identifying named entities to identify named entities in text. Named Entity (or entity for short) refers to an entity with specific meaning or strong referentiality in the text. It usually includes the name of a person, place name, organization name, date and time, proper nouns, etc., and more extensive entities also include Numbers, currencies, addresses, etc.
本申请提供的命名实体的识别方法可以应用于正式的识别场景类型中,例如,为人工智能的语音助手提供文本的命名实体识别。如图1所示,提供了一种应用于语音助手的系统架构,用户通过车载终端、电脑终端、手机终端等终端进入语音助手的模式,语音助手获取语音,并利用自动语音识别技术(Automatic Speech Recognition,简称ASR)模块将语音转换为文本,将文本输入对话管理(Dialog Management,简称DM)模块,由对话管理模块将文本分发给自然语言理解(Natural Language Understand,简称NLU)模块,NLU模块接收到当前句以及上文之后,针对当前句执行命名实体识别,可选的,命名实体识别模块执行本申请实施例提供的命名实体的识别方法的一个示例,包括分词、词性标注、命名实体标注(本申请提供的命名实体的识别方法中的序列标注模型)等模块,此外,还包括意图识别分类、槽位填充等模块,以理解文本中的语义,进而NLU模块将分析结果返回给DM模块,DM模块进而根据识别出的语义利用自然语言生成(Natural Language Generation,简称NLG)模块生成回复的对话文本,回复的对话文本由语音合成(Text-To-Speech)模块生成语音,播报给用户。在如图1所示的三种应用场景(车载终端的语音助手、电脑终端的语音助手、手机终端的语音助手)中,针对不同的应用场景进行命名实体的识别结果可能是不同的,导致终端对用户发出指令的响应也不同,例如,“换成你的名字”未识别出命名实体,对于手机的语音助手是闲聊,而对于电视语音助手,识别出命名实体为电影“你的名字”,语音助手则切换为电影“你的名字”。The method for recognizing named entities provided in this application can be applied to formal recognition scenarios, for example, to provide text-based named entity recognition for artificial intelligence voice assistants. As shown in Figure 1, a system architecture applied to voice assistants is provided. Users enter the voice assistant mode through vehicle-mounted terminals, computer terminals, and mobile phone terminals. The voice assistant obtains voice and uses automatic speech recognition technology (Automatic Speech Recognition). The Recognition (ASR) module converts speech into text, and the text is input into the Dialog Management (DM) module, and the dialog management module distributes the text to the Natural Language Understand (NLU) module, and the NLU module receives it To the current sentence and beyond, perform named entity recognition for the current sentence. Optionally, the named entity recognition module executes an example of the named entity recognition method provided in the embodiment of this application, including word segmentation, part-of-speech tagging, and named entity tagging ( The sequence labeling model in the named entity recognition method provided by this application, in addition, also includes modules such as intention recognition classification, slot filling, etc., to understand the semantics in the text, and then the NLU module returns the analysis result to the DM module. The DM module then uses the Natural Language Generation (NLG) module to generate the reply dialogue text according to the recognized semantics, and the reply dialogue text is generated by the speech synthesis (Text-To-Speech) module and broadcast to the user. In the three application scenarios shown in Figure 1 (Voice Assistant for Vehicle Terminals, Voice Assistant for Computer Terminals, and Voice Assistant for Mobile Phone Terminals), the recognition results of named entities for different application scenarios may be different, leading to the terminal The response to the user’s instructions is also different. For example, "Change to your name" does not recognize the named entity, for mobile phone voice assistants, it is small chat, and for TV voice assistants, the named entity is recognized as the movie "Your Name". The voice assistant switches to the movie "Your Name".
本申请提供的命名实体的识别方法还可以应用于对命名实体识别模型进行训练的场景中,在应用于训练过程中时,在应用本申请提供的方法识别出训练文本中的命名实体之后,与训练文本中预先标注出的命名实体进行对比,根据对比结果调整命名实体识别模型中的参数。The method for recognizing named entities provided in this application can also be applied to a scenario where a named entity recognition model is trained. When applied to the training process, after the method provided in this application is used to identify the named entity in the training text, and The pre-marked named entities in the training text are compared, and the parameters in the named entity recognition model are adjusted according to the comparison results.
下面结合图2对本申请实施例的命名实体的识别方法进行详细的介绍。图2所示的方法包括步骤101~步骤104,下面分别对这些步骤进行详细的描述。The following describes the method for identifying a named entity in an embodiment of the present application in detail with reference to FIG. 2. The method shown in FIG. 2 includes steps 101 to 104, and these steps are respectively described in detail below.
步骤101,获取待识别文本。Step 101: Obtain the text to be recognized.
可选的,待识别文本可以是通过语音转换成文本之后得到的文本,也可以是预先标注有命名实体标签的训练样本文本,待识别文本可以包括中文、数字、符号、英文等字符。Optionally, the text to be recognized may be text obtained after voice conversion into text, or a training sample text pre-marked with named entity tags. The text to be recognized may include characters such as Chinese, numbers, symbols, and English.
一种可选的示例中,本申请实施例提供的命名实体的识别方法应用于配置有声音接收器的电子设备,该电子设备具体可以是移动终端(例如,智能手机),电脑,个人数字助理,可穿戴设备,车载设备,物联网设备或者其他能够接收声音的电子设备。在该示例中,声音接收器采集到的语音经过如图1所示的语音转文本模块转换为文本,得到待识别文本。In an optional example, the method for identifying a named entity provided in the embodiment of the present application is applied to an electronic device equipped with a sound receiver. The electronic device may specifically be a mobile terminal (for example, a smart phone), a computer, or a personal digital assistant. , Wearable devices, in-vehicle devices, Internet of Things devices or other electronic devices that can receive sound. In this example, the voice collected by the sound receiver is converted into text by the voice-to-text module shown in FIG. 1 to obtain the text to be recognized.
步骤102,确定用于识别待识别文本中的命名实体的命名实体识别模型所应用的场景类型。Step 102: Determine the scene type to which the named entity recognition model used to recognize the named entity in the text to be recognized is applied.
命名实体识别(Named Entity Recongition,简称NER)模型(也可以称为命名实体识别系统)可以从上述待识别文本中抽取出上述命名实体,并且可以按照业务需求识别出更多类别的命名实体。命名实体识别模型可以采用现有相关技术中基于特征模板的方法、基于神经网络的方法等实施方式的模型等,在一种可选的示例中,命名实体识别模型可以采用Word Embedding(词嵌入)+LSTM(长短期记忆网络)/BiLSTM(双向长短期记忆网络)+CRF(条件随机场)的模型。The Named Entity Recongition (NER) model (also referred to as a named entity recognition system) can extract the named entity from the text to be recognized, and can identify more types of named entities according to business requirements. The named entity recognition model can use the feature template-based method and neural network-based method in the existing related technologies. In an optional example, the named entity recognition model can use Word Embedding (word embedding). +LSTM (Long Short Term Memory Network)/BiLSTM (Bidirectional Long Short Term Memory Network) + CRF (Conditional Random Field) model.
本申请中,场景是指需要命名实体识别模型去识别命名实体的业务需求场合,场景类型可以根据命名实体识别模型所应用的终端类型和/或应用软件类型的不同,分为不同种类。例如,终端可以包括电视、手机、汽车中控台等不同类型的终端电子设备,应用软件可以是系统级别、或终端的操作系统中安装的应用软件的种类(如视频类、音乐类等),用途类型可以分为语音助手或自动回复系统等,通过以上任意一种分类方式或多种分类方式的结合,可以将场景类型分为多类,例如,电视的系统语音助手,购物类软件的人工智能客服,视频类应用软件的语音助手,智能家用电器的人工智能语音助手等多种应用场景,本申请对具体将场景分为哪几类不作具体限定,可以根据实际情况而配置。In this application, a scenario refers to a business requirement scenario that requires a named entity recognition model to identify a named entity. The scenario type can be divided into different types according to the terminal type and/or application software type to which the named entity recognition model is applied. For example, the terminal may include different types of terminal electronic equipment such as televisions, mobile phones, and car consoles. The application software may be at the system level or the type of application software installed in the terminal's operating system (such as video, music, etc.). Use types can be divided into voice assistants or automatic response systems, etc. Through any one of the above classification methods or a combination of multiple classification methods, the scene types can be divided into multiple categories, for example, voice assistants for TV systems, manuals for shopping software There are multiple application scenarios such as smart customer service, voice assistants for video applications, and artificial intelligence voice assistants for smart home appliances. This application does not specifically limit the specific categories of scenarios into which they can be configured according to actual conditions.
步骤103,将待识别文本和场景类型输入命名实体识别模型。Step 103: Input the text to be recognized and the scene type into the named entity recognition model.
步骤104,获取所述命名实体识别模型的输出信息,以确定所述命名实体识别模型针对所述场景类型在所述待识别文本中识别出的命名实体。Step 104: Obtain output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
本申请实施例所述的命名实体识别模型与相关现有技术中的命名实体识别模型不同的是,在本申请提供的方法中,除了向命名实体识别模型输入待识别文本之外,输入信息还包括命名实体识别模型所应用的场景类型信息,通过输入场景类型信息作为命名实体识别模型在训练过程和/或识别过程中的输入信息,使得命名实体识别模型能够适用不同的应用场景类型,例如,如果用户对语音助手说出“改为你的名字”,对于电视语音助手,会将“你的名字”识别为电影的名字,而对于手机语音助手,则可能不会将“你的名字”识别为电影的名字,这是由于命名实体识别模型所应用的场景类型不同,命名实体识别模型基于输入信息的场景类型信息,输出的识别结果可能会不同。The difference between the named entity recognition model described in the embodiments of this application and the named entity recognition model in the related prior art is that in the method provided in this application, in addition to inputting the text to be recognized into the named entity recognition model, the input information is also Including the scene type information applied by the named entity recognition model. By inputting the scene type information as the input information in the training process and/or recognition process of the named entity recognition model, the named entity recognition model can be applied to different application scene types, for example, If the user says "change your name" to the voice assistant, the TV voice assistant will recognize "your name" as the name of the movie, while for the mobile phone voice assistant, it may not recognize "your name" It is the name of the movie. This is because the named entity recognition model uses different scene types. The named entity recognition model is based on the scene type information of the input information, and the output recognition results may be different.
在一种可选的实施方式中,在执行步骤103之前,将待识别文本和场景类型输入命名实体识别模型之前,该方法还包括执行如下步骤11~步骤13:In an optional implementation manner, before step 103 is performed, before the text to be recognized and the scene type are input into the named entity recognition model, the method further includes performing the following steps 11 to 13:
步骤11,将待识别文本按照划分单位标注内容索引,其中,内容相同的划分单位通过相同的内容索引进行标注。Step 11: Mark the content index of the text to be recognized according to the division unit, wherein the division units with the same content are marked by the same content index.
上述划分单位是指句子划分的基本单位,例如,对于中文,可以以单个汉字作为最基本的划分单位,也可以以执行分词处理后的词作为最基本的划分单位,其中,分词处理可以采用现有相关技术中的分词工具,如jieba分词工具等,分词处理的目标是将句子划分为多个分词,待识别文本中的每个划分单位会被标注对应的内容索引(也可以称为字索引或词索引),相同的字或词的索引是相同的,例如,“的”字的索引为15,“名字”的索引为92,等等。The above division unit refers to the basic unit of sentence division. For example, for Chinese, a single Chinese character can be used as the most basic division unit, or the word after word segmentation processing can be used as the most basic division unit. There are word segmentation tools in related technologies, such as the jieba word segmentation tool. The goal of word segmentation processing is to divide a sentence into multiple word segments. Each segmentation unit in the text to be recognized will be marked with a corresponding content index (also called a word index) Or word index), the index of the same word or word is the same, for example, the index of "的" is 15, the index of "Name" is 92, and so on.
步骤12,确定场景类型所对应的场景类型索引。Step 12: Determine the scene type index corresponding to the scene type.
上述场景类型所对应的场景类型索引的确定方式可以是预先人工配置,例如,根据所应用的终端设备的类型在出厂设置场景类型索引,不同类型的场景所对应的索引可以是预先配置的映射,例如,对于应用于手机终端的语音助手的应用场景,场景类型索引为1,对于应用于电视终端的语音助手的应用场景,场景类型索引为2,等等。可选的,场景类型索引可以是浮点型float数据,例如,通用场景的索引为0,高召回率场景的索引为1.0,从而可以通过调整场景类型索引在0~1之间变化,使得命名实体识别模型主动迁移到新的场景。The method for determining the scene type index corresponding to the above scene type may be manually configured in advance. For example, the scene type index is set in the factory according to the type of terminal device to be applied. The indexes corresponding to different types of scenes may be pre-configured mappings. For example, for an application scenario of a voice assistant applied to a mobile phone terminal, the scene type index is 1, for an application scenario of a voice assistant applied to a TV terminal, the scenario type index is 2, and so on. Optionally, the scene type index can be floating-point float data. For example, the index of general scenes is 0, and the index of high recall scenes is 1.0, so that the scene type index can be adjusted to change between 0 and 1 to make the naming The entity recognition model is actively migrated to the new scene.
步骤13,针对每个划分单位标注场景类型索引。Step 13: Mark the scene type index for each division unit.
也即,每个划分单位(如每个字或每个分词)都被标注有所应用的场景类型索引。That is, each division unit (for example, each word or each word segmentation) is marked with an applied scene type index.
相应的,步骤103将待识别文本和场景类型输入命名实体识别模型,包括:Correspondingly, step 103 inputs the text to be recognized and the scene type into the named entity recognition model, including:
步骤14,将待识别文本中所有划分单位被标注的索引输入命名实体识别模型。 Step 14. Input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
进一步的,在执行步骤14将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之后,命名实体识别模型的处理方法可以包括如下步骤21~步骤23:Further, after performing step 14 to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the processing method of the named entity recognition model may include the following steps 21 to 23:
步骤21,针对每个划分单位,分别将被标注的不同类型的索引转换为多维向量。Step 21: For each division unit, convert the marked indexes of different types into multi-dimensional vectors.
步骤22,针对每个划分单位,按序拼接不同类型的索引转换后的多个多维向量。Step 22: For each division unit, a plurality of multi-dimensional vectors converted by different types of indexes are sequentially spliced.
步骤23,获取序列标注模型的输出结果,以得到待识别文本中的命名实体的标注信息。Step 23: Obtain the output result of the sequence annotation model to obtain the annotation information of the named entity in the text to be recognized.
可选的,将索引转换(映射)为向量可以采用相关现有技术中的词嵌入(Word Embedding)、分布式向量(Distributional Vectors)、独热(one-hot)等算法或改进的算法,将用于表示自然语言的划分单位(字或分词)的索引或其它类型的索引转换为机器能够识别的多维向量。Optionally, the conversion (mapping) of the index into a vector can use the related prior art word embedding (Word Embedding), distributed vector (Distributional Vectors), one-hot (one-hot) and other algorithms or improved algorithms. An index or other type of index used to represent the division unit (character or word segmentation) of natural language is converted into a multidimensional vector that can be recognized by the machine.
进而,在得到不同类型的索引转换后的多个多维向量之后,按照上述划分单位进行拼接。举例来说,针对每个字,将内容索引转换的向量和场景类型向量按序拼接,得到每个字的拼接向量,例如,对于“的”字,内容索引为15,转换为50维向量w1,命名实体识别模型的应用场景为手机终端的语音助手,索引为1,转换为20维向量w2,则“的”字的拼接向量为[w1,w2]。Furthermore, after obtaining multiple multi-dimensional vectors converted by different types of indexes, they are spliced according to the above-mentioned division unit. For example, for each word, the vector of content index conversion and the scene type vector are spliced in order to obtain the splicing vector of each word. For example, for the word "的", the content index is 15, which is converted into a 50-dimensional vector w1 , The application scenario of the named entity recognition model is the voice assistant of the mobile phone terminal, the index is 1, and it is converted into a 20-dimensional vector w2, then the stitching vector of the word "的" is [w1, w2].
需要说明的是,上述序列标注模型是用于执行序列标注任务的模型,在本申请中,序列标注模型的输入是多个拼接向量的序列,序列中每个拼接向量对应于对应位置的划分单位,输出是每个拼接向量对应的标签,标签用于表示对应的划分单位是否为命名实体。It should be noted that the above sequence labeling model is a model for performing sequence labeling tasks. In this application, the input of the sequence labeling model is a sequence of multiple splicing vectors, and each splicing vector in the sequence corresponds to the division unit of the corresponding position. , The output is the label corresponding to each splicing vector, and the label is used to indicate whether the corresponding division unit is a named entity.
一种可选的示例中,还可以利用不同的标签标注出命名实体类型和/或对应的划分单位是否为起始位置,例如,待识别文本为“播放你的名字”,分词结果为“播放/你/的/名字”,场景类型索引为1,将拼接向量输入序列标注模型,得到输出结果为“O B-movie I-movie I-movie”,其中,标签“O”表示对应的划分单位“播放”不是命名实体,标签“B-movie”表示对应的划分单位“你”是命名实体,类型为movie(电影),且是命名实体的起始位置,标签“I-movie”表示对应的划分单位“的”和“名字”是命名实体,类型为movie(电影),且不是命名实体的起始位置。In an optional example, different tags can also be used to mark whether the named entity type and/or the corresponding division unit is the starting position. For example, the text to be recognized is "Play your name", and the word segmentation result is "Play /你/的/name", the scene type index is 1, input the splicing vector into the sequence labeling model, and the output result is "O B-movie I-movie I-movie", where the label "O" represents the corresponding division unit "Play" is not a named entity, the label "B-movie" indicates that the corresponding division unit "you" is a named entity, the type is movie (movie), and it is the starting position of the named entity, and the label "I-movie" indicates the corresponding The division unit "of" and "name" are named entities, the type is movie, and they are not the starting position of the named entity.
可选的,输入至命名实体识别模型的输入信息还可以包括词性索引和/或知识索引。Optionally, the input information input to the named entity recognition model may also include part-of-speech index and/or knowledge index.
在一种可选的实施方式中,在将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之前,该方法还包括:针对待识别文本中的每个划分单位标注词性索引,词性索引用于表示对应划分单位的词性,如,动词、名词、副词、连词等等;相应的,输入命名实体识别模型的每个划分单位被标注的索引包括词性索引。相应的,在将索引转换为向量时,也包括将词性索引转换为多维向量,在生成拼接向量时,针对每个划分单位,将所有类型的索引(包括内容索引、词性索引、场景索引)的向量拼接为一个向量,作为对应的划分单位的拼接向量。In an optional implementation manner, before inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the method further includes: marking the part-of-speech index for each division unit in the text to be recognized. The index is used to indicate the part-of-speech of the corresponding division unit, such as verb, noun, adverb, conjunction, etc.; correspondingly, the index marked for each division unit input to the named entity recognition model includes a part-of-speech index. Correspondingly, when converting an index into a vector, it also includes converting a part-of-speech index into a multi-dimensional vector. When generating a splicing vector, for each division unit, all types of indexes (including content index, part-of-speech index, scene index) The vector is spliced into a vector as the splicing vector of the corresponding division unit.
在一种可选的实施方式中,在将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之前,该方法还包括:将待识别文本与预设的命名实体字典匹配,确定待识别文本中匹配到的所有命名实体;针对待识别文本中的每个划分单位,标注知识索引,其 中,知识索引用于表示对应的划分单位在命名实体识别模型中所匹配到的命名实体的信息,相应的,输入命名实体识别模型的每个划分单位被标注的索引包括知识索引。In an optional implementation manner, before inputting the marked indexes of all the division units in the text to be recognized into the named entity recognition model, the method further includes: matching the text to be recognized with a preset named entity dictionary to determine the Recognize all named entities that are matched in the text; label a knowledge index for each division unit in the text to be recognized, where the knowledge index is used to indicate the information of the named entity matched by the corresponding division unit in the named entity recognition model Correspondingly, the index marked for each division unit of the input named entity recognition model includes a knowledge index.
应理解,由于命名实体字典是已知的知识,将待识别文本在命名实体字典中匹配,匹配结果可以作为已知的知识输入命名实体识别模型,以提高命名实体识别模型的识别成功率,输入匹配结果信息的方式为通过知识索引标注,知识索引可以标注出命名实体的类型和/或起始位置和/或匹配次数等,例如,“你的名字”中“你”、“名字”、“你的名字”在命名实体字典中都匹配到电影名称实体,则对“你”标注索引B2-I0-movie,以表示“你”是匹配到两次作为起始位置的电影名称命名实体,对“名字”标注B1-I1-movie表示“名字”是匹配到一次作为起始位置和一次作为非起始位置的电影名称命名实体。It should be understood that since the named entity dictionary is known knowledge, the text to be recognized is matched in the named entity dictionary, and the matching result can be used as the known knowledge input into the named entity recognition model to improve the recognition success rate of the named entity recognition model. The matching result information is marked by the knowledge index. The knowledge index can mark the type and/or starting position and/or matching times of the named entity, for example, "you", "name", "in your name" "Your name" matches the movie name entity in the named entity dictionary, so mark "you" with the index B2-I0-movie to indicate that "you" is the movie name named entity that matches twice as the starting position. The "name" label B1-I1-movie indicates that the "name" is a named entity that matches the movie name once as the starting position and once as the non-starting position.
在一种可选的实施方式中,序列标注模型为深度学习模型,例如,RNN(循环神经网络)+CRF模型。具体的,深度学习模型包括一层或多层循环神经网络和条件随机场。In an alternative embodiment, the sequence labeling model is a deep learning model, for example, an RNN (recurrent neural network) + CRF model. Specifically, the deep learning model includes one or more layers of recurrent neural networks and conditional random fields.
具体而言,在一层或多层循环神经网络中,每层循环神经网络利用神经网络计算单元按序对待识别文本中每个划分单位的拼接向量进行计算,以输出每个划分单位对应的计算结果向量。Specifically, in one or more layers of recurrent neural networks, each layer of recurrent neural network uses neural network computing units to calculate the stitching vector of each division unit in the recognized text in order to output the calculation corresponding to each division unit The result vector.
条件随机场用于接收向量序列,向量序列包括按序排列的多个计算结果向量,多个计算结果向量为一层或多层循环神经网络中最后一层循环神经网络针对所有划分单位的计算结果向量,以输出用于标识每个划分单位是否为命名实体的标注标签。The conditional random field is used to receive the vector sequence. The vector sequence includes multiple calculation result vectors arranged in order. The multiple calculation result vectors are the calculation results of the last layer of the recurrent neural network in one or more layers of the recurrent neural network for all division units. Vector to output a label used to identify whether each division unit is a named entity.
在一种可选的实施方式中,RNN可以选择LSTM或者BiLSTM。LSTM(Long Short-Term Memory,长短期记忆)模型,是RNN(Recurrent Neural Network,循环神经网络)的一种。BiLSTM(Bi-directional Long Short-Term Memory,双向长短期记忆)模型是由前向LSTM与后向LSTM组合而成。LSTM和BiLSTM两者在自然语言处理任务中都常被用来建模上下文信息。In an alternative implementation manner, the RNN can select LSTM or BiLSTM. The LSTM (Long Short-Term Memory) model is a type of RNN (Recurrent Neural Network). BiLSTM (Bi-directional Long Short-Term Memory) model is a combination of forward LSTM and backward LSTM. Both LSTM and BiLSTM are often used to model contextual information in natural language processing tasks.
图3为采用BiLSTM+CRF的命名实体识别模型的一个示例的结构示意图。如图3所示,命名实体识别模型300包括向量转换模块,向量拼接模块和序列标注模块301,序列标注模块301包括双向长短期记忆BiLSTM和CRF。向量转换模块的输入为每个词(划分单位)的各类索引,包括场景(类型)索引、词性索引和词的(内容)索引,向量转换模块利用Word embedding技术将各个索引分别映射为向量,向量拼接模块将每个划分单位的多个向量拼接在一起,输入BiLSTM,BiLSTM包括一层前向LSTM网络和一层后向LSTM网络,每层LSTM网络包括多个重复的LSTM神经单元,每个神经单元用于计算输入的向量。针对每个划分单位,将前向LSTM神经单元和后向LSTM神经单元的输出拼接在一起,得到对应划分单位的计算结果向量,将所有计算结果向量按序排列为向量序列,输入CRF,得到最后输出的标签t1,t2……,每个标签用于表示对应的划分单位是否属于命名实体,还可以标识出对应的划分单位在命名实体中是否处于起始位置。Fig. 3 is a schematic structural diagram of an example of a named entity recognition model using BiLSTM+CRF. As shown in FIG. 3, the named entity recognition model 300 includes a vector conversion module, a vector splicing module, and a sequence labeling module 301. The sequence labeling module 301 includes bidirectional long and short-term memory BiLSTM and CRF. The input of the vector conversion module is various indexes of each word (division unit), including scene (type) index, part-of-speech index, and word (content) index. The vector conversion module uses Word embedding technology to map each index into a vector. The vector stitching module stitches together multiple vectors of each division unit, and inputs BiLSTM. BiLSTM includes a forward LSTM network and a backward LSTM network. Each layer of LSTM network includes multiple repeated LSTM neural units. The neural unit is used to calculate the input vector. For each division unit, splice the outputs of the forward LSTM neural unit and the backward LSTM neural unit together to obtain the calculation result vector of the corresponding division unit, arrange all the calculation result vectors in order into a vector sequence, input the CRF, and get the final The output tags t1, t2..., each tag is used to indicate whether the corresponding division unit belongs to a named entity, and can also identify whether the corresponding division unit is at the starting position in the named entity.
在一种可选的实施方式中,利用了迁移学习的原理,将利用语料进行无监督预训练得到的模型作为上述深度学习模型。迁移学习是一种机器学习方法,指的是一个预训练的模型被重新用在另一个任务中,例如,把为任务A开发的模型作为初始点,重新使用在为任务B开发模型的过程中。在本申请实施例中,无监督预训练是利用未标注标签的语料对模型进行训练的方式,例如,无监督预训练的任务可以是以下任意一种:In an optional implementation manner, the principle of transfer learning is used, and a model obtained by unsupervised pre-training using corpus is used as the aforementioned deep learning model. Transfer learning is a machine learning method that refers to a pre-trained model being reused in another task. For example, the model developed for task A is used as the initial point and reused in the process of developing the model for task B . In the embodiment of this application, unsupervised pre-training is a way to train the model using unlabeled corpus. For example, the task of unsupervised pre-training can be any of the following:
1)利用序列的自动编码器(autoencoder)对原序列编码,将编码后的序列输入至深度学习模型,以预测原序列;1) Use the autoencoder of the sequence to encode the original sequence, and input the encoded sequence into the deep learning model to predict the original sequence;
2)在采用LSTM+CRF模型的情况下,训练的任务为传统的语言模型任务:预测下一个词。2) In the case of the LSTM+CRF model, the training task is the traditional language model task: predict the next word.
在一种可选的实施方式中,在将待识别文本和场景类型输入命名实体识别模型之前,该方法还包括:获取本轮会话对应的待识别的第一文本,会话可以是语音会话或文本会话,本申请实施例的本轮会话是指与本申请实施例执行方相对应的另一方发出的最新一次的会话,根据本轮会话的语音或文本,得到待识别的第一文本;检测第一文本中是否存在第一关键词,例如,“改为”、“换成”等等,第一关键词用于指示第一文本与多轮会话场景相关,多轮会话场景是指有上下文语境的场景,例如,用户说出“请播放都挺好”,然后再说出“改为你的名字”,可选的,第一关键词还用于指示第一文本所对应的意图不完整;在第一文本中存在第一关键词的情况下,将第一文本中的第一关键词替换为第二关键词,例如,将“改为”替换为“播放”,得到待识别的第二文本;相应的,命名实体识别模型还用于至少根据第二关键词和场景类型,在第二文本中识别命名实体,第二关键词与识别出的命名实体所对应的实体类别相关,上述举例的第二关键词“播放”是与电影类的实体类别相关,命名实体识别模型接收到包含有第二关键词的第二文本,所识别出的命名实体的实体类别与第二关键词对应的实体类别相关,也即,第二关键词与识别出的命名实体的实体类别相关。In an optional implementation manner, before inputting the text to be recognized and the scene type into the named entity recognition model, the method further includes: obtaining the first text to be recognized corresponding to the current round of conversation. The conversation may be a voice conversation or a text. Conversation, the current round of conversations in this embodiment of this application refers to the latest conversation sent by another party corresponding to the executor of this embodiment of this application. According to the voice or text of this round of conversation, the first text to be recognized is obtained; Whether there is a first keyword in a text, for example, "change", "replace", etc. The first keyword is used to indicate that the first text is related to a multi-round conversation scene, which means that there is context Contextual scenarios, for example, the user says "please play it all well" and then "change to your name". Optionally, the first keyword is also used to indicate that the intent corresponding to the first text is incomplete; When the first keyword exists in the first text, replace the first keyword in the first text with the second keyword, for example, replace "change" with "play" to obtain the second keyword to be recognized Text; Correspondingly, the named entity recognition model is also used to identify named entities in the second text at least according to the second keywords and scene types. The second keywords are related to the entity category corresponding to the identified named entity, the above example The second keyword "play" is related to the entity category of the movie category. The named entity recognition model receives the second text containing the second keyword, and the entity category of the identified named entity corresponds to the second keyword The entity category is related, that is, the second keyword is related to the entity category of the identified named entity.
在一种可能的实施方式中,在检测第一文本中是否存在第一关键词之前,该方法还包括:获取本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到第三文本的意图类型,需要说明的是,本申请实施例的执行方可以获取到对上一轮会话的意图分析结果,得到其对应的意图类型,例如,可以是搜索视频类的意图类型,等等;判断第三文本的意图类型是否为指定的意图类型;相应的,如果第三文本的意图类型是指定的意图类型,则检测第一文本中是否存在第一关键词,也即,只有在上一轮意图类型是特定的一种或几种意图类型的情况下,才需要检测第一文本中是否存在第一关键词。可选的,第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定,例如,每个意图类型可以对应一个或多个关键词,在这些关键词中选择一个关键词作为第二关键词,或者,第二关键词可以是从前一轮会话中提取出的词,例如,动词(如“播放”)、或与实体类别相关的名字(如“电影”)。可选的,第二关键词是动词和/或名词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the method further includes: obtaining an intent analysis result of the third text to be recognized corresponding to the previous conversation of the current round of conversation, In order to obtain the intent type of the third text, it should be noted that the executor of the embodiment of the present application can obtain the intent analysis result of the previous round of conversation, and obtain the corresponding intent type. For example, it may be an intent to search for a video category. Type, etc.; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type, check whether the first keyword exists in the first text, that is , Only when the intent type in the previous round is a specific one or several intent types, it is necessary to detect whether the first keyword exists in the first text. Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous session of the current session. For example, each intent type can correspond to one or more keywords, and one keyword is selected as the first keyword among these keywords. The second keyword, or, the second keyword may be a word extracted from the previous round of conversation, for example, a verb (such as "play"), or a name related to the entity category (such as "movie"). Optionally, the second keyword is a verb and/or noun.
在一种可能的实施方式中,检测第一文本中是否存在第一关键词,包括:利用预设的正则表达式在第一文本中进行匹配,确定第一文本中是否存在第一关键词。例如,正则表达式为([想只需]?要|选[择取出]?|[筛挑]选?|[改换变][为成]).*,其中,“[]”表示匹配到括号内的任意一个字符即可,“?”表示对应的字符是可以被舍弃的,“|”表示或者,“.*”表示任意字符串,也即,对于该正则表达式,句式“只要xxx”“选出xxx”“改成xxx”“选xxx”等都可以匹配成功。In a possible implementation manner, detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the first text to determine whether the first keyword exists in the first text. For example, the regular expression is ([I want only]? Want|select [select out]?|[screen pick]select?|[变变变][为成]).*, where "[]" means match to Any one of the characters in the brackets is sufficient, "?" means that the corresponding character can be discarded, "|" means or, and ".*" means any character string, that is, for the regular expression, the sentence "as long as "xxx", "select xxx", "change to xxx", "select xxx", etc. can be matched successfully.
在一种可能的实施方式中,第二关键词对应的实体类别为:电影类或音乐类;电影类的实体类别对应的第二关键词为“播放”和/或“电影”;音乐类的实体类别对应的第二关键词为“听”和/或“音乐”。In a possible implementation, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category is "listening" and/or "music".
在一种可能的实施方式中,在利用命名实体识别模型在第二文本中识别命名实体之后,方法还包括:在第一文本中,查找命名实体识别模型针对第二文本识别出的命名实体;如果在第一文本中未查找到命名实体,则确定对应的命名实体无效;如果在第一文本中查找到命名实体,则确定对应的命名实体有效。In a possible implementation manner, after the named entity recognition model is used to recognize the named entity in the second text, the method further includes: in the first text, searching for the named entity recognized by the named entity recognition model for the second text; If the named entity is not found in the first text, then the corresponding named entity is determined to be invalid; if the named entity is found in the first text, then the corresponding named entity is determined to be valid.
上述实施方式的目的是,防止识别出的命名实体不在原文中。例如,第一文本为“改成ABC”,第二文本为“播放ABC”,识别出的命名实体为“放AB”,不在第一文本的原文中,这是由于在替换关键词后,导致识别命名实体错误。The purpose of the above embodiment is to prevent the identified named entity from not being in the original text. For example, the first text is "Change to ABC", the second text is "Play ABC", and the recognized named entity is "Put AB", which is not in the original text of the first text. This is due to the replacement of keywords. Error in identifying named entities.
在一种可能的实施方式中,上述场景类型根据命名实体识别模型所应用的终端类型和/或应用软件的类型分类。In a possible implementation manner, the above-mentioned scene types are classified according to the type of terminal and/or the type of application software to which the named entity recognition model is applied.
本申请实施例还提供了另一种命名实体的识别方法的实施例,应理解,本实施例中未详述的部分,可参考上述实施例中相对应部分的具体说明。本实施例提供的方法包括如下步骤32~步骤38:The embodiment of the present application also provides an embodiment of another named entity identification method. It should be understood that for parts that are not described in detail in this embodiment, reference may be made to the specific description of the corresponding part in the foregoing embodiment. The method provided in this embodiment includes the following steps 32 to 38:
步骤32,获取本轮会话对应的待识别的第一文本;Step 32: Obtain the first text to be recognized corresponding to this round of conversation;
步骤34,检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;Step 34: Detect whether there is a first keyword in the first text, and the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios;
步骤36,在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;Step 36: If the first keyword exists in the first text, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized;
步骤38,至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。Step 38: Use a named entity recognition model to identify a named entity in the second text according to at least the second keyword, where the second keyword is related to the entity category corresponding to the identified named entity.
需要说明的是,命名实体识别模型可以结合命名实体识别模型所应用的场景类型,在利用命名实体识别模型在所述第二文本中识别命名实体之前,获取命名实体识别模型所应用的场景类型,至少根据所述第二关键词和所述场景类型在所述第二文本中识别命名实体,本领域技术人员有能力结合第一方面所提供的实施例和第二方面所提供的实施例。It should be noted that the named entity recognition model can be combined with the scene type applied by the named entity recognition model, and before the named entity recognition model is used to identify the named entity in the second text, the scene type applied by the named entity recognition model is obtained, At least according to the second keyword and the scene type to identify the named entity in the second text, those skilled in the art have the ability to combine the embodiments provided in the first aspect and the embodiments provided in the second aspect.
在一种可能的实施方式中,在检测所述第一文本中是否存在第一关键词之前,所述方法还包括:获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则检测所述第一文本中是否存在第一关键词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the method further includes: obtaining the third text to be recognized corresponding to the previous session of the current session Intent analysis result of the third text to obtain the intent type of the third text; determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent Type, then it is detected whether there is a first keyword in the first text.
在一种可能的实施方式中,在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,所述方法还包括:在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, after the named entity recognition model is used to recognize the named entity in the second text, the method further includes: searching for the named entity recognition model in the first text The named entity identified for the second text; if the named entity is not found in the first text, it is determined that the corresponding named entity is invalid; if the named entity is found in the first text Named entity, it is determined that the corresponding named entity is valid.
可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,所述第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,所述第一关键词用于指示所述第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
可选的,检测所述第一文本中是否存在第一关键词包括:利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。Optionally, detecting whether the first keyword exists in the first text includes: using a preset regular expression to perform matching in the text to be recognized to determine whether the first keyword exists in the first text.
可选的,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category of the music category is "listen" and/or "music".
图4为本申请实施例提供的命名实体的识别方法的一种可选的流程示意图,如图4所示,该方法包括:FIG. 4 is a schematic diagram of an optional process of a named entity identification method provided by an embodiment of the application. As shown in FIG. 4, the method includes:
在命名实体的识别方法对待识别文本进行处理之前,通过人工或在某一类场景下的语料进行提取收集关键词和多轮句式。Before the named entity recognition method processes the text to be recognized, keywords and multiple rounds of sentence patterns are collected manually or from corpus in a certain type of scene.
例如,对于电影类型的关键词可以是“播放”、“电影”,对于音乐类型的关键词可以是“听”、“歌曲”,收集的每一类关键词可以对应于一种特殊的上述场景,对该使用场景下的命名实体识别增强特征,提高识别出相关命名实体的概率,例如,电影类的关键词可以对应于电视终端的语音助手等场景类型,音乐类的关键词可以对应于手机终端的音乐类软件等场景类型。For example, the keywords for the movie genre can be "play" and "movie", and the keywords for the music genre can be "listen" and "song". Each type of keyword collected can correspond to a special above scene. , The enhanced feature of named entity recognition in the use scene improves the probability of identifying related named entities. For example, movie keywords can correspond to scene types such as voice assistants on TV terminals, and music keywords can correspond to mobile phones. Scene types such as terminal music software.
在本申请实施例中所述的多轮句式,是指包含的意图信息不完整,需要上文中的意图信息进行补充的句式,例如,多轮句式可以是“只要钢铁侠”、“选出明天”、“改成你的名字”、“选都挺好”等等。基于收集到的多轮句式,构造多轮句式的正则表达式,例如,正则表达式可以是([想只需]?要|选[择取出]?|[筛挑]选?|[改换变][为成]).*。The multi-round sentence pattern described in the embodiments of this application refers to a sentence pattern that contains incomplete intention information and needs to be supplemented by the above intention information. For example, the multi-round sentence pattern can be "as long as Iron Man", " Choose tomorrow", "Change to your name", "Choose all very well" and so on. Based on the collected multiple rounds of sentence patterns, construct regular expressions of multiple rounds of sentence patterns. For example, the regular expression can be ([I want only]? Want|Select [Select out]?|[Screen Pick]Select?|[ Change and change][为成]).*.
需要说明的是,上述的收集关键词、收集多轮句式、构造正则表达式的步骤,与命名实体的识别模型对待识别文本的识别处理过程是相对独立的。It should be noted that the above steps of collecting keywords, collecting multiple rounds of sentence patterns, and constructing regular expressions are relatively independent of the recognition process of the text to be recognized by the named entity recognition model.
在获取待识别文本之后,将文本输入至本申请实施例提供的命名实体的识别模型。After the text to be recognized is obtained, the text is input into the recognition model of the named entity provided in the embodiment of the present application.
首先,利用收集的多轮句式的正则表达式匹配待替换语句,将待替换语句替换为带有关键词的句式,具体的,可以包括拼接关键词和/或替换关键词,也即,在原句拼接上关键词,和/或,将原句中的一部分词替换为关键词。例如,输入的待识别文本为“换成你的名字”,经正则表达式匹配之后,替换为“播放你的名字”。First, use the collected regular expressions of multiple rounds to match the sentence to be replaced, and replace the sentence to be replaced with a sentence with keywords. Specifically, it can include splicing keywords and/or replacing keywords, that is, Join keywords in the original sentence, and/or replace part of the words in the original sentence with keywords. For example, the input text to be recognized is "replace your name", and after the regular expression is matched, replace it with "play your name".
其次,将替换后的文本输入至命名实体的识别模型。在命名实体的识别模型中,首先对替换后的文本执行分词处理,得到“播放/你/的/名字”,对每个分词标注索引(包括词索引、词性索引、场景索引),其次,将每个索引映射为向量,在将每个分词的多个索引的向量拼接后,输入序列标注模型。序列标注模型可以采用上述的BiLSTM+CRF模型的结构。例如,经过序列标注模型对“播放你的名字”的向量序列进行标注之后,确定每个分词的标签为“O B-movie I-movie I-movie”,各个标签分别代表不是命名实体、命名实体的起始位置、命名实体的非起始位置、命名实体的非起始位置。Second, input the replaced text into the recognition model of the named entity. In the recognition model of named entities, first perform word segmentation processing on the replaced text to get "play/you/的/name", mark each word segmentation index (including word index, part-of-speech index, scene index), and secondly, Each index is mapped to a vector, and after the vectors of multiple indexes of each word segmentation are spliced, the sequence labeling model is input. The sequence labeling model can adopt the structure of the above-mentioned BiLSTM+CRF model. For example, after the sequence labeling model is used to label the vector sequence of "Play your name", the label of each word segmentation is determined to be "O B-movie I-movie I-movie", and each label represents whether it is a named entity or a named entity. The starting position of the named entity, the non-starting position of the named entity, and the non-starting position of the named entity.
第三,将标注出的命名实体结构化,例如,如果识别出命名实体为“钢铁侠第二部”,则结构化(或者说归一化)为命名实体“钢铁侠2”。对于命名实体“你的名字”,结构化实体的结果仍为“你的名字”。Third, structure the marked named entity. For example, if the named entity is identified as "Iron Man Part 2", it will be structured (or normalized) as the named entity "Iron Man 2". For the named entity "your name", the result of the structured entity is still "your name".
最后,将未结构化的命名实体在原来的待识别文本中进行匹配,校验识别出的命名实体是否存在于原文中,避免将替换的关键词与原文结合识别出原文不存在的命名实体。如果存在,确定识别出的命名实体有效。Finally, the unstructured named entity is matched in the original text to be recognized to verify whether the recognized named entity exists in the original text, and to avoid combining the replaced keywords with the original text to identify a named entity that does not exist in the original text. If it exists, confirm that the identified named entity is valid.
图5为本申请实施例提供的命名实体的识别方法的又一种可选的流程示意图,如图5所示,该方法分为训练流程和识别流程两个部分。训练流程是训练实际使用的命名实体识别模型的过程,识别过程是命名实体识别模型在使用时的过程。训练过程与识别过程可以 是相对独立的,训练过程训练得到的命名实体的识别模型用于作为识别过程所使用的命名实体的识别模型。FIG. 5 is a schematic diagram of another optional process of the method for identifying a named entity provided by an embodiment of the application. As shown in FIG. 5, the method is divided into two parts: a training process and a recognition process. The training process is the process of training the actual named entity recognition model, and the recognition process is the process of using the named entity recognition model. The training process and the recognition process can be relatively independent, and the recognition model of the named entity trained in the training process is used as the recognition model of the named entity used in the recognition process.
在训练过程中,对收集到的训练语料可以进行语料增强的处理方法,语料增强是将语料的一些关键词替换为上述的多轮句式,以扩充语料的处理方法。例如,语料文本为“播放你的名字”,经过语料增强的处理之后,增强语料的文本为“改为你的名字”。语料增强可以视作是在待识别文本中匹配正则表达式并替换关键词的反向做法。对语料的预处理包括分词处理、知识抽取、词性判断、索引标注等。分词处理用于对语料进行分词,知识抽取用于利用预设的命名实体字典在语料中进行匹配,匹配到的命名实体可以作为已知的知识一同输入至命名实体的识别模型进行训练,词性判断用于确定每个分词的词性,索引标注可以对词的内容本身(文字)进行标注,也可以对词性标注索引,还可以对场景类型和/或知识进行索引。语料预处理可以处理原语料,也可以处理增强后的语料,以当前的训练目标而定。In the training process, the collected training corpus can be processed with corpus enhancement. The corpus enhancement is to replace some keywords of the corpus with the above-mentioned multi-round sentence pattern to expand the processing method of the corpus. For example, the text of the corpus is "Play your name", and after the processing of the corpus enhancement, the text of the enhanced corpus is "Change your name". Corpus enhancement can be regarded as the reverse method of matching regular expressions and replacing keywords in the text to be recognized. The preprocessing of the corpus includes word segmentation, knowledge extraction, part-of-speech judgment, index labeling and so on. Word segmentation is used to segment the corpus, and knowledge extraction is used to match in the corpus using a preset named entity dictionary. The matched named entity can be used as known knowledge and input into the named entity recognition model for training, and part of speech judgment Used to determine the part of speech of each word segmentation, the index tagging can mark the content of the word itself (text), it can also index the part of speech tag, and it can also index the scene type and/or knowledge. The corpus preprocessing can process the original corpus or the enhanced corpus, depending on the current training goal.
在建立索引之后,输入基础的模型,和预处理的信息,对模型进行训练。基础的模型可以配置为BiLSTM+CRF模型。模型的输入至少包括场景类型索引和每个分词的词索引。After building the index, input the basic model and preprocessed information to train the model. The basic model can be configured as BiLSTM+CRF model. The input of the model includes at least the scene type index and the word index of each word segmentation.
输出即为序列标注的标签,也即每个词的命名实体标签。The output is the label of the sequence label, which is the named entity label of each word.
在识别过程中,首先可以获取上文意图或槽位信息,上文意图可以是由如图1所示的意图识别模块和槽位填充模块在处理上一轮或上n轮的语句时所识别出的意图和槽位的信息。在获得上文意图和槽位信息之后,可以判断该意图是否与当前的实体相关,例如,上文意图为播放一个电影:你的名字,在本轮获取到的待识别文本(一个语句)时,可以首先利用命名实体字典识别当前文本中是否存在实体,如“改为都挺好”,在命名实体字典中匹配到电视剧“挺好”,说明当前待识别文本中的实体是与上文意图相关的,需要利用关键词进行增强。或者,也可以利用正则表达式直接匹配,如果匹配不到正则表达式,则说明不需要对待识别文本进行关键词的特征增强,如果匹配到正则表达式,则进行增强。In the recognition process, the above intention or slot information can be obtained first. The above intention can be recognized by the intention recognition module and the slot filling module shown in Figure 1 when processing the last round or last n rounds of sentences. Out the intention and slot information. After obtaining the above intention and slot information, you can determine whether the intention is related to the current entity. For example, the above intention is to play a movie: your name, when the text (a sentence) to be recognized is obtained in this round , You can first use the named entity dictionary to identify whether there is an entity in the current text, such as "It’s good to change it", and the TV series “very good” is matched in the named entity dictionary, indicating that the entity in the current text to be recognized is the same as the above intention Related, need to use keywords for enhancement. Alternatively, regular expressions can also be used for direct matching. If the regular expressions cannot be matched, it means that there is no need to enhance the features of the keywords in the text to be recognized. If the regular expressions are matched, then the enhancements are performed.
增强的方法为利用正则表达式检索匹配上述的多轮句式,并替换为含有关键词的句式。例如,将“换成你的名字”替换为“播放你的名字”。The enhanced method is to use regular expression search to match the above-mentioned multiple rounds of sentence patterns and replace them with sentence patterns that contain keywords. For example, replace "Replace your name" with "Play your name".
在替换文本后,对替换后的文本执行预处理,包括分词处理、上述的知识抽取等,并标注索引。将预处理后得到的索引以及场景类型的索引输入到命名实体的识别模型中,以得到标注序列。标注序列用于标注每个分词是否为实体。After replacing the text, perform preprocessing on the replaced text, including word segmentation, the above-mentioned knowledge extraction, etc., and mark the index. The index obtained after the preprocessing and the index of the scene type are input into the recognition model of the named entity to obtain the labeling sequence. The labeling sequence is used to label whether each word segmentation is an entity.
在得到标注序列后,执行后处理,也即,校验替换前的原文中是否存在标注出的命名实体,如果不存在,则为误识别,如果存在,则将实体结构化后输出给后续的下游模块,如图1中的意图识别模块、槽位填充模块等。After obtaining the label sequence, perform post-processing, that is, check whether the labeled named entity exists in the original text before replacement. If it does not exist, it is misrecognized. If it exists, the entity is structured and output to the subsequent Downstream modules, such as the intent recognition module and slot filling module in Figure 1.
本申请实施例提供的命名实体的识别方法,可以利用同一个命名实体识别模型适用于不同的场景,适用于人工智能领域的语音识别,例如,终端系统或应用软件的语音助手、AI客服、AI聊天等应用,本申请实施例提供的命名实体的识别方法与自然语言处理技术相关,可以针对不同的场景有效识别对应场景下的命名实体,有助于提高自然语言处理的语义识别能力,减少收集语料所需人力成本,提高语义识别的泛化能力。本申请实施例通过在命名实体识别模型的输入中增加“场景类型”信息的输入,使得识别命名实体时可以动态调整“场景类型”的输入值,以调整实体识别结果,以适应不同的场景,为用户提供更准确、更符合所应用场景的识别结果。The named entity recognition method provided in the embodiments of this application can use the same named entity recognition model to apply to different scenarios, and is suitable for voice recognition in the field of artificial intelligence, for example, voice assistants of terminal systems or application software, AI customer service, AI For applications such as chat, the method for identifying named entities provided in the embodiments of this application is related to natural language processing technology, which can effectively identify named entities in corresponding scenarios for different scenarios, which helps to improve the semantic recognition capabilities of natural language processing and reduce collection The labor cost required for the corpus improves the generalization ability of semantic recognition. The embodiment of the application adds the input of the "scene type" information to the input of the named entity recognition model, so that the input value of the "scene type" can be dynamically adjusted when the named entity is recognized, so as to adjust the entity recognition result to adapt to different scenarios. Provide users with more accurate recognition results that are more in line with the application scenario.
可以理解的是,上述实施例中的部分或全部步骤或操作仅是示例,本申请实施例还可以执行其它操作或者各种操作的变形。此外,各个步骤可以按照上述实施例呈现的不同的顺序来执行,并且有可能并非要执行上述实施例中的全部操作。It can be understood that part or all of the steps or operations in the above-mentioned embodiments are only examples, and the embodiments of the present application may also perform other operations or various operation variations. In addition, each step may be executed in a different order presented in the foregoing embodiment, and it may not be necessary to perform all operations in the foregoing embodiment.
如图6所示,提供了一种命名实体的识别设备的结构示意图,该命名实体的识别设备600包括第一获取模块601,第一确定模块602、输入模块603和执行模块604。As shown in FIG. 6, a schematic structural diagram of a named entity recognition device is provided. The named entity recognition device 600 includes a first acquisition module 601, a first determination module 602, an input module 603, and an execution module 604.
其中,第一获取模块,用于获取待识别文本;第一确定模块,用于确定用于识别待识别文本中的命名实体的命名实体识别模型所应用的场景类型;输入模块,用于将待识别文本和场景类型输入命名实体识别模型;执行模块,用于获取命名实体识别模型的输出信息,以确定命名实体识别模型针对场景类型在待识别文本中识别出的命名实体。Among them, the first obtaining module is used to obtain the text to be recognized; the first determining module is used to determine the scene type applied by the named entity recognition model used to recognize the named entity in the text to be recognized; the input module is used to transfer the The recognition text and scene type are input to the named entity recognition model; the execution module is used to obtain the output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
在一种可能的实施方式中,该装置还包括:划分模块,用于在将待识别文本和场景类型输入命名实体识别模型之前,将待识别文本按照划分单位标注内容索引,其中,内容相同的划分单位通过相同的内容索引进行标注;第二确定模块,用于确定场景类型所对应的场景类型索引;针对每个划分单位标注场景类型索引;相应的,输入模块包括:第一输入单元,用于将待识别文本中所有划分单位被标注的索引输入命名实体识别模型。In a possible implementation manner, the device further includes: a division module, which is used to mark the content index of the text to be recognized according to the division unit before inputting the text to be recognized and the scene type into the named entity recognition model, wherein the content of the same content is indexed. The division units are marked by the same content index; the second determination module is used to determine the scene type index corresponding to the scene type; the scene type index is marked for each division unit; correspondingly, the input module includes: a first input unit, To input the marked index of all the division units in the text to be recognized into the named entity recognition model.
在一种可能的实施方式中,命名实体识别模型包括:第一转换单元,用于在将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之后,针对每个划分单位,分别将被标注的不同类型的索引转换为多维向量;拼接单元,用于针对每个划分单位,按序拼接不同类型的索引转换后的多个多维向量;第二输入单元,用于将待识别文本中所有划分单位的拼接向量输入序列标注模型;第一获取单元,用于获取序列标注模型的输出结果,以得到待识别文本中的命名实体的标注信息。In a possible implementation manner, the named entity recognition model includes: a first conversion unit, configured to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model, and for each division unit, respectively The marked different types of indexes are converted into multi-dimensional vectors; the splicing unit is used to sequentially splice multiple multi-dimensional vectors after the conversion of different types of indexes for each division unit; the second input unit is used to convert the text to be recognized The splicing vectors of all the division units are input to the sequence labeling model; the first obtaining unit is used to obtain the output result of the sequence labeling model to obtain the labeling information of the named entity in the text to be recognized.
在一种可能的实施方式中,序列标注模型为深度学习模型,深度学习模型包括:一层或多层循环神经网络,每层循环神经网络利用神经网络计算单元按序对待识别文本中每个划分单位的拼接向量进行计算,以输出每个划分单位对应的计算结果向量;条件随机场,用于接收向量序列,向量序列包括按序排列的多个计算结果向量,多个计算结果向量为一层或多层循环神经网络中最后一层循环神经网络针对所有划分单位的计算结果向量,以输出用于标识每个划分单位是否为命名实体的标注标签。In a possible implementation, the sequence labeling model is a deep learning model, and the deep learning model includes: one or more layers of recurrent neural networks, and each layer of recurrent neural networks uses neural network computing units to treat each segment of the recognized text in order The stitching vector of the unit is calculated to output the calculation result vector corresponding to each division unit; the conditional random field is used to receive the vector sequence. The vector sequence includes multiple calculation result vectors arranged in order, and multiple calculation result vectors are one layer Or the last layer of the recurrent neural network in the multi-layer recurrent neural network calculates the result vector for all the division units to output a label used to identify whether each division unit is a named entity.
可选的,循环神经网络为长短期记忆神经网络、或双向长短期记忆神经网络。Optionally, the cyclic neural network is a long and short-term memory neural network, or a bidirectional long- and short-term memory neural network.
可选的,深度学习模型为利用语料进行无监督预训练得到的模型。Optionally, the deep learning model is a model obtained by unsupervised pre-training using corpus.
在一种可能的实施方式中,装置还包括:第一标注模块,用于在将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之前,针对待识别文本中的每个划分单位标注词性索引;相应的,输入命名实体识别模型的每个划分单位被标注的索引包括词性索引。In a possible implementation manner, the device further includes: a first labeling module, configured to, before inputting the labelled index of all the division units in the text to be recognized into the named entity recognition model, for each division unit in the text to be recognized Mark the part-of-speech index; correspondingly, the index marked for each division unit of the input named entity recognition model includes the part-of-speech index.
在一种可能的实施方式中,该装置还包括:第三确定模块,用于在将待识别文本中所有划分单位被标注的索引输入命名实体识别模型之前,将待识别文本与预设的命名实体字典匹配,确定待识别文本中匹配到的所有命名实体;第二标注模块,用于针对待识别文本中的每个划分单位,标注知识索引,其中,知识索引用于表示对应的划分单位在命名实体识别模型中所匹配到的命名实体的信息;相应的,输入命名实体识别模型的每个划分单位被标注的索引包括知识索引。In a possible implementation manner, the device further includes: a third determining module, configured to combine the text to be recognized with a preset name before inputting the index of all the division units in the text to be recognized into the named entity recognition model. Entity dictionary matching is used to determine all named entities that are matched in the text to be recognized; the second labeling module is used to label the knowledge index for each division unit in the text to be recognized, where the knowledge index is used to indicate that the corresponding division unit is in The information of the matched named entity in the named entity recognition model; correspondingly, the index marked for each division unit of the input named entity recognition model includes a knowledge index.
在一种可能的实施方式中,该装置还包括:第二获取模块,用于在将待识别文本和场景类型输入命名实体识别模型之前,获取本轮会话对应的待识别的第一文本;检测模块,用于检测第一文本中是否存在第一关键词,第一关键词用于指示第一文本与多轮会话场景相关;替换模块,用于在第一文本中存在第一关键词的情况下,将第一文本中的第一关键词替换为第二关键词,得到待识别的第二文本;相应的,命名实体识别模型还用于至少根据第二关键词和场景类型,在第二文本中识别命名实体,第二关键词与识别出的命名实体所对应的实体类别相关。In a possible implementation manner, the device further includes: a second acquiring module, configured to acquire the first text to be recognized corresponding to the current session before inputting the text and scene type into the named entity recognition model; and detecting The module is used to detect whether the first keyword exists in the first text, the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; the replacement module is used when the first keyword exists in the first text Next, replace the first keyword in the first text with the second keyword to obtain the second text to be recognized; correspondingly, the named entity recognition model is also used to at least according to the second keyword and scene type, in the second The named entity is recognized in the text, and the second keyword is related to the entity category corresponding to the recognized named entity.
在一种可能的实施方式中,在检测第一文本中是否存在第一关键词之前,该装置还包括:第三获取模块,用于获取本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到第三文本的意图类型;判断模块,用于判断第三文本的意图类型是否为指定的意图类型;相应的,如果第三文本的意图类型是指定的意图类型,则检测模块执行检测第一文本中是否存在第一关键词。In a possible implementation manner, before detecting whether the first keyword exists in the first text, the device further includes: a third acquiring module, configured to acquire the first to be identified corresponding to the previous session of the current round of conversation The intent analysis result of the three texts to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type , The detection module performs detection of whether the first keyword exists in the first text.
在一种可能的实施方式中,该装置还包括:查找模块,用于在利用命名实体识别模型在第二文本中识别命名实体之后,在第一文本中,查找命名实体识别模型针对第二文本识别出的命名实体;第四确定模块,用于如果在第一文本中未查找到命名实体,则确定对应的命名实体无效;第五确定模块,用于如果在第一文本中查找到命名实体,则确定对应的命名实体有效。In a possible implementation manner, the device further includes: a search module, which is used to search for the named entity recognition model for the second text in the first text after the named entity recognition model is used to identify the named entity in the second text. The identified named entity; the fourth determining module is used to determine that the corresponding named entity is invalid if the named entity is not found in the first text; the fifth determining module is used to determine if the named entity is found in the first text , The corresponding named entity is determined to be valid.
可选的,第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,第一关键词用于指示第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
在一种可能的实施方式中,检测模块包括:匹配单元,用于利用预设的正则表达式在第一文本中进行匹配,确定第一文本中是否存在第一关键词。In a possible implementation manner, the detection module includes: a matching unit, configured to perform matching in the first text by using a preset regular expression to determine whether the first keyword exists in the first text.
可选的,第二关键词对应的实体类别为:电影类或音乐类;电影类的实体类别对应的第二关键词为“播放”和/或“电影”;音乐类的实体类别对应的第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; the second keyword corresponding to the entity category of the music The second key word is "listening" and/or "music".
可选的,场景类型根据命名实体识别模型所应用的终端类型和/或应用软件的类型分类。Optionally, the scene type is classified according to the type of terminal to which the named entity recognition model is applied and/or the type of application software.
在一种可能的实施方式中,装置应用于配置有声音接收器的电子设备,获取模块包括:第二获取单元,用于获取声音接收器采集到的语音;第二转换单元,用于将语音转换为文本,以得到待识别文本。In a possible implementation manner, the device is applied to an electronic device equipped with a sound receiver, and the acquisition module includes: a second acquisition unit for acquiring the voice collected by the sound receiver; and a second conversion unit for converting the voice Convert to text to get the text to be recognized.
如图7所示,还提供了另一种命名实体的识别设备的结构示意图,该命名实体的识别设备700包括第一获取模块701,检测模块702、替换模块703和识别模块704。As shown in FIG. 7, there is also provided a schematic structural diagram of another named entity identification device. The named entity identification device 700 includes a first acquisition module 701, a detection module 702, a replacement module 703, and an identification module 704.
第一获取模块,用于获取本轮会话对应的待识别的第一文本;检测模块,用于检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;替换模块,用于在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;识别模块,用于至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。The first obtaining module is used to obtain the first text to be recognized corresponding to the current session; the detection module is used to detect whether there is a first keyword in the first text, and the first keyword is used to indicate the The first text is related to multiple rounds of conversation scenarios; the replacement module is used to replace the first keyword in the first text with the first keyword when the first keyword exists in the first text Two keywords to obtain the second text to be recognized; the recognition module is used to recognize named entities in the second text using a named entity recognition model at least according to the second keywords, and the second keywords are It is related to the entity category corresponding to the identified named entity.
在一种可能的实施方式中,所述装置还包括:第二获取模块,用于在检测所述第一文本中是否存在第一关键词之前,获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;判断模块,用于判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则所述检测模块执行检测所述第一文本中是否存在第一关键词。In a possible implementation manner, the device further includes: a second obtaining module, configured to obtain the previous session correspondence of the current session before detecting whether the first keyword exists in the first text The intent analysis result of the third text to be recognized to obtain the intent type of the third text; the judgment module is used to determine whether the intent type of the third text is the specified intent type; correspondingly, if the If the intent type of the third text is the specified intent type, the detection module performs detection of whether the first keyword exists in the first text.
在一种可能的实施方式中,所述装置还包括:查找模块,用于在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;第一确定模块,用于如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;第二确定模块,用于如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。In a possible implementation manner, the device further includes: a search module, configured to, after recognizing a named entity in the second text by using the named entity recognition model, search for all the named entities in the first text. The named entity recognition model is for the named entity recognized by the second text; a first determining module is configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text; The second determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
可选的,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。Optionally, the second keyword is determined according to the intent analysis result corresponding to the previous round of the current round of conversation.
可选的,所述第二关键词是动词和/或名词。Optionally, the second keyword is a verb and/or noun.
可选的,所述第一关键词用于指示所述第一文本所对应的意图不完整。Optionally, the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
在一种可能的实施方式中,所述检测模块包括:匹配单元,用于利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。In a possible implementation manner, the detection module includes: a matching unit, configured to use a preset regular expression to perform matching in the text to be recognized, and determine whether the first keyword exists in the first text .
可选的,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。Optionally, the entity category corresponding to the second keyword is: movie or music; the second keyword corresponding to the entity category of the movie is "play" and/or "movie"; The second keyword corresponding to the entity category of the music category is "listen" and/or "music".
在本申请实施例提供的命名实体的识别设备600或命名实体的识别设备700的描述中未详述的部分,本领域技术人员应当从对本申请实施例提供的命名实体的识别方法的描述中确定相对应的内容,这对于本领域技术人员而言是显而易见的,在此不再赘述。In the description of the named entity identification device 600 or the named entity identification device 700 provided in the embodiments of the present application, those skilled in the art should determine from the description of the named entity identification method provided in the embodiments of the present application. The corresponding content is obvious to those skilled in the art, and will not be repeated here.
应理解以上图6或图7所示设备的各个模块的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且这些模块可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分模块以软件通过处理元件调用的形式实现,部分模块通过硬件的形式实现。例如,确定模块可以为单独设立的处理元件,也可以集成在通信装置,例如终端的某一个芯片中实现,此外,也可以以程序的形式存储于通信装置的存储器中,由通信装置的某一个处理元件调用并执行以上各个模块的功能。其它模块的实现与之类似。此外这些模块全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件可以是一种集成电路,具有信号的处理能力。在实现过程中,上述方法的各步骤或以上各个模块可以通过处理器元件中的硬件的集成逻辑电路或者软件形式的指令完成。It should be understood that the division of the various modules of the device shown in FIG. 6 or FIG. 7 is only a division of logical functions, and may be fully or partially integrated into one physical entity during actual implementation, or may be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be implemented in the form of hardware; part of the modules can be implemented in the form of software called by the processing elements, and some of the modules can be implemented in the form of hardware. For example, the determination module may be a separately established processing element, or it may be integrated in a communication device, such as a certain chip of a terminal, and it may also be stored in the memory of the communication device in the form of a program. The processing element calls and executes the functions of the above modules. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together or implemented independently. The processing element described here may be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules may be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
例如,以上这些模块可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个特定集成电路(Application Specific Integrated Circuit,ASIC),或,一个或多个微处理器(digital singnal processor,DSP),或,一个或者多个现场可编程门阵列(Field Programmable Gate Array,FPGA)等。再如,当以上某个模块通过处理元件调度程序的形式实现时,该处理元件可以是通用处理器,例如中央处理器(Central Processing Unit,CPU)或其它可以调用程序的处理器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital singnal processor, DSP), or, one or more Field Programmable Gate Array (Field Programmable Gate Array, FPGA), etc. For another example, when one of the above modules is implemented in the form of a processing element scheduler, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call programs. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
应理解,本申请中,“多个”是指两个或两个以上,其它量词与之类似。“和/或”,描述关联对象的对应关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。It should be understood that in this application, "a plurality of" refers to two or more than two, and other quantifiers are similar. "And/or" describes the corresponding relationship of the associated objects, indicating that there can be three types of relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects before and after are in an "or" relationship.
本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。In this application, "at least one" refers to one or more, and "multiple" refers to two or more. "And/or" describes the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone, where A, B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in an "or" relationship. "The following at least one item (a)" or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a). For example, at least one item (a) of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
需要说明的是,本申请实施例所提供的命名实体的识别方法和设备仅仅是一种举例,本申请实施例并不限制于此。It should be noted that the method and device for identifying named entities provided in the embodiments of the present application are merely examples, and the embodiments of the present application are not limited thereto.
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行上述实施例所述的方法。The embodiments of the present application also provide a computer-readable storage medium in which a computer program is stored, and when the computer program is run on a computer, the computer executes the method described in the above-mentioned embodiment.
此外,本申请实施例还提供一种计算机程序产品,该计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行上述实施例所述的方法。In addition, the embodiments of the present application also provide a computer program product, which includes a computer program, which when running on a computer, causes the computer to execute the method described in the foregoing embodiment.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk)等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented by software, it can be implemented in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions described in this application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center integrated with one or more available media. The usable medium may be a magnetic medium, (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk).

Claims (30)

  1. 一种命名实体的识别方法,其特征在于,包括:A method for identifying named entities, which is characterized in that it includes:
    获取待识别文本;Obtain the text to be recognized;
    确定用于识别所述待识别文本中的命名实体的命名实体识别模型所应用的场景类型;Determining the type of scene applied by the named entity recognition model used to recognize the named entity in the text to be recognized;
    将所述待识别文本和所述场景类型输入所述命名实体识别模型;Inputting the to-be-recognized text and the scene type into the named entity recognition model;
    获取所述命名实体识别模型的输出信息,以确定所述命名实体识别模型针对所述场景类型在所述待识别文本中识别出的命名实体。Obtain the output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
  2. 如权利要求1所述的方法,其特征在于,The method of claim 1, wherein:
    在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,所述方法还包括:Before inputting the to-be-recognized text and the scene type into the named entity recognition model, the method further includes:
    将所述待识别文本按照划分单位标注内容索引,其中,内容相同的所述划分单位通过相同的内容索引进行标注;Marking the text to be recognized with a content index according to division units, wherein the division units with the same content are marked by the same content index;
    确定所述场景类型所对应的场景类型索引;针对每个所述划分单位标注所述场景类型索引;Determine the scene type index corresponding to the scene type; mark the scene type index for each division unit;
    相应的,所述将所述待识别文本和所述场景类型输入所述命名实体识别模型,包括:Correspondingly, the inputting the text to be recognized and the scene type into the named entity recognition model includes:
    将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型。Input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
  3. 如权利要求2所述的方法,其特征在于,在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之后,所述命名实体识别模型的处理方法包括:3. The method according to claim 2, wherein after inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, the processing method of the named entity recognition model comprises:
    针对每个所述划分单位,分别将被标注的不同类型的索引转换为多维向量;For each of the division units, convert the marked indexes of different types into multi-dimensional vectors;
    针对每个所述划分单位,按序拼接不同类型的索引转换后的多个多维向量;For each of the division units, sequentially splicing multiple multi-dimensional vectors converted by different types of indexes;
    将所述待识别文本中所有所述划分单位的拼接向量输入序列标注模型;Inputting the stitching vectors of all the division units in the text to be recognized into the sequence labeling model;
    获取所述序列标注模型的输出结果,以得到所述待识别文本中的命名实体的标注信息。Obtain the output result of the sequence annotation model to obtain the annotation information of the named entity in the text to be recognized.
  4. 如权利要求3所述的方法,其特征在于,所述序列标注模型为深度学习模型,所述深度学习模型包括:The method of claim 3, wherein the sequence labeling model is a deep learning model, and the deep learning model comprises:
    一层或多层循环神经网络,每层所述循环神经网络利用神经网络计算单元按序对所述待识别文本中每个所述划分单位的拼接向量进行计算,以输出每个所述划分单位对应的计算结果向量;One or more layers of cyclic neural network, each layer of the cyclic neural network uses a neural network calculation unit to sequentially calculate the stitching vector of each of the division units in the text to be recognized, to output each of the division units The corresponding calculation result vector;
    条件随机场,用于接收向量序列,所述向量序列包括按序排列的多个所述计算结果向量,所述多个计算结果向量为所述一层或多层循环神经网络中最后一层所述循环神经网络针对所有所述划分单位的计算结果向量,以输出用于标识每个所述划分单位是否为命名实体的标注标签。The conditional random field is used to receive a vector sequence, the vector sequence includes a plurality of the calculation result vectors arranged in order, and the plurality of calculation result vectors are the last layer of the one or more layers of the cyclic neural network. The recurrent neural network outputs a vector of calculation results for all the division units to output a label used to identify whether each division unit is a named entity.
  5. 如权利要求1-4任一项所述的方法,其特征在于,在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,所述方法还包括:获取本轮会话对应的待识别的第一文本;检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;相应的,所述将所述待识别文本和所述场景类型输入所述命名实体识别模型,包括:至少根据所述第二关键词,利用所述命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。The method according to any one of claims 1 to 4, characterized in that, before the text to be recognized and the scene type are input into the named entity recognition model, the method further comprises: obtaining the current session correspondence The first text to be recognized; detecting whether there is a first keyword in the first text, the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios; in the first text If the first keyword exists, replace the first keyword in the first text with a second keyword to obtain the second text to be recognized; correspondingly, the Inputting the text and the scene type into the named entity recognition model includes: at least according to the second keyword, using the named entity recognition model to recognize a named entity in the second text, and the second keyword is related to The entity category corresponding to the identified named entity is related.
  6. 一种命名实体的识别方法,其特征在于,所述方法包括:A method for identifying named entities, characterized in that the method includes:
    获取本轮会话对应的待识别的第一文本;Obtain the first text to be recognized corresponding to this round of conversation;
    检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;Detecting whether there is a first keyword in the first text, where the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios;
    在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;In the case where the first keyword exists in the first text, replacing the first keyword in the first text with a second keyword to obtain the second text to be recognized;
    至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。At least according to the second keyword, a named entity recognition model is used to identify a named entity in the second text, and the second keyword is related to the entity category corresponding to the identified named entity.
  7. 如权利要求6所述的方法,其特征在于,在检测所述第一文本中是否存在第一关键词之前,所述方法还包括:8. The method of claim 6, wherein before detecting whether the first keyword exists in the first text, the method further comprises:
    获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;Acquiring an intent analysis result of the third text to be recognized corresponding to the previous session of the current round of conversation, so as to obtain the intent type of the third text;
    判断所述第三文本的意图类型是否为指定的意图类型;Determine whether the intent type of the third text is a designated intent type;
    相应的,如果所述第三文本的意图类型是所述指定的意图类型,则检测所述第一文本中是否存在第一关键词。Correspondingly, if the intent type of the third text is the specified intent type, it is detected whether the first keyword exists in the first text.
  8. 如权利要求6或7所述的方法,其特征在于,在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,所述方法还包括:8. The method according to claim 6 or 7, wherein after using the named entity recognition model to identify the named entity in the second text, the method further comprises:
    在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实 体;In the first text, search for named entities recognized by the named entity recognition model for the second text;
    如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;If the named entity is not found in the first text, determining that the corresponding named entity is invalid;
    如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。If the named entity is found in the first text, it is determined that the corresponding named entity is valid.
  9. 如权利要求6-8任一项所述的方法,其特征在于,检测所述第一文本中是否存在第一关键词包括:利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。The method according to any one of claims 6-8, wherein detecting whether the first keyword exists in the first text comprises: using a preset regular expression to match in the text to be recognized, and determining the Whether the first keyword exists in the first text.
  10. 一种命名实体的识别设备,其特征在于,所述设备包括:A device for identifying named entities, characterized in that the device includes:
    第一获取模块,用于获取待识别文本;The first obtaining module is used to obtain the text to be recognized;
    第一确定模块,用于确定用于识别所述待识别文本中的命名实体的命名实体识别模型所应用的场景类型;The first determining module is configured to determine the type of scene applied by the named entity recognition model used to recognize the named entity in the text to be recognized;
    输入模块,用于将所述待识别文本和所述场景类型输入所述命名实体识别模型;An input module, configured to input the to-be-recognized text and the scene type into the named entity recognition model;
    执行模块,用于获取所述命名实体识别模型的输出信息,以确定所述命名实体识别模型针对所述场景类型在所述待识别文本中识别出的命名实体。The execution module is configured to obtain output information of the named entity recognition model to determine the named entity recognized by the named entity recognition model in the text to be recognized for the scene type.
  11. 如权利要求10所述的装置,其特征在于,所述装置还包括:The device of claim 10, wherein the device further comprises:
    划分模块,用于在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,将所述待识别文本按照划分单位标注内容索引,其中,内容相同的所述划分单位通过相同的内容索引进行标注;The dividing module is configured to mark the content index of the text to be recognized according to the division unit before the text to be recognized and the scene type are input into the named entity recognition model, wherein the division units with the same content pass the same Mark the content index;
    第二确定模块,用于确定所述场景类型所对应的场景类型索引;针对每个所述划分单位标注所述场景类型索引;The second determining module is configured to determine the scene type index corresponding to the scene type; mark the scene type index for each division unit;
    相应的,所述输入模块包括:Correspondingly, the input module includes:
    第一输入单元,用于将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型。The first input unit is configured to input the marked indexes of all the division units in the text to be recognized into the named entity recognition model.
  12. 如权利要求11所述的装置,其特征在于,所述命名实体识别模型包括:The apparatus of claim 11, wherein the named entity recognition model comprises:
    第一转换单元,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之后,针对每个所述划分单位,分别将被标注的不同类型的索引转换为多维向量;The first conversion unit is configured to, after inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, for each division unit, separate different types of indexes to be marked Convert to multidimensional vector;
    拼接单元,用于针对每个所述划分单位,按序拼接不同类型的索引转换后的多个多维向量;The splicing unit is used for splicing multiple multi-dimensional vectors of different types of index conversion in sequence for each of the division units;
    第二输入单元,用于将所述待识别文本中所有所述划分单位的拼接向量输入序列标注模型;The second input unit is configured to input the stitching vectors of all the division units in the text to be recognized into the sequence labeling model;
    第一获取单元,用于获取所述序列标注模型的输出结果,以得到所述待识别文本中的命名实体的标注信息。The first acquiring unit is configured to acquire the output result of the sequence annotation model to obtain the annotation information of the named entity in the text to be recognized.
  13. 如权利要求12所述的装置,其特征在于,所述序列标注模型为深度学习模型,所述深度学习模型包括:The device of claim 12, wherein the sequence labeling model is a deep learning model, and the deep learning model comprises:
    一层或多层循环神经网络,每层所述循环神经网络利用神经网络计算单元按序对所述待识别文本中每个所述划分单位的拼接向量进行计算,以输出每个所述划分单位对应的计算结果向量;One or more layers of cyclic neural network, each layer of the cyclic neural network uses a neural network calculation unit to sequentially calculate the stitching vector of each of the division units in the text to be recognized, to output each of the division units The corresponding calculation result vector;
    条件随机场,用于接收向量序列,所述向量序列包括按序排列的多个所述计算结果向量,所述多个计算结果向量为所述一层或多层循环神经网络中最后一层所述循环神经网络针对所有所述划分单位的计算结果向量,以输出用于标识每个所述划分单位是否为命名实体的标注标签。The conditional random field is used to receive a vector sequence, the vector sequence includes a plurality of the calculation result vectors arranged in order, and the plurality of calculation result vectors are the last layer of the one or more layers of the cyclic neural network. The recurrent neural network outputs a vector of calculation results for all the division units to output a label used to identify whether each division unit is a named entity.
  14. 如权利要求13所述的装置,其特征在于,所述循环神经网络为长短期记忆神经网络、或双向长短期记忆神经网络。The device according to claim 13, wherein the cyclic neural network is a long- and short-term memory neural network or a bidirectional long- and short-term memory neural network.
  15. 如权利要求13或14所述的装置,其特征在于,所述深度学习模型为利用语料进行无监督预训练得到的模型。The device according to claim 13 or 14, wherein the deep learning model is a model obtained by unsupervised pre-training using corpus.
  16. 如权利要求11-15任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 11-15, wherein the device further comprises:
    第一标注模块,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,针对所述待识别文本中的每个所述划分单位标注词性索引;The first labeling module is configured to label the part-of-speech index for each of the division units in the text to be recognized before inputting the index of all the division units in the text to be recognized into the named entity recognition model ;
    相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述词性索引。Correspondingly, the index marked for each division unit input to the named entity recognition model includes the part-of-speech index.
  17. 如权利要求11-16任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 11-16, wherein the device further comprises:
    第三确定模块,用于在将所述待识别文本中所有所述划分单位被标注的索引输入所述命名实体识别模型之前,将所述待识别文本与预设的命名实体字典匹配,确定所述待识别文本中匹配到的所有命名实体;The third determining module is configured to match the to-be-recognized text with a preset named-entity dictionary before inputting the marked indexes of all the division units in the to-be-recognized text into the named entity recognition model, and determine the State all named entities matched in the text to be recognized;
    第二标注模块,用于针对所述待识别文本中的每个所述划分单位,标注知识索引,其中,所述知识索引用于表示对应的所述划分单位在所述命名实体识别模型中所匹配到的命名实体的信息;The second labeling module is configured to label a knowledge index for each of the division units in the text to be recognized, wherein the knowledge index is used to indicate the corresponding division unit in the named entity recognition model. Information of the matched named entity;
    相应的,输入所述命名实体识别模型的每个所述划分单位被标注的索引包括所述知识索引。Correspondingly, the index marked for each division unit input to the named entity recognition model includes the knowledge index.
  18. 如权利要求10-17任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 10-17, wherein the device further comprises:
    第二获取模块,用于在将所述待识别文本和所述场景类型输入所述命名实体识别模型之前,获取本轮会话对应的待识别的第一文本;The second obtaining module is configured to obtain the first text to be recognized corresponding to the current round of conversation before the text to be recognized and the scene type are input into the named entity recognition model;
    检测模块,用于检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;A detection module, configured to detect whether a first keyword exists in the first text, and the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios;
    替换模块,用于在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;The replacement module is used to replace the first keyword in the first text with a second keyword when the first keyword exists in the first text to obtain the second keyword to be recognized text;
    相应的,所述命名实体识别模型还用于至少根据所述第二关键词和所述场景类型,在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。Correspondingly, the named entity recognition model is also used to identify a named entity in the second text at least according to the second keyword and the scene type, and the second keyword corresponds to the recognized name. The entity type corresponding to the entity is related.
  19. 如权利要求10-18任一项所述的装置,其特征在于,所述场景类型根据所述命名实体识别模型所应用的终端类型和/或应用软件的类型分类。The device according to any one of claims 10-18, wherein the scene type is classified according to the type of terminal to which the named entity recognition model is applied and/or the type of application software.
  20. 如权利要求10-19任一项所述的装置,其特征在于,所述装置应用于配置有声音接收器的电子设备,所述获取模块包括:The device according to any one of claims 10-19, wherein the device is applied to an electronic device equipped with a sound receiver, and the acquisition module comprises:
    第二获取单元,用于获取所述声音接收器采集到的语音;The second acquiring unit is configured to acquire the voice collected by the sound receiver;
    第二转换单元,用于将所述语音转换为文本,以得到所述待识别文本。The second conversion unit is used to convert the voice into text to obtain the text to be recognized.
  21. 一种命名实体的识别装置,其特征在于,所述装置包括:A device for identifying named entities, characterized in that the device comprises:
    第一获取模块,用于获取本轮会话对应的待识别的第一文本;The first obtaining module is configured to obtain the first text to be recognized corresponding to the current round of conversation;
    检测模块,用于检测所述第一文本中是否存在第一关键词,所述第一关键词用于指示所述第一文本与多轮会话场景相关;A detection module, configured to detect whether a first keyword exists in the first text, and the first keyword is used to indicate that the first text is related to multiple rounds of conversation scenarios;
    替换模块,用于在所述第一文本中存在所述第一关键词的情况下,将所述第一文本中的所述第一关键词替换为第二关键词,得到待识别的第二文本;The replacement module is used to replace the first keyword in the first text with a second keyword when the first keyword exists in the first text to obtain the second keyword to be recognized text;
    识别模块,用于至少根据所述第二关键词,利用命名实体识别模型在所述第二文本中识别命名实体,所述第二关键词与所述识别出的命名实体所对应的实体类别相关。The recognition module is configured to recognize a named entity in the second text using a named entity recognition model at least according to the second keyword, where the second keyword is related to the entity category corresponding to the recognized named entity .
  22. 如权利要求21所述的装置,其特征在于,所述装置还包括:The device of claim 21, wherein the device further comprises:
    第二获取模块,用于在检测所述第一文本中是否存在第一关键词之前,获取所述本轮会话的前一轮会话对应的待识别的第三文本的意图分析结果,以得到所述第三文本的意图类型;The second acquiring module is used to acquire the intent analysis result of the third text to be recognized corresponding to the previous round of the current conversation before detecting whether the first keyword exists in the first text, so as to obtain the State the type of intent of the third text;
    判断模块,用于判断所述第三文本的意图类型是否为指定的意图类型;相应的,如果所述第三文本的意图类型是所述指定的意图类型,则所述检测模块执行检测所述第一文本中是否存在第一关键词。The judgment module is used to judge whether the intent type of the third text is the specified intent type; correspondingly, if the intent type of the third text is the specified intent type, the detection module executes the detection of the Whether the first keyword exists in the first text.
  23. 如权利要求21或22所述的装置,其特征在于,所述装置还包括:The device according to claim 21 or 22, wherein the device further comprises:
    查找模块,用于在利用所述命名实体识别模型在所述第二文本中识别命名实体之后,在所述第一文本中,查找所述命名实体识别模型针对所述第二文本识别出的命名实体;The search module is used to search for the name recognized by the named entity recognition model for the second text in the first text after the named entity recognition model is used to identify the named entity in the second text entity;
    第一确定模块,用于如果在所述第一文本中未查找到所述命名实体,则确定对应的所述命名实体无效;A first determining module, configured to determine that the corresponding named entity is invalid if the named entity is not found in the first text;
    第二确定模块,用于如果在所述第一文本中查找到所述命名实体,则确定对应的所述命名实体有效。The second determining module is configured to determine that the corresponding named entity is valid if the named entity is found in the first text.
  24. 如权利要求21-23任一项所述的装置,其特征在于,所述第二关键词根据本轮会话的前一轮会话对应的意图分析结果确定。The device according to any one of claims 21-23, wherein the second keyword is determined according to an intent analysis result corresponding to the previous round of the current round of conversation.
  25. 如权利要求24所述的装置,其特征在于,所述第二关键词是动词和/或名词。The device of claim 24, wherein the second keyword is a verb and/or a noun.
  26. 如权利要求21-25任一项所述的装置,其特征在于,所述第一关键词用于指示所述第一文本所对应的意图不完整。The device according to any one of claims 21-25, wherein the first keyword is used to indicate that the intent corresponding to the first text is incomplete.
  27. 如权利要求21-26任一项所述的装置,其特征在于,所述检测模块包括:The device according to any one of claims 21-26, wherein the detection module comprises:
    匹配单元,用于利用预设的正则表达式在待识别文本中进行匹配,确定所述第一文本中是否存在所述第一关键词。The matching unit is configured to perform matching in the text to be recognized by using a preset regular expression to determine whether the first keyword exists in the first text.
  28. 如权利要求21-27任一项所述的装置,其特征在于,所述第二关键词对应的所述实体类别为:电影类或音乐类;所述电影类的实体类别对应的所述第二关键词为“播放”和/或“电影”;所述音乐类的实体类别对应的所述第二关键词为“听”和/或“音乐”。The device according to any one of claims 21-27, wherein the entity category corresponding to the second keyword is: movie category or music category; the first category corresponding to the entity category of the movie category The second keyword is "play" and/or "movie"; the second keyword corresponding to the entity category of the music category is "listen" and/or "music".
  29. 一种命名实体的识别设备,其特征在于,所述设备包括:A device for identifying named entities, characterized in that the device includes:
    一个或多个处理器;存储器;多个应用程序;以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述设备执行时,使得所述设备执行如权利要求1-9任一项所述的方法。One or more processors; memory; multiple application programs; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, When the instruction is executed by the device, the device is caused to execute the method according to any one of claims 1-9.
  30. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如权利要求1-9任一项所述的方法。A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which when running on a computer, causes the computer to execute the method according to any one of claims 1-9.
PCT/CN2020/102094 2019-10-15 2020-07-15 Named entity identification method and device, and computer-readable storage medium WO2021073179A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910979122.2A CN112668333A (en) 2019-10-15 2019-10-15 Named entity recognition method and device, and computer-readable storage medium
CN201910979122.2 2019-10-15

Publications (1)

Publication Number Publication Date
WO2021073179A1 true WO2021073179A1 (en) 2021-04-22

Family

ID=75400558

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/102094 WO2021073179A1 (en) 2019-10-15 2020-07-15 Named entity identification method and device, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN112668333A (en)
WO (1) WO2021073179A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342909B (en) * 2021-08-06 2021-11-02 中科雨辰科技有限公司 Data processing system for identifying identical solid models
CN113722464A (en) * 2021-09-14 2021-11-30 国泰君安证券股份有限公司 System, method, device, processor and storage medium for realizing named entity recognition processing aiming at security intelligent customer service system
CN115146627B (en) * 2022-07-26 2023-05-02 平安科技(深圳)有限公司 Entity identification method, entity identification device, electronic equipment and storage medium
CN116798417B (en) * 2023-07-31 2023-11-10 成都赛力斯科技有限公司 Voice intention recognition method, device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110035210A1 (en) * 2009-08-10 2011-02-10 Benjamin Rosenfeld Conditional random fields (crf)-based relation extraction system
CN106569998A (en) * 2016-10-27 2017-04-19 浙江大学 Text named entity recognition method based on Bi-LSTM, CNN and CRF
CN108255816A (en) * 2018-03-12 2018-07-06 北京神州泰岳软件股份有限公司 A kind of name entity recognition method, apparatus and system
CN109858040A (en) * 2019-03-05 2019-06-07 腾讯科技(深圳)有限公司 Name entity recognition method, device and computer equipment
CN109902305A (en) * 2019-03-04 2019-06-18 上海宝尊电子商务有限公司 Template generation, search and text generation apparatus and method for based on name Entity recognition
CN110096570A (en) * 2019-04-09 2019-08-06 苏宁易购集团股份有限公司 A kind of intension recognizing method and device applied to intelligent customer service robot

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10496382B2 (en) * 2018-02-22 2019-12-03 Midea Group Co., Ltd. Machine generation of context-free grammar for intent deduction
CN109918673B (en) * 2019-03-14 2021-08-03 湖北亿咖通科技有限公司 Semantic arbitration method and device, electronic equipment and computer-readable storage medium
CN110287283B (en) * 2019-05-22 2023-08-01 中国平安财产保险股份有限公司 Intention model training method, intention recognition method, device, equipment and medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110035210A1 (en) * 2009-08-10 2011-02-10 Benjamin Rosenfeld Conditional random fields (crf)-based relation extraction system
CN106569998A (en) * 2016-10-27 2017-04-19 浙江大学 Text named entity recognition method based on Bi-LSTM, CNN and CRF
CN108255816A (en) * 2018-03-12 2018-07-06 北京神州泰岳软件股份有限公司 A kind of name entity recognition method, apparatus and system
CN109902305A (en) * 2019-03-04 2019-06-18 上海宝尊电子商务有限公司 Template generation, search and text generation apparatus and method for based on name Entity recognition
CN109858040A (en) * 2019-03-05 2019-06-07 腾讯科技(深圳)有限公司 Name entity recognition method, device and computer equipment
CN110096570A (en) * 2019-04-09 2019-08-06 苏宁易购集团股份有限公司 A kind of intension recognizing method and device applied to intelligent customer service robot

Also Published As

Publication number Publication date
CN112668333A (en) 2021-04-16

Similar Documents

Publication Publication Date Title
WO2021073179A1 (en) Named entity identification method and device, and computer-readable storage medium
US11503155B2 (en) Interactive voice-control method and apparatus, device and medium
CN107818781B (en) Intelligent interaction method, equipment and storage medium
CN109697282B (en) Sentence user intention recognition method and device
CN111046656B (en) Text processing method, text processing device, electronic equipment and readable storage medium
CN112100354B (en) Man-machine conversation method, device, equipment and storage medium
US20220092276A1 (en) Multimodal translation method, apparatus, electronic device and computer-readable storage medium
US9589563B2 (en) Speech recognition of partial proper names by natural language processing
WO2018045646A1 (en) Artificial intelligence-based method and device for human-machine interaction
Simonnet et al. ASR error management for improving spoken language understanding
US11604925B1 (en) Architecture for gazetteer-augmented named entity recognition
US11170765B2 (en) Contextual multi-channel speech to text
CN113051380B (en) Information generation method, device, electronic equipment and storage medium
CN114003682A (en) Text classification method, device, equipment and storage medium
CN113326702A (en) Semantic recognition method and device, electronic equipment and storage medium
WO2022160445A1 (en) Semantic understanding method, apparatus and device, and storage medium
CN110717316B (en) Topic segmentation method and device for subtitle dialog flow
CN112347768A (en) Entity identification method and device
CN112017647B (en) Semantic-combined voice recognition method, device and system
CN114116975A (en) Multi-intention identification method and system
CN114239601A (en) Statement processing method and device and electronic equipment
CN108877781B (en) Method and system for searching film through intelligent voice
CN112183114A (en) Model training and semantic integrity recognition method and device
CN118377909B (en) Customer label determining method and device based on call content and storage medium
CN113744737B (en) Training of speech recognition model, man-machine interaction method, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20877541

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20877541

Country of ref document: EP

Kind code of ref document: A1