WO2023065635A1 - 命名实体识别方法、装置、存储介质及终端设备 - Google Patents

命名实体识别方法、装置、存储介质及终端设备 Download PDF

Info

Publication number
WO2023065635A1
WO2023065635A1 PCT/CN2022/089993 CN2022089993W WO2023065635A1 WO 2023065635 A1 WO2023065635 A1 WO 2023065635A1 CN 2022089993 W CN2022089993 W CN 2022089993W WO 2023065635 A1 WO2023065635 A1 WO 2023065635A1
Authority
WO
WIPO (PCT)
Prior art keywords
text data
named entity
entity recognition
labeled
recognition model
Prior art date
Application number
PCT/CN2022/089993
Other languages
English (en)
French (fr)
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 WO2023065635A1 publication Critical patent/WO2023065635A1/zh

Links

Images

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Definitions

  • the present application belongs to the technical field of artificial intelligence, and in particular relates to a named entity recognition method, device, computer-readable storage medium and terminal equipment.
  • Named entity recognition also known as entity recognition, entity block or entity extraction
  • NER named entity recognition
  • entity recognition entity block or entity extraction
  • IOB labeling scheme to transform it into a sequence labeling problem, in which the bidirectional long-term short-term memory network combined with the conditional random field is a typical model, and the great success of these methods benefits from a large amount of correctly labeled data.
  • the present application proposes a named entity recognition method, device, storage medium and terminal equipment to solve the problem of high cost consumption in the existing named entity recognition method.
  • the first aspect of the present application provides a named entity recognition method, the method comprising:
  • the pre-trained encoder is used as the encoder of the preset named entity recognition model, and the named entity recognition model is trained using the labeled text data in the text data set to obtain the named entity recognition after label training Model;
  • a second aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores at least one computer-readable instruction, and when the at least one computer-readable instruction is executed by a processor, the following steps are implemented:
  • the pre-trained encoder is used as the encoder of the preset named entity recognition model, and the named entity recognition model is trained using the labeled text data in the text data set to obtain the named entity recognition after label training Model;
  • a third aspect of the present application provides a terminal device, the terminal device includes a memory and a processor, the memory is used to store at least one computer-readable instruction, and the processor is used to execute the at least one computer-readable instruction to Implement the following steps:
  • the pre-trained encoder is used as the encoder of the preset named entity recognition model, and the named entity recognition model is trained using the labeled text data in the text data set to obtain the named entity recognition after label training Model;
  • a fourth aspect of the present application provides a named entity recognition device, the device comprising:
  • the encoder pre-training module is used to pre-train the encoder in the preset twin network using the text data in the preset text data set to obtain the pre-trained encoder;
  • the model training module is used to use the pre-trained encoder as the encoder of the preset named entity recognition model, and use the labeled text data in the text data set to train the named entity recognition model to obtain the labeled The trained named entity recognition model;
  • the model prediction module is used to predict the unlabeled text data in the text data set by using the named entity recognition model after the label training, and obtain the first type of text data after the model annotation and the second type of text to be manually labeled data;
  • a new module for labeling text data is used to obtain the second type of text data after manual labeling, and use the first type of text data after the model labeling and the second type of text data after manual labeling as newly added labeling text data;
  • a model adjustment module configured to use the newly added labeled text data to adjust the labeled and trained named entity recognition model to obtain the adjusted named entity recognition model
  • the named entity recognition module is configured to obtain target text data to be recognized, and use the adjusted named entity recognition model to process the target text data to obtain entity categories of each named entity in the target text data.
  • the named entity recognition method, device, storage medium and terminal equipment described in this application effectively reduce the consumption of time and money costs.
  • FIG. 1 is a flowchart of an embodiment of a named entity recognition method in the embodiment of the present application
  • Fig. 2 is the schematic flowchart of pre-training the encoder in the preset Siamese network using the text data in the preset text data set;
  • Fig. 3 is the schematic flowchart of using the labeled text data in the text data set to train the named entity recognition model
  • FIG. 5 is a structural diagram of an embodiment of a named entity recognition device in the embodiment of the present application.
  • FIG. 6 is a schematic block diagram of a terminal device in an embodiment of the present application.
  • AI artificial intelligence
  • digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
  • Artificial intelligence basic technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation/interaction systems, and mechatronics.
  • Artificial intelligence software technology mainly includes computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning/deep learning.
  • the execution subject of the embodiment of the present application may be a terminal device based on artificial intelligence, which is used to execute the named entity recognition method in the embodiment of the present application.
  • an embodiment of a named entity recognition method in the embodiment of the present application may include:
  • Step S101 using the text data in the preset text data set to pre-train the encoder in the preset Siamese network to obtain the pre-trained encoder.
  • step S101 may specifically include the following process:
  • Step S1011 performing data enhancement on the text data in the text data set to obtain a preset number of enhanced text data pairs.
  • the text data set may include labeled text data and unlabeled text data. Any one of the enhanced text data pairs includes two different enhanced text data obtained by performing data enhancement on the same text data.
  • the dropout method can be used for data enhancement, that is, the dropout operation is performed on the text data by randomly sampling the dropout mask. , two consecutive dropout operations are performed on the same text data, and two different enhanced text data can be obtained respectively, thereby forming an enhanced text data pair.
  • Step S1012 using the Siamese network to process the enhanced text data pair to obtain a first feature vector and a second feature vector respectively.
  • Described twin network can be SimSiam network, comprises two processing branches (respectively denoted as branch 1 and branch 2) in SimSiam network, respectively to two enhanced text data in the enhanced text data pair (respectively denoted as text data 1 and text data data 2) for processing, wherein, the encoder (encoder) in branch 1 encodes the text data 1 to obtain the first feature vector; the encoder in branch 2 encodes the text data 2, and the encoding result passes through the predictor ( predictor) to obtain the second eigenvector. It should be noted that the encoder in branch 1 and the encoder in branch 2 share the same parameters and can be considered as the same encoder.
  • Step S1013 calculating a first loss function according to the first feature vector and the second feature vector.
  • the first loss function can be calculated according to the following formula:
  • p 1 is the first eigenvector
  • z 2 is the second eigenvector
  • 2 is the modulus of the first eigenvector
  • 2 is the first eigenvector the magnitude of two eigenvectors, is the first loss function.
  • Step S1014 pre-training the encoder in the Siamese network with the goal of minimizing the first loss function to obtain a pre-trained encoder.
  • the model parameters of the Siamese network can be adjusted according to the first loss function.
  • the model parameter of the twin network is W1
  • the first loss function is backpropagated to modify the model parameter W1 of the twin network to obtain the modified model parameter W2.
  • each training process can modify the model parameters of the twin network until the preset training conditions are met, wherein the training conditions can be The number of training times reaches the preset number of times threshold, which can be set according to the actual situation, for example, it can be set to thousands, tens of thousands, hundreds of thousands or even a larger value; the training condition can also be that the twin network converges ; Since the number of training times may not reach the number threshold, but the twin network has converged, unnecessary work may be repeated; or the twin network cannot converge, which may lead to an infinite loop, and the training process cannot be ended.
  • the training conditions can be The number of training times reaches the preset number of times threshold, which can be set according to the actual situation, for example, it can be set to thousands, tens of thousands, hundreds of thousands or even a larger value; the training condition can also be that the twin network converges ; Since the number of training times may not reach the number threshold, but the twin network has converged, unnecessary work may be repeated; or the twin network cannot converge
  • the training condition may also be that the number of training times reaches a threshold or the twin network converges.
  • the training conditions are met, the pre-trained twin network can be obtained, and the encoder at this time is the pre-trained encoder.
  • Step S102 using the pre-trained encoder as the encoder of the preset named entity recognition model, and using the labeled text data in the text dataset to train the named entity recognition model to obtain the labeled and trained Named entity recognition model.
  • step S102 may specifically include the following process:
  • Step S1021 using the encoder of the named entity recognition model to encode the labeled text data in the text dataset to obtain encoded feature vectors.
  • FIG. 4 is a schematic diagram of the named entity recognition model, and the named entity recognition model may include an encoder and a multi-layer perceptron (Multi-Layer Perception).
  • i is the sequence number of the labeled text data in the text data set
  • x i is the i-th labeled text data in the text data set
  • 1 ⁇ i ⁇ n is the number of labeled text data in the text data set
  • the encoder of the named entity recognition model encodes xi to obtain an encoded feature vector corresponding to xi , which is denoted as hi .
  • Step S1022 using the multi-layer perceptron of the named entity recognition model to process the encoded feature vectors to obtain the probability distribution of entity categories.
  • the probability distribution of entity categories can be calculated according to the following formula:
  • U and V are preset model parameters
  • Softmax is a preset activation function
  • p i is the probability distribution of the entity category corresponding to x i .
  • Step S1023 calculating a second loss function according to the probability distribution.
  • the second loss function can be calculated according to the following formula:
  • z i is the entity category label corresponding to x i , that is, the entity category manually marked in advance, and loss is the second loss function.
  • Step S1024 train the named entity recognition model with the goal of minimizing the second loss function, and obtain a labeled and trained named entity recognition model.
  • the model parameters of the named entity recognition model may be adjusted according to the second loss function.
  • the second loss function is backpropagated to modify the model parameter V1 of the named entity recognition model to obtain the modified model parameter V2.
  • each training process can modify the model parameters of the named entity recognition model until the preset training conditions are met, wherein,
  • the training condition can be that the number of training times reaches the preset number threshold, and the number threshold can be set according to the actual situation, for example, it can be set to a value of thousands, tens of thousands, hundreds of thousands or even greater; the training condition can also be all
  • the named entity recognition model converges; because the number of training times may not reach the number threshold, but the named entity recognition model has converged, which may cause unnecessary work to be repeated; or the named entity recognition model cannot converge all the time, which may lead to infinite Cycle, the training process cannot be ended.
  • the training condition can also be that the number of training times reaches the number threshold or the named entity recognition model converges. When the training conditions are met, the labeled and trained named entity recognition model can be obtained.
  • Step S103 use the labeled trained named entity recognition model to predict the unlabeled text data in the text data set, and obtain the first type of text data marked by the model and the second type of text data to be manually labeled.
  • the unlabeled text data in the text data set may be predicted by using the named entity recognition model trained with the annotation, and the confidence of the prediction result may be calculated. Then, the unlabeled text data whose confidence degree of the prediction result is greater than or equal to the preset confidence threshold can be regarded as the first type of text data, that is, the text data that is easier to be marked by the model; the confidence degree of the prediction result is less than the confidence threshold
  • the unlabeled text data with degree threshold is regarded as the second type of text data, that is, the text data that is difficult to be annotated by the model.
  • the confidence threshold can be set according to the actual situation, which is not specifically limited in this embodiment of the present application.
  • Step S104 acquiring the second type of text data manually marked, and using the first type of text data marked by the model and the second type of text data after manual marking as newly added marked text data.
  • experts can be arranged to manually label the selected second type of text data.
  • the text data that is easier to label through the model can be directly labeled with the model, and only the selected Manually annotate the text data that is difficult to annotate through the model, which greatly improves the overall efficiency of the model.
  • Step S105 using the newly added labeled text data to adjust the labeled and trained named entity recognition model to obtain an adjusted named entity recognition model.
  • the adjustment of the model is a continuous iterative process, that is, continuously repeating steps S103 to S105, continuously transforming unlabeled text data into labeled text data, and using the newly added labeled text data for a new round of Model adjustment until the final named entity recognition model reaches the predetermined recognition accuracy.
  • the model can be used for named entity recognition.
  • Step S106 acquire target text data to be recognized, and use the adjusted named entity recognition model to process the target text data to obtain entity categories of each named entity in the target text data.
  • the target text data may be pre-stored in the terminal device, or sent to the terminal device by other devices through a preset communication method, or input by a user through a preset human-computer interaction interface to the terminal device.
  • the terminal device can use the adjusted named entity recognition model to process the target text data, so as to obtain the entity category of each named entity in the target text data. For example, if the target text data is "Xiao Ming goes to school at 8 o'clock in the morning.”, then after the adjusted named entity recognition model is processed, the final recognition result is: (named entity: Xiao Ming, entity category: PersonName); (Named Entity: 8AM, EntityType: Time); (NamedEntity: School, EntityType: Location).
  • the embodiment of the present application uses the text data in the preset text data set to pre-train the encoder in the preset Siamese network to obtain the pre-trained encoder; the pre-trained encoder As an encoder of a preset named entity recognition model, and use the labeled text data in the text data set to train the named entity recognition model to obtain a named entity recognition model after labeling training; use the labeled text data after training
  • the named entity recognition model predicts the unlabeled text data in the text data set, and obtains the first type of text data marked by the model and the second type of text data to be manually marked; obtains the second type of text data after manual marking, And the first type of text data after the model annotation and the second type of text data after the manual annotation are used as newly added annotation text data; using the newly added annotation text data to identify the named entity after the annotation training Adjust the model to obtain an adjusted named entity recognition model; obtain the target text data to be recognized, and use the adjusted named entity recognition model to process the target text data to obtain each of the target text
  • active learning and comparative learning are integrated.
  • the method of comparative learning is used to pre-train the encoder and be used for the training of the named entity recognition model.
  • the model is continuously improved through the feedback received.
  • Self-iterative training and optimization the whole process requires only a small amount of manual labeling, which effectively reduces the consumption of time and money costs.
  • FIG. 5 shows a structural diagram of an embodiment of a named entity recognition device provided in an embodiment of the present application.
  • a device for named entity recognition may include:
  • the encoder pre-training module 501 is used to pre-train the encoder in the preset Siamese network using the text data in the preset text data set to obtain the pre-trained encoder;
  • the model training module 502 is used to use the pre-trained encoder as the encoder of the preset named entity recognition model, and use the labeled text data in the text data set to train the named entity recognition model to obtain Annotate the trained named entity recognition model;
  • the model prediction module 503 is used to predict the unlabeled text data in the text data set using the named entity recognition model trained by the label, and obtain the first type of text data marked by the model and the second type of text data to be manually labeled text data;
  • Annotate text data adding module 504, configured to obtain the second type of text data after manual annotation, and use the first type of text data after the model annotation and the second type of text data after the manual annotation as new annotations text data;
  • a model adjustment module 505, configured to use the newly added labeled text data to adjust the labeled and trained named entity recognition model to obtain the adjusted named entity recognition model;
  • a named entity recognition module 506 configured to acquire target text data to be recognized, and use the adjusted named entity recognition model to process the target text data to obtain the entity category of each named entity in the target text data .
  • the encoder pre-training module may include:
  • a data enhancement unit configured to perform data enhancement on the text data in the text data set to obtain a preset number of enhanced text data pairs; wherein, any one of the enhanced text data pairs includes the same text data after data enhancement The obtained two different enhanced text data;
  • a Siamese network processing unit configured to use the Siamese network to process the enhanced text data pair to obtain a first feature vector and a second feature vector;
  • a first loss function calculation unit configured to calculate a first loss function according to the first feature vector and the second feature vector
  • a pre-training unit configured to pre-train the encoder in the Siamese network with the goal of minimizing the first loss function, to obtain a pre-trained encoder.
  • the first loss function calculation unit may be specifically configured to calculate the first loss function according to the following formula:
  • p 1 is the first eigenvector
  • z 2 is the second eigenvector
  • 2 is the modulus of the first eigenvector
  • 2 is the first eigenvector the magnitude of two eigenvectors, is the first loss function.
  • the model training module may include:
  • An encoding unit configured to use the encoder of the named entity recognition model to encode the labeled text data in the text dataset to obtain encoded feature vectors
  • a multi-layer perceptron unit configured to use the multi-layer perceptron of the named entity recognition model to process the encoded feature vector to obtain the probability distribution of entity categories;
  • a second loss function calculation unit configured to calculate a second loss function according to the probability distribution
  • a model training unit configured to train the named entity recognition model with the goal of minimizing the second loss function, to obtain a labeled and trained named entity recognition model.
  • the multi-layer perception unit may be specifically configured to calculate the probability distribution of entity categories according to the following formula:
  • i is the sequence number of the labeled text data in the text data set
  • hi is the encoded feature vector corresponding to the i-th labeled text data in the text data set
  • U and V are preset model parameters
  • Softmax is a preset activation function
  • p i is the probability distribution of the entity category corresponding to the i-th labeled text data in the text dataset.
  • the second loss function calculation unit may be specifically configured to calculate the second loss function according to the following formula:
  • n is the number of labeled text data in the text dataset
  • zi is the entity category label corresponding to the i-th labeled text data in the text dataset
  • loss is the second loss function.
  • the model prediction module may include:
  • a prediction unit configured to use the named entity recognition model trained by the annotation to predict the unlabeled text data in the text data set, and calculate the confidence of the prediction result
  • a first-type text data determination unit configured to use unlabeled text data whose confidence degree of the prediction result is greater than or equal to a preset confidence threshold as the first-type text data
  • the second-type text data determining unit is configured to use unlabeled text data whose confidence degree of the prediction result is less than the confidence threshold as the second-type text data.
  • FIG. 6 shows a schematic block diagram of a terminal device provided by an embodiment of the present application. For ease of description, only parts related to the embodiment of the present application are shown.
  • the terminal device 6 may be a computing device such as a desktop computer, a notebook, or a palmtop computer.
  • the terminal device 6 may include: a processor 60, a memory 61, and computer-readable instructions 62 stored in the memory 61 and operable on the processor 60, such as computer-readable instructions for executing the above named entity recognition method. instruction.
  • the processor 60 executes the computer-readable instructions 62
  • the steps in the embodiments of the above-mentioned named entity recognition methods are implemented, such as steps S101 to S106 shown in FIG. 1 .
  • the processor 60 executes the computer-readable instructions 62
  • the functions of the modules/units in the above-mentioned device embodiments are implemented, for example, the functions of the modules 501 to 506 shown in FIG. 5 .
  • the computer-readable instructions 62 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 61 and executed by the processor 60, to complete this application.
  • the one or more modules/units may be a series of computer-readable instruction segments capable of accomplishing specific functions, and the instruction segments are used to describe the execution process of the computer-readable instructions 62 in the terminal device 6 .
  • the processor 60 can be a central processing unit (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the storage 61 may be an internal storage unit of the terminal device 6 , such as a hard disk or memory of the terminal device 6 .
  • the memory 61 can also be an external storage device of the terminal device 6, such as a plug-in hard disk equipped on the terminal device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash memory card (Flash Card), etc. Further, the memory 61 may also include both an internal storage unit of the terminal device 6 and an external storage device.
  • the memory 61 is used to store the computer-readable instructions and other instructions and text data required by the terminal device 6 .
  • the memory 61 can also be used to temporarily store text data that has been output or will be output.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function, etc.; The data created using the node, etc.
  • Each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may physically exist separately, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several computer-readable instructions to enable a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, etc., which can store computer-readable instructions. medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请属于人工智能技术领域,尤其涉及一种命名实体识别方法、装置、计算机可读存储介质及终端设备。所述方法包括:对孪生网络中的编码器进行预训练,将其作为命名实体识别模型的编码器,使用标注文本数据对模型进行训练,得到标注训练后的模型;使用标注训练后的模型对无标注文本数据进行预测,得到第一类和第二类文本数据;获取人工标注后的第二类文本数据,并将模型标注后的第一类文本数据和人工标注后的第二类文本数据作为新增标注文本数据;使用新增标注文本数据对标注训练后的模型进行调整,得到调整后的模型;获取待识别的目标文本数据,使用调整后的模型对目标文本数据进行处理,得到目标文本数据中的各个命名实体的实体类别。

Description

命名实体识别方法、装置、存储介质及终端设备
本申请要求于2021年10月22日提交中国专利局,申请号为202111233302.X申请名称为“命名实体识别方法、装置、存储介质及终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于人工智能技术领域,尤其涉及一种命名实体识别方法、装置、计算机可读存储介质及终端设备。
背景技术
命名实体识别(Named Entity Recognition,NER)也称为实体识别、实体分块或实体提取,是信息提取的一个子任务,旨在对非结构化文本中的命名实体进行定位和分类,将其分类为预定义类别,如人名、组织、位置、医疗代码、时间表达式、数量、货币价值、百分比等。现有技术中的方法通常采用IOB标记方案将其转化为序列标记问题,其中双向长短期记忆网络结合条件随机场是典型的模型,这些方法取得的巨大成功得益于大量正确人工标注的数据。但是,发明人发现在实际的命名实体识别的场景中,即使只人工标注几千或者几万个训练数据,所消耗的时间和金钱成本也是巨大的,而为了获得更高的识别准确率,则需要更多的标注数据,也会造成更大的成本消耗。
发明内容
本申请提出一种命名实体识别方法、装置、存储介质及终端设备,以解决现有的命名实体识别方法成本消耗较大的问题。
本申请的第一方面提供一种命名实体识别方法,所述方法包括:
使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
本申请的第二方面提供一种计算机可读存储介质,所述计算机可读存储介质存储有至少一个计算机可读指令,所述至少一个计算机可读指令被处理器执行时实现以下步骤:
使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
本申请的第三方面提供一种终端设备,所述终端设备包括存储器及处理器,所述存储器用于存储至少一个计算机可读指令,所述处理器用于执行所述至少一个计算机可读指令以实现以下步骤:
使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
本申请的第四方面提供一种命名实体识别装置,所述装置包括:
编码器预训练模块,用于使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
模型训练模块,用于将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
模型预测模块,用于使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
标注文本数据新增模块,用于获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
模型调整模块,用于使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
命名实体识别模块,用于获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
本申请所述的命名实体识别方法、装置、存储介质及终端设备,有效减少了对于时间和金钱成本的消耗。
附图说明
图1为本申请实施例中一种命名实体识别方法的一个实施例流程图;
图2为使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练的示意流程图;
图3为使用文本数据集中的标注文本数据对命名实体识别模型进行训练的示意流程图;
图4为命名实体识别模型的示意图;
图5为本申请实施例中一种命名实体识别装置的一个实施例结构图;
图6为本申请实施例中一种终端设备的示意框图。
具体实施方式
为使得本申请的发明目的、特征、优点能够更加的明显和易懂,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,下面所描述的实施例仅仅是本申请一部分实施例,而非全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
本申请实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。
人工智能基础技术一般包括如传感器、专用人工智能芯片、云计算、分布式存储、大数据处理技术、操作/交互系统、机电一体化等技术。人工智能软件技术主要包括计算机视觉技术、机器人技术、生物识别技术、语音处理技术、自然语言处理技术以及机器学习/深度学习等几大方向。
本申请实施例的执行主体可以为基于人工智能的终端设备,用于执行本申请实施例中的命名实体识别方法。
请参阅图1,本申请实施例中一种命名实体识别方法的一个实施例可以包括:
步骤S101、使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器。
如图2所示,步骤S101具体可以包括如下过程:
步骤S1011、对所述文本数据集中的文本数据进行数据增强,得到预设数量的增强文本数据对。
其中,所述文本数据集中可以包括标注文本数据和无标注文本数据。任意一个所述增强文本数据对中均包括由同一文本数据进行数据增强后的得到的两个不同的增强文本数据。
在本申请实施例中,通过对同一样本进行数据增强,能够得到一系列自相似的文本数据对作为正例。具体采用何种数据增强方法,可以根据实际情况进行设置,例如,在一种实现方式中,可以使用dropout方法进行数据增强,即通过随机采样dropout掩码(dropout mask)来对文本数据进行dropout操作,同一个文本数据进行连续两次的dropout操作,可以分别得到两个不同的增强文本数据,从而组成一个增强文本数据对。
需要注意的是,以上仅为举例,而非对数据增强方法的限定,在实际应用中,可以根据具体情况采用现有技术中其它的数据增强方法,本申请实施例对此不作具体限定。
步骤S1012、使用所述孪生网络对所述增强文本数据对进行处理,分别得到第一特征向量和第二特征向量。
所述孪生网络可以为SimSiam网络,SimSiam网络中包括两条处理分支(分别记为分支1和分支2),分别对增强文本数据对中的两个增强文本数据(分别记为文本数据1和文本数据2)进行处理,其中,分支1中的编码器(encoder)对文本数据1进行编码,得到第一特征向量;分支2中的编码器对文本数据2进行编码,编码结果再经过预测器(predictor)的非线性变化,得到第二特征向量。需要注意的是,分支1中的编码器和分支2中的编码器共用相同的参数,可以将其认为是同一个编码器。
步骤S1013、根据所述第一特征向量和所述第二特征向量计算第一损失函数。
具体地,可以根据下式计算所述第一损失函数:
Figure PCTCN2022089993-appb-000001
其中,p 1为所述第一特征向量,z 2为所述第二特征向量,||p 1|| 2为所述第一特征向量的模,||z 2|| 2为所述第二特征向量的模,
Figure PCTCN2022089993-appb-000002
为所述第一损失函数。
步骤S1014、以最小化所述第一损失函数为目标对所述孪生网络中的编码器进行预训练,得到预训练后的编码器。
在计算得到所述第一损失函数之后,则可以根据第所述第一损失函数对所述孪生网络的模型参数进行调整。在本申请实施例中,假设所述孪生网络的模型参数为W1,将第一损失函数反向传播修改所述孪生网络的模型参数W1,得到修改后的模型参数W2。修改参数之后再继续执行下一次的训练过程,在该次训练过程中,重新计算得到所述第一损失函数,将所述第一损失函数反向传播修改所述孪生网络的模型参数W2,得到修改后的模型参数W3,……,以此类推,不断重复以上过程,每次训练过程均可对所述孪生网络的模型参数进行修改,直至满足预设的训练条件,其中,训练条件可以是训练次数达到预设的次数阈值,次数阈值可以根据实际情况进行设置,例如,可以将其设置为数千、数万、数十万甚至更大的数值;训练条件也可以是所述孪生网络收敛;由于可能出现训练次数还未达到次数阈值,但所述孪生网络已经收敛,可能导致重复不必要的工作;或者所述孪生网络始终无法收敛,可能导致无限循环,无法结束训练的过程,基于上述两种情况,训练条件还可以是训练次数达到次数阈值或所述孪生网络收敛。当满足训练条件,即可得到预训练后的孪生网络,此时的编码器即为预训练后的编码器。
通过本申请实施例中的这种对比学习方式,编码器的参数已得到优化,可用于后续的命名实体识别过程。
步骤S102、将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
如图3所示,步骤S102具体可以包括如下过程:
步骤S1021、使用所述命名实体识别模型的编码器对所述文本数据集中的标注文本数据进行编码,得到编码后的特征向量。
图4所示即为所述命名实体识别模型的示意图,所述命名实体识别模型可以包括编码器和多层感知器(Multi-Layer Perception)。i为所述文本数据集中的标注文本数据的序号,x i为所述文本数据集中的第i个标注文本数据,1≤i≤n,n为所述文本数据集中的标注文本数据的数目,所述命名实体识别模型的编码器对x i进行编码,得到与x i对应的编码后的特征向量,将其记为h i
步骤S1022、使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布。
具体地,可以根据下式计算实体类别的概率分布:
p i=Softmax(U tanh(Vh i))
其中,U和V均为预设的模型参数,Softmax为预设的激励函数,p i为与x i对应的实体类别的概率分布。
步骤S1023、根据所述概率分布计算第二损失函数。
具体地,可以根据下式计算所述第二损失函数:
Figure PCTCN2022089993-appb-000003
其中,z i为与x i对应的实体类别标签,即预先人工标注的实体类别,loss为所述第二损失 函数。
步骤S1024、以最小化所述第二损失函数为目标对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
在计算得到所述第二损失函数之后,则可以根据第所述第二损失函数对所述命名实体识别模型的模型参数进行调整。在本申请实施例中,假设所述命名实体识别模型的模型参数为V1,将第二损失函数反向传播修改所述命名实体识别模型的模型参数V1,得到修改后的模型参数V2。修改参数之后再继续执行下一次的训练过程,在该次训练过程中,重新计算得到所述第二损失函数,将所述第二损失函数反向传播修改所述命名实体识别模型的模型参数V2,得到修改后的模型参数V3,……,以此类推,不断重复以上过程,每次训练过程均可对所述命名实体识别模型的模型参数进行修改,直至满足预设的训练条件,其中,训练条件可以是训练次数达到预设的次数阈值,次数阈值可以根据实际情况进行设置,例如,可以将其设置为数千、数万、数十万甚至更大的数值;训练条件也可以是所述命名实体识别模型收敛;由于可能出现训练次数还未达到次数阈值,但所述命名实体识别模型已经收敛,可能导致重复不必要的工作;或者所述命名实体识别模型始终无法收敛,可能导致无限循环,无法结束训练的过程,基于上述两种情况,训练条件还可以是训练次数达到次数阈值或所述命名实体识别模型收敛。当满足训练条件,即可得到标注训练后的命名实体识别模型。
步骤S103、使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据。
具体地,可以使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,并计算预测结果的置信度。然后可以将预测结果的置信度大于或等于预设的置信度阈值的无标注文本数据作为第一类文本数据,即较易通过模型进行标注的文本数据;将预测结果的置信度小于所述置信度阈值的无标注文本数据作为第二类文本数据,即难以通过模型进行标注的文本数据。例如,如果是对“Mary”进行标注,如果模型给出的预测标注为实体类别“PER”和“LOC”的概率较为接近,则无法确定其最终的标注结果,因此可将其作为第二类文本数据,需要筛选出来进行人工标注。所述置信度阈值的具体取值可以根据实际情况进行设置,本申请实施例对此不作具体限定。
步骤S104、获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据。
在本申请实施例中,可以安排专家对筛选出来的第二类文本数据进行人工标注,通过这样的主动学习方式,对较易通过模型进行标注的文本数据直接使用模型进行标注,仅将经过筛选的难以通过模型进行标注的文本数据进行人工标注,极大提高模型的整体效率。
步骤S105、使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型。
经过上述过程,一部分的无标注文本数据转变成了标记文本数据,标记文本数据的数量在该过程中不断增多,可以继续使用新增标注文本数据对命名实体识别模型进行调整,得到调整后的命名实体识别模型。
需要注意的是,模型的调整是一个持续迭代的过程,即不断地重复步骤S103至步骤S105,持续地将无标注文本数据转变为标记文本数据,并使用新增标注文本数据进行新一轮的模型调整,直至最终得到的命名实体识别模型达到预定的识别精度为止。在后续的命名实体识别任务中,即可使用该模型进行命名实体识别。
步骤S106、获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
所述目标文本数据可以是预先存储于所述终端设备中,也可以是由其他设备通过预设的通信方式发送至所述终端设备中,还可以是由用户通过预设的人机交互界面输入到所述终端设备中。当需要进行命名实体识别时,所述终端设备即可使用所述调整后的命名实体识别模 型对所述目标文本数据进行处理,从而得到所述目标文本数据中的各个命名实体的实体类别。例如,若所述目标文本数据为“小明早上8点去学校上课。”,则经过所述调整后的命名实体识别模型处理之后,最终得到的识别结果为:(命名实体:小明,实体类别:人名);(命名实体:早上8点,实体类别:时间);(命名实体:学校,实体类别:地点)。
综上所述,本申请实施例使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。通过本申请实施例,将主动学习与对比学习进行融合,首先利用对比学习的方法预训练编码器并用于命名实体识别模型的训练,在随后的主动学习过程中,模型通过收到的反馈不断进行自我的迭代训练与优化,整个过程仅需少量的人工标注,有效减少了对于时间和金钱成本的消耗。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的一种命名实体识别方法,图5示出了本申请实施例提供的一种命名实体识别装置的一个实施例结构图。
本实施例中,一种命名实体识别装置可以包括:
编码器预训练模块501,用于使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
模型训练模块502,用于将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
模型预测模块503,用于使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
标注文本数据新增模块504,用于获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
模型调整模块505,用于使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
命名实体识别模块506,用于获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
在本申请实施例的一种具体实现方式中,所述编码器预训练模块可以包括:
数据增强单元,用于对所述文本数据集中的文本数据进行数据增强,得到预设数量的增强文本数据对;其中,任意一个所述增强文本数据对中均包括由同一文本数据进行数据增强后的得到的两个不同的增强文本数据;
孪生网络处理单元,用于使用所述孪生网络对所述增强文本数据对进行处理,分别得到第一特征向量和第二特征向量;
第一损失函数计算单元,用于根据所述第一特征向量和所述第二特征向量计算第一损失函数;
预训练单元,用于以最小化所述第一损失函数为目标对所述孪生网络中的编码器进行预训练,得到预训练后的编码器。
在本申请实施例的一种具体实现方式中,所述第一损失函数计算单元可以具体用于根据下式计算所述第一损失函数:
Figure PCTCN2022089993-appb-000004
其中,p 1为所述第一特征向量,z 2为所述第二特征向量,||p 1|| 2为所述第一特征向量的模,||z 2|| 2为所述第二特征向量的模,
Figure PCTCN2022089993-appb-000005
为所述第一损失函数。
在本申请实施例的一种具体实现方式中,所述模型训练模块可以包括:
编码单元,用于使用所述命名实体识别模型的编码器对所述文本数据集中的标注文本数据进行编码,得到编码后的特征向量;
多层感知单元,用于使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布;
第二损失函数计算单元,用于根据所述概率分布计算第二损失函数;
模型训练单元,用于以最小化所述第二损失函数为目标对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
在本申请实施例的一种具体实现方式中,所述多层感知单元可以具体用于根据下式计算实体类别的概率分布:
p i=Softmax(U tanh(Vh i))
其中,i为所述文本数据集中的标注文本数据的序号,h i为与所述文本数据集中的第i个标注文本数据对应的编码后的特征向量,U和V均为预设的模型参数,Softmax为预设的激励函数,p i为与所述文本数据集中的第i个标注文本数据对应的实体类别的概率分布。
在本申请实施例的一种具体实现方式中,所述第二损失函数计算单元可以具体用于根据下式计算所述第二损失函数:
Figure PCTCN2022089993-appb-000006
其中,n为所述文本数据集中的标注文本数据的数目,z i为与所述文本数据集中的第i个标注文本数据对应的实体类别标签,loss为所述第二损失函数。
在本申请实施例的一种具体实现方式中,所述模型预测模块可以包括:
预测单元,用于使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,并计算预测结果的置信度;
第一类文本数据确定单元,用于将预测结果的置信度大于或等于预设的置信度阈值的无标注文本数据作为所述第一类文本数据;
第二类文本数据确定单元,用于将预测结果的置信度小于所述置信度阈值的无标注文本数据作为所述第二类文本数据。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置,模块和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
图6示出了本申请实施例提供的一种终端设备的示意框图,为了便于说明,仅示出了与本申请实施例相关的部分。
在本实施例中,所述终端设备6可以是桌上型计算机、笔记本、掌上电脑等计算设备。该终端设备6可包括:处理器60、存储器61以及存储在所述存储器61中并可在所述处理器60上运行的计算机可读指令62,例如执行上述的命名实体识别方法的计算机可读指令。所述处理器60执行所述计算机可读指令62时实现上述各个命名实体识别方法实施例中的步骤, 例如图1所示的步骤S101至S106。或者,所述处理器60执行所述计算机可读指令62时实现上述各装置实施例中各模块/单元的功能,例如图5所示模块501至506的功能。
示例性的,所述计算机可读指令62可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器61中,并由所述处理器60执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机可读指令段,该指令段用于描述所述计算机可读指令62在所述终端设备6中的执行过程。
所述处理器60可以是中央处理单元(Central Processing Unit,CPU),还可以是其它通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器61可以是所述终端设备6的内部存储单元,例如终端设备6的硬盘或内存。所述存储器61也可以是所述终端设备6的外部存储设备,例如所述终端设备6上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器61还可以既包括所述终端设备6的内部存储单元也包括外部存储设备。所述存储器61用于存储所述计算机可读指令以及所述终端设备6所需的其它指令和文本数据。所述存储器61还可以用于暂时地存储已经输出或者将要输出的文本数据。
进一步地,所述计算机可读存储介质可以是非易失性,也可以是易失性。
进一步地,所述计算机可读存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。
在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干计算机可读指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储计算机可读指令的介质。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种命名实体识别方法,其中,所述方法包括:
    使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
    将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
    使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
    获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
    使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
    获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
  2. 根据权利要求1所述的命名实体识别方法,其中,所述使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器,包括:
    对所述文本数据集中的文本数据进行数据增强,得到预设数量的增强文本数据对;其中,任意一个所述增强文本数据对中均包括由同一文本数据进行数据增强后的得到的两个不同的增强文本数据;
    使用所述孪生网络对所述增强文本数据对进行处理,分别得到第一特征向量和第二特征向量;
    根据所述第一特征向量和所述第二特征向量计算第一损失函数;
    以最小化所述第一损失函数为目标对所述孪生网络中的编码器进行预训练,得到预训练后的编码器。
  3. 根据权利要求2所述的命名实体识别方法,其中,所述根据所述第一特征向量和所述第二特征向量计算第一损失函数,包括:
    根据下式计算所述第一损失函数:
    Figure PCTCN2022089993-appb-100001
    其中,p 1为所述第一特征向量,z 2为所述第二特征向量,||p 1|| 2为所述第一特征向量的模,||z 2|| 2为所述第二特征向量的模,
    Figure PCTCN2022089993-appb-100002
    为所述第一损失函数。
  4. 根据权利要求1所述的命名实体识别方法,其中,所述使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型,包括:
    使用所述命名实体识别模型的编码器对所述文本数据集中的标注文本数据进行编码,得到编码后的特征向量;
    使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布;
    根据所述概率分布计算第二损失函数;
    以最小化所述第二损失函数为目标对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
  5. 根据权利要求4所述的命名实体识别方法,其中,所述使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布,包括:
    根据下式计算实体类别的概率分布:
    p i=Softmax(U tanh(Vh i))
    其中,i为所述文本数据集中的标注文本数据的序号,h i为与所述文本数据集中的第i个标注文本数据对应的编码后的特征向量,U和V均为预设的模型参数,Softmax为预设的激励函数,p i为与所述文本数据集中的第i个标注文本数据对应的实体类别的概率分布。
  6. 根据权利要求5所述的命名实体识别方法,其中,所述根据所述概率分布计算第二损失函数,包括:
    根据下式计算所述第二损失函数:
    Figure PCTCN2022089993-appb-100003
    其中,n为所述文本数据集中的标注文本数据的数目,z i为与所述文本数据集中的第i个标注文本数据对应的实体类别标签,loss为所述第二损失函数。
  7. 根据权利要求1至6中任一项所述的命名实体识别方法,其中,所述使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据,包括:
    使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,并计算预测结果的置信度;
    将预测结果的置信度大于或等于预设的置信度阈值的无标注文本数据作为所述第一类文本数据;
    将预测结果的置信度小于所述置信度阈值的无标注文本数据作为所述第二类文本数据。
  8. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有至少一个计算机可读指令,所述至少一个计算机可读指令被处理器执行时实现以下步骤:
    使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
    将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
    使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
    获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
    使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
    获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
  9. 根据权利要求8所述的存储介质,其中,所述至少一个计算机可读指令被所述处理器执行以实现所述使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器时,具体包括:
    对所述文本数据集中的文本数据进行数据增强,得到预设数量的增强文本数据对;其中,任意一个所述增强文本数据对中均包括由同一文本数据进行数据增强后的得到的两个不同的增强文本数据;
    使用所述孪生网络对所述增强文本数据对进行处理,分别得到第一特征向量和第二特征向量;
    根据所述第一特征向量和所述第二特征向量计算第一损失函数;
    以最小化所述第一损失函数为目标对所述孪生网络中的编码器进行预训练,得到预训练后的编码器。
  10. 根据权利要求9所述的存储介质,其中,所述至少一个计算机可读指令被所述处理 器执行以实现所述根据所述第一特征向量和所述第二特征向量计算第一损失函数时,具体包括:
    根据下式计算所述第一损失函数:
    Figure PCTCN2022089993-appb-100004
    其中,p 1为所述第一特征向量,z 2为所述第二特征向量,||p 1|| 2为所述第一特征向量的模,||z 2|| 2为所述第二特征向量的模,
    Figure PCTCN2022089993-appb-100005
    为所述第一损失函数。
  11. 根据权利要求8所述的存储介质,其中,所述至少一个计算机可读指令被所述处理器执行以实现所述使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型时,具体包括:
    使用所述命名实体识别模型的编码器对所述文本数据集中的标注文本数据进行编码,得到编码后的特征向量;
    使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布;
    根据所述概率分布计算第二损失函数;
    以最小化所述第二损失函数为目标对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
  12. 根据权利要求11所述的存储介质,其中,所述至少一个计算机可读指令被所述处理器执行以实现所述使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布时,具体包括:
    根据下式计算实体类别的概率分布:
    p i=Softmax(U tanh(Vh i))
    其中,i为所述文本数据集中的标注文本数据的序号,h i为与所述文本数据集中的第i个标注文本数据对应的编码后的特征向量,U和V均为预设的模型参数,Softmax为预设的激励函数,p i为与所述文本数据集中的第i个标注文本数据对应的实体类别的概率分布。
  13. 根据权利要求12所述的存储介质,其中,所述至少一个计算机可读指令被所述处理器执行以实现所述根据所述概率分布计算第二损失函数时,具体包括:
    根据下式计算所述第二损失函数:
    Figure PCTCN2022089993-appb-100006
    其中,n为所述文本数据集中的标注文本数据的数目,z i为与所述文本数据集中的第i个标注文本数据对应的实体类别标签,loss为所述第二损失函数。
  14. 一种终端设备,其中,所述终端设备包括存储器及处理器,所述存储器用于存储至少一个计算机可读指令,所述处理器用于执行所述至少一个计算机可读指令以实现以下步骤:
    使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
    将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
    使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
    获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
    使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整 后的命名实体识别模型;
    获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
  15. 根据权利要求14所述的终端设备,其中,所述处理器执行所述至少一个计算机可读指令以实现所述使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器时,具体包括:
    对所述文本数据集中的文本数据进行数据增强,得到预设数量的增强文本数据对;其中,任意一个所述增强文本数据对中均包括由同一文本数据进行数据增强后的得到的两个不同的增强文本数据;
    使用所述孪生网络对所述增强文本数据对进行处理,分别得到第一特征向量和第二特征向量;
    根据所述第一特征向量和所述第二特征向量计算第一损失函数;
    以最小化所述第一损失函数为目标对所述孪生网络中的编码器进行预训练,得到预训练后的编码器。
  16. 根据权利要求15所述的终端设备,其中,所述处理器执行所述至少一个计算机可读指令以实现所述根据所述第一特征向量和所述第二特征向量计算第一损失函数时,具体包括:
    根据下式计算所述第一损失函数:
    Figure PCTCN2022089993-appb-100007
    其中,p 1为所述第一特征向量,z 2为所述第二特征向量,||p 1|| 2为所述第一特征向量的模,||z 2|| 2为所述第二特征向量的模,
    Figure PCTCN2022089993-appb-100008
    为所述第一损失函数。
  17. 根据权利要求14所述的终端设备,其中,所述处理器执行所述至少一个计算机可读指令以实现所述使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型时,具体包括:
    使用所述命名实体识别模型的编码器对所述文本数据集中的标注文本数据进行编码,得到编码后的特征向量;
    使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布;
    根据所述概率分布计算第二损失函数;
    以最小化所述第二损失函数为目标对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型。
  18. 根据权利要求17所述的终端设备,其中,所述处理器执行所述至少一个计算机可读指令以实现所述使用所述命名实体识别模型的多层感知器对所述编码后的特征向量进行处理,得到实体类别的概率分布时,具体包括:
    根据下式计算实体类别的概率分布:
    p i=Softmax(U tanh(Vh i))
    其中,i为所述文本数据集中的标注文本数据的序号,h i为与所述文本数据集中的第i个标注文本数据对应的编码后的特征向量,U和V均为预设的模型参数,Softmax为预设的激励函数,p i为与所述文本数据集中的第i个标注文本数据对应的实体类别的概率分布。
  19. 根据权利要求18所述的终端设备,其中,所述处理器执行所述至少一个计算机可读指令以实现所述根据所述概率分布计算第二损失函数时,具体包括:
    根据下式计算所述第二损失函数:
    Figure PCTCN2022089993-appb-100009
    其中,n为所述文本数据集中的标注文本数据的数目,z i为与所述文本数据集中的第i个 标注文本数据对应的实体类别标签,loss为所述第二损失函数。
  20. 一种命名实体识别装置,其中,所述装置包括:
    编码器预训练模块,用于使用预设的文本数据集中的文本数据对预设的孪生网络中的编码器进行预训练,得到预训练后的编码器;
    模型训练模块,用于将所述预训练后的编码器作为预设的命名实体识别模型的编码器,并使用所述文本数据集中的标注文本数据对所述命名实体识别模型进行训练,得到标注训练后的命名实体识别模型;
    模型预测模块,用于使用所述标注训练后的命名实体识别模型对所述文本数据集中的无标注文本数据进行预测,得到模型标注后的第一类文本数据和待人工标注的第二类文本数据;
    标注文本数据新增模块,用于获取人工标注后的第二类文本数据,并将所述模型标注后的第一类文本数据和所述人工标注后的第二类文本数据作为新增标注文本数据;
    模型调整模块,用于使用所述新增标注文本数据对所述标注训练后的命名实体识别模型进行调整,得到调整后的命名实体识别模型;
    命名实体识别模块,用于获取待识别的目标文本数据,并使用所述调整后的命名实体识别模型对所述目标文本数据进行处理,得到所述目标文本数据中的各个命名实体的实体类别。
PCT/CN2022/089993 2021-10-22 2022-04-28 命名实体识别方法、装置、存储介质及终端设备 WO2023065635A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111233302.XA CN113901823A (zh) 2021-10-22 2021-10-22 命名实体识别方法、装置、存储介质及终端设备
CN202111233302.X 2021-10-22

Publications (1)

Publication Number Publication Date
WO2023065635A1 true WO2023065635A1 (zh) 2023-04-27

Family

ID=79025932

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/089993 WO2023065635A1 (zh) 2021-10-22 2022-04-28 命名实体识别方法、装置、存储介质及终端设备

Country Status (2)

Country Link
CN (1) CN113901823A (zh)
WO (1) WO2023065635A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116776154A (zh) * 2023-07-06 2023-09-19 华中师范大学 一种ai人机协同数据标注方法和系统

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113901823A (zh) * 2021-10-22 2022-01-07 平安科技(深圳)有限公司 命名实体识别方法、装置、存储介质及终端设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959252A (zh) * 2018-06-28 2018-12-07 中国人民解放军国防科技大学 基于深度学习的半监督中文命名实体识别方法
CN109543009A (zh) * 2018-10-17 2019-03-29 龙马智芯(珠海横琴)科技有限公司 文本相似度评估系统及文本相似度评估方法
CN112818691A (zh) * 2021-02-01 2021-05-18 北京金山数字娱乐科技有限公司 命名实体识别模型训练方法及装置
US20210149993A1 (en) * 2019-11-15 2021-05-20 Intuit Inc. Pre-trained contextual embedding models for named entity recognition and confidence prediction
CN113901823A (zh) * 2021-10-22 2022-01-07 平安科技(深圳)有限公司 命名实体识别方法、装置、存储介质及终端设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959252A (zh) * 2018-06-28 2018-12-07 中国人民解放军国防科技大学 基于深度学习的半监督中文命名实体识别方法
CN109543009A (zh) * 2018-10-17 2019-03-29 龙马智芯(珠海横琴)科技有限公司 文本相似度评估系统及文本相似度评估方法
US20210149993A1 (en) * 2019-11-15 2021-05-20 Intuit Inc. Pre-trained contextual embedding models for named entity recognition and confidence prediction
CN112818691A (zh) * 2021-02-01 2021-05-18 北京金山数字娱乐科技有限公司 命名实体识别模型训练方法及装置
CN113901823A (zh) * 2021-10-22 2022-01-07 平安科技(深圳)有限公司 命名实体识别方法、装置、存储介质及终端设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WEIXIN_39874196: "A twin network image similarity_twin network is used for carrying out meta-learning by using a double-head neural network", CSDN BLOG, CN, 20 November 2020 (2020-11-20), CN, pages 1 - 6, XP009545792 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116776154A (zh) * 2023-07-06 2023-09-19 华中师范大学 一种ai人机协同数据标注方法和系统
CN116776154B (zh) * 2023-07-06 2024-04-09 华中师范大学 一种ai人机协同数据标注方法和系统

Also Published As

Publication number Publication date
CN113901823A (zh) 2022-01-07

Similar Documents

Publication Publication Date Title
US11816442B2 (en) Multi-turn dialogue response generation with autoregressive transformer models
WO2020140403A1 (zh) 文本分类方法、装置、计算机设备及存储介质
WO2023065635A1 (zh) 命名实体识别方法、装置、存储介质及终端设备
WO2021159714A1 (zh) 一种数据处理方法及相关设备
JP2020520492A (ja) 文書要約自動抽出方法、装置、コンピュータ機器及び記憶媒体
WO2022141864A1 (zh) 对话意图识别模型训练方法、装置、计算机设备及介质
WO2022227162A1 (zh) 问答数据处理方法、装置、计算机设备及存储介质
WO2021189960A1 (zh) 对抗网络训练、医疗数据补充方法、装置、设备及介质
WO2022174496A1 (zh) 基于生成模型的数据标注方法、装置、设备及存储介质
CN113434683A (zh) 文本分类方法、装置、介质及电子设备
US20200159828A1 (en) Robust key value extraction
WO2023134067A1 (zh) 语音分类模型的训练方法、装置、设备及存储介质
US20220358955A1 (en) Method for detecting voice, method for training, and electronic devices
WO2022257454A1 (zh) 一种合成语音的方法、装置、终端及存储介质
CN115687934A (zh) 意图识别方法、装置、计算机设备及存储介质
CN113010678A (zh) 分类模型的训练方法、文本分类方法及装置
JP2024515199A (ja) 要素テキスト処理方法、装置、電子機器及び記憶媒体
WO2022227214A1 (zh) 分类模型训练方法、装置、终端设备及存储介质
CN113571052A (zh) 一种噪声提取及指令识别方法和电子设备
WO2023078009A1 (zh) 一种模型权重获取方法以及相关系统
US10706086B1 (en) Collaborative-filtering based user simulation for dialog systems
CN112328784B (zh) 数据信息分类方法及装置
CN114491030A (zh) 技能标签的抽取、候选短语分类模型的训练方法及装置
CN113420869A (zh) 基于全方向注意力的翻译方法及其相关设备
WO2021042517A1 (zh) 基于人工智能的文章主旨提取方法、装置及存储介质

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: 22882260

Country of ref document: EP

Kind code of ref document: A1