A training method and device of a part-of-speech tagger, an electronic device and a storage medium

By converting word sequences into token sequences and training a part-of-speech (POS) language model using a masked language model, the problem of separating POS sequences from word sequences in POS tagging is solved, achieving efficient POS tagging and improving the accuracy and efficiency of POS prediction.

CN117744645BActive Publication Date: 2026-11-24BEIJING UNISOUND INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311873408.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-30
Publication Date
2026-11-24
Estimated Expiration
2043-12-30

AI Technical Summary

Technical Problem

In existing technologies, the fine-tuning effect of downstream tasks of deep learning-based part-of-speech tagging methods is limited by the pre-trained language model, and the part-of-speech sequences and word sequences are physically isolated, making it difficult to effectively integrate historical language information.

Method used

The word sequences in the training data are converted into token sequences, and a part-of-speech language model is trained through a masked language model to output a masked tag sequence, thereby removing the physical separation between the part-of-speech sequence and the word sequence. The BERT model is then used for part-of-speech tagging.

Benefits of technology

It enables the prediction of the part-of-speech tags of tokens with multiple parts of speech in the context of the non-masked location, improving the accuracy and efficiency of part-of-speech tagging. A language model-based part-of-speech tagger can be obtained with only one training step.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117744645B_ABST
    Figure CN117744645B_ABST
Patent Text Reader

Abstract

This invention relates to a training method, apparatus, electronic device, and storage medium for a part-of-speech tagger. The method includes: converting word sequences in training data into token sequences; initializing the token sequences; inputting the initialized token sequences into a masked language model to train the part-of-speech language model to output a masked tag sequence; and querying the part-of-speech mapping table in the training data to tag the parts of speech at non-masked positions in the masked tag sequence. This invention cleverly integrates word sequences and part-of-speech sequences into a single set, removing the physical separation between the two sets. It also fully utilizes the historical and underlying linguistic information contained in the word sequences. A language model-based part-of-speech tagger can be obtained in a single training step. The part-of-speech tagger can predict the parts of speech of tokens with multiple parts of speech in the context of the training data at non-masked positions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of part-of-speech tagging technology, and more specifically to a training method, apparatus, electronic device, and storage medium for a part-of-speech tagging system. Background Technology

[0002] Existing technologies generally classify part-of-speech tagging tasks as sequence labeling tasks (Seq2Seq). Assuming there exists a part-of-speech model, it takes a sequence of words in a sentence as input and outputs the part-of-speech tag sequence for each word. Such models can be RNN (Recurrent Neural Network) or BERT (Bidirectional Encoder Representations from Transformers). The input sequence is a sequence of words, and the output sequence is a sequence of parts of speech. The sequence of words belongs to a set of words, and the sequence of parts of speech belongs to a set of parts of speech. Essentially, these two sets are physically isolated from each other.

[0003] Deep learning-based part-of-speech tagging methods typically involve two steps for downstream tasks: pre-training a language model and fine-tuning. The effectiveness of fine-tuning is to some extent limited by the pre-trained language model. Summary of the Invention

[0004] This invention provides a training method, apparatus, electronic device, and storage medium for a part-of-speech tagger, which can solve the above-mentioned technical problems.

[0005] In a first aspect, embodiments of the present invention provide a method for training a part-of-speech tagger, comprising:

[0006] Convert the word sequences in the training data into token sequences;

[0007] Initialize the token sequence;

[0008] The initialized token sequence is input into the masked language model to train the part-of-speech language model to output the masked label sequence. The part-of-speech is then queried from the part-of-speech mapping table in the training data to label the part of speech at the non-masked positions in the masked label sequence.

[0009] Furthermore, in the above-mentioned training method for a part-of-speech tagger, the word sequence in the training data is converted into a token sequence, including:

[0010] Determine whether the words in the training data word sequence are multiple parts of speech or a single part of speech;

[0011] Different transformations are performed for words with multiple parts of speech and words with a single part of speech.

[0012] Furthermore, in the above-mentioned training method for a part-of-speech tagger, the different transformations performed on multiple parts-of-speech words and a single part-of-speech word include:

[0013] Multiple parts-of-speech words are split into the part-of-speech word itself and the part-of-speech corresponding to the part-of-speech word;

[0014] The part of speech of a word itself and the part of speech corresponding to the word are abbreviated as part of speech word and part of speech word label;

[0015] A single part-of-speech word is the part-of-speech word itself.

[0016] Furthermore, in the above-mentioned training method for a part-of-speech tagger, the initialization of the token sequence includes:

[0017] For tokens of multiple parts of speech, each token is initialized using the token of the word itself.

[0018] Furthermore, in the above-mentioned training method for part-of-speech taggers, the loss function in the process of inputting the initialized token sequence into the masked language model to train the part-of-speech language model and outputting the masked label sequence is expressed as:

[0019]

[0020] Where m(x) represents the masked words in the given word sequence x, and \m(x) represents the unmasked words in the word sequence.

[0021] Furthermore, in the above-mentioned training method for part-of-speech taggers, the initialized token sequence is input into the masked language model to train the part-of-speech language model to output the masked label sequence, and the single part-of-speech words in the token sequence are masked.

[0022] Furthermore, in the training method of the above-mentioned part-of-speech tagger, the part-of-speech language model is the BERT model.

[0023] Secondly, embodiments of the present invention also provide a training apparatus for a part-of-speech tagger, comprising:

[0024] The conversion module is used to convert word sequences in the training data into token sequences.

[0025] Initialization module: Used to initialize the token sequence;

[0026] Training module: Used to input the initialized Token sequence into the masked language model to train the part-of-speech language model to output the masked label sequence, and to query the part-of-speech mapping table in the training data for the part-of-speech of the non-masked positions in the masked label sequence.

[0027] Thirdly, embodiments of the present invention also provide an electronic device, including: a processor and a memory;

[0028] The processor executes a training method for a part-of-speech tagger, such as one of the above methods, by calling programs or instructions stored in memory.

[0029] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a program or instructions that cause a computer to execute a training method for a part-of-speech tagger as described above.

[0030] The beneficial effects of this invention are as follows: This invention transforms word sequences in training data into token sequences; initializes the token sequences; inputs the initialized token sequences into a masked language model to train the part-of-speech (POS) language model to output a masked label sequence; and queries the POS mapping table in the training data to identify the part-of-speech tags at non-masked positions in the masked label sequence for labeling. This invention cleverly integrates word sequences and POS sequences into one set, removing the physical isolation between the two sets. Simultaneously, it can fully utilize the historical and underlying language information contained in the word sequences. Only one training step is needed to obtain a language model-based POS tagger, which can predict the POS of tokens with multiple POS in the context of the non-masked positions. Attached Figure Description

[0031] Figure 1 A training method for a part-of-speech tagger provided in this embodiment of the invention. Figure 1 ;

[0032] Figure 2 A training method for a part-of-speech tagger provided in this embodiment of the invention. Figure 2 ;

[0033] Figure 3 A diagram of a training device for a part-of-speech tagger provided in an embodiment of the present invention;

[0034] Figure 4 This is a schematic block diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0035] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.

[0036] Figure 1 A training method for a part-of-speech tagger provided in this embodiment of the invention. Figure 1 .

[0037] Firstly, embodiments of the present invention provide a training method for a part-of-speech tagger, combining... Figure 1 It includes three steps, S101 to S103:

[0038] S101: Convert the word sequence in the training data into a token sequence.

[0039] Specifically, for example, the word sequence could be "At a traditional wedding, there are people wearing Hanfu." where the forward slash " / " indicates a word boundary. The word sequence "At a traditional wedding, there are people wearing Hanfu." is transformed into the token sequence "At a traditional wedding (2) there are people wearing Hanfu (1)." It should be understood that this word sequence is a sequence of many words; the specific conversion method is detailed below.

[0040] S102: Initialize the token sequence.

[0041] Replace (initialize) the "Split Token" with the "Default Token". The "Default Token" and "Split Token" are described in detail below.

[0042] Specifically, for example, the initialization of "At the wedding of / traditional2 / there are / traditional1 / wearing / Hanfu / ." results in "At the wedding of / traditional / there are / traditional / wearing / Hanfu / ." The specific initialization method is described in detail below.

[0043] S103: Input the initialized Token sequence into the masked language model to train the part-of-speech language model to output the masked label sequence. Then, query the part-of-speech mapping table in the training data to find the part of speech at the non-masked position in the masked label sequence and label it.

[0044] Specifically, for example, the initialized token sequence "At / traditional / wedding / there / wearing / Hanfu / traditional / ." is input into the masked language model to train the part-of-speech language model to output the masked label sequence "M / traditional2 / M / M / M / M / M / M / M / traditional1 / M". The part-of-speech mapping table "preposition / adjective / auxiliary word / noun / locative word / verb / verb / noun / auxiliary word / noun / punctuation mark" in the training data is used to query the non-masked positions of the tokens "traditional2" and "traditional1" in the masked label sequence and label them as adjectives and nouns. It should be understood that the part-of-speech annotator obtained by annotating the part of speech of tokens with multiple parts of speech in the context environment through a large number of word sequences during the training process can predict the part of speech of tokens with multiple parts of speech.

[0045] Figure 2 A training method for a part-of-speech tagger provided in this embodiment of the invention. Figure 2 .

[0046] Furthermore, in the above-mentioned training method for part-of-speech taggers, the word sequences in the training data are converted into token sequences, combined with... Figure 2 It includes two steps, S201 to S202:

[0047] S201: Determine whether the words in the word sequence are multiple parts of speech or a single part of speech;

[0048] S202: Different transformations are performed for words with multiple parts of speech and words with a single part of speech.

[0049] Specifically, in this embodiment of the invention, by determining whether the words in the word sequence are multiple parts of speech or a single part of speech, such as "In traditional weddings there is a tradition of wearing Hanfu", "traditional" is a multiple part of speech, the first "traditional" is an adjective, the second "traditional" is a noun, and wedding is a single part of speech, the part of speech of wedding is a noun, and different transformations are performed on multiple part of speech and single part of speech, the transformation methods are described in detail below.

[0050] Furthermore, in the training method of the above-mentioned part-of-speech tagger, different transformations are performed on words with multiple parts of speech and words with a single part of speech, including:

[0051] Multiple parts-of-speech words are split into the part-of-speech word itself and the part-of-speech corresponding to the part-of-speech word;

[0052] The part of speech of a word itself and the part of speech corresponding to the word are abbreviated as part of speech word and part of speech word label;

[0053] A single part-of-speech word is the part-of-speech word itself.

[0054] Specifically, for example, the word "traditional" with multiple parts of speech splits into three tokens: "traditional", "traditional_noun", and "traditional_adjective". "traditional", "traditional_noun", and "traditional_adjective" are then abbreviated to "traditional", "traditional1", and "traditional2" respectively. The token "traditional" is called the "default token", which is essentially the word "traditional" itself. Both tokens "traditional1" and "traditional2" become "split tokens". The single part of speech word "wedding" retains the "wedding" token, which is also the word "wedding" itself.

[0055] Furthermore, in the above-mentioned training method for a part-of-speech tagger, the initialization of the token sequence includes:

[0056] For tokens of multiple parts of speech, each token is initialized using the token of the word itself.

[0057] Specifically, for example, initializing "At the wedding of / traditional2 / there are / those wearing / Hanfu / traditional1 / ." results in "At the wedding of / traditional / there are / those wearing / Hanfu / traditional / ." This initializes the multiple parts of speech "traditional2" and "traditional1" using the traditional part of speech word itself.

[0058] Furthermore, in the above-mentioned training method for part-of-speech taggers, the loss function in the process of inputting the initialized token sequence into the masked language model to train the part-of-speech language model and outputting the masked label sequence is expressed as:

[0059]

[0060] Where m(x) represents the masked words in the given word sequence x, and \m(x) represents the unmasked words in the word sequence.

[0061] Specifically, in this embodiment of the invention, the loss function is used to guide the training process of the model. By minimizing the loss function, the parameters of the model can be adjusted so that it can better fit the training data and improve the performance of the model.

[0062] Furthermore, in the above-mentioned training method for part-of-speech taggers, the initialized token sequence is input into the masked language model to train the part-of-speech language model to output the masked label sequence, and the single part-of-speech words in the token sequence are masked.

[0063] Specifically, in this embodiment of the invention, the initialized Token sequence "In traditional weddings, there is a tradition of wearing Hanfu." is input into the masked language model to train the part-of-speech language model. During the output of the masked label sequence, the single part-of-speech words in the Token sequence are masked to obtain "M / traditional2 / M / M / M / M / M / M / M / Traditional1 / M".

[0064] Furthermore, in the training method of the above-mentioned part-of-speech tagger, the part-of-speech language model is the BERT model.

[0065] Secondly, embodiments of the present invention also provide a training apparatus for a part-of-speech tagger, comprising:

[0066] Transformation module 301: Used to transform word sequences in training data into token sequences.

[0067] Specifically, for example, the word sequence could be "At a traditional wedding, there are people wearing Hanfu." The conversion module 301 converts the word sequence "At a traditional wedding, there are people wearing Hanfu." into the token sequence "At a traditional wedding 2, there are people wearing Hanfu 1." It should be understood that the word sequence here is a sequence composed of a large number of words.

[0068] Initialization module 302: Used to initialize the token sequence.

[0069] Specifically, for example, the initialization module 302 initializes "At the wedding of / traditional 2 / there are / traditional 1 / wearing / Hanfu / ." to obtain "At the wedding of / traditional / there are / traditional / wearing / Hanfu / .".

[0070] Training module 303: This module is used to input the initialized Token sequence into the masked language model to train the part-of-speech language model to output the masked label sequence. It then queries the part-of-speech mapping table in the training data to find the part of speech at the non-masked position in the masked label sequence.

[0071] Specifically, exemplarily, the training module 303 inputs the initialized token sequence “At / traditional / wedding / there / wearing / Hanfu / traditional / .” into the masked language model to train the part-of-speech language model to output the masked label sequence “M / traditional2 / M / M / M / M / M / M / M / traditional1 / M”. Then, it queries the part-of-speech mapping table “preposition / adjective / auxiliary word / noun / locative word / verb / verb / noun / auxiliary word / noun / punctuation” in the training data to query the non-masked positions of the tokens “traditional2” and “traditional1” in the masked label sequence and labels them as adjectives and nouns, respectively. It should be understood that the part-of-speech annotator obtained by annotating the part of speech through a large number of word sequences during the training process can predict the part of speech of tokens with multiple parts of speech in the context.

[0072] Thirdly, embodiments of the present invention also provide an electronic device, including: a processor and a memory;

[0073] The processor executes a training method for a part-of-speech tagger, such as one of the above methods, by calling programs or instructions stored in memory.

[0074] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a program or instructions that cause a computer to execute a training method for a part-of-speech tagger as described above.

[0075] Figure 4This is a schematic block diagram of an electronic device provided in an embodiment of this disclosure.

[0076] like Figure 4 As shown, the electronic device includes at least one processor 401, at least one memory 402, and at least one communication interface 403. The various components of the electronic device are coupled together via a bus system 404. The communication interface 403 is used for information transmission with external devices. It is understood that the bus system 404 is used to implement communication between these components. In addition to a data bus, the bus system 404 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 4 The general designated all buses as Bus System 404.

[0077] It is understood that the memory 402 in this embodiment can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.

[0078] In some implementations, memory 402 stores elements such as executable units or data structures, or subsets thereof, or extended sets thereof: operating systems and applications.

[0079] The operating system includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application programs include various applications, such as media players and browsers, used to implement various application functions. A program implementing any method in the part-of-speech tagging training method provided in this embodiment of the invention can be included in the application programs.

[0080] In this embodiment of the invention, the processor 401 executes the steps of various embodiments of the training method for a part-of-speech tagger provided in this embodiment of the invention by calling the program or instructions stored in the memory 402, specifically, the program or instructions stored in the application program.

[0081] Convert the word sequences in the training data into token sequences;

[0082] Initialize the token sequence;

[0083] The initialized token sequence is input into the masked language model to train the part-of-speech language model to output the masked label sequence. The part-of-speech is then queried from the part-of-speech mapping table in the training data to label the part of speech at the non-masked positions in the masked label sequence.

[0084] Any method in the training method for a part-of-speech tagger provided in this embodiment of the invention can be applied to, or implemented by, the processor 401. The processor 401 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 401 or by instructions in software form. The processor 401 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0085] In the training method for a part-of-speech tagger provided in this embodiment of the invention, any step can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software units in the decoding processor. The software units can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 402, and processor 401 reads the information in memory 402 and combines it with hardware to complete the steps of the method.

[0086] Those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention and form different embodiments.

[0087] Those skilled in the art will understand that the descriptions of the various embodiments have different focuses, and for parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0088] Although embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention. All such modifications and variations fall within the scope defined by the appended claims. The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

[0089] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A training method for a part-of-speech tagger, characterized in that, include: Convert the word sequences in the training data into token sequences; Initialize the token sequence; The initialized Token sequence is input into the masked language model to train the part-of-speech language model to output the masked label sequence. The part-of-speech is then queried from the part-of-speech mapping table in the training data to label the part of speech at the non-masked positions in the masked label sequence. The step of converting word sequences in the training data into token sequences includes: Determine whether the words in a word sequence are multiple parts of speech or a single part of speech; Different transformations are applied to words with multiple parts of speech and words with a single part of speech; The different transformations of words with multiple parts of speech and words with a single part of speech include: Multiple parts-of-speech words are split into the part-of-speech word itself and the part-of-speech corresponding to the part-of-speech word; The part of speech of a word itself and the part of speech corresponding to the word are abbreviated as part of speech word and part of speech word label; A single part-of-speech word is the part-of-speech word itself; Initializing the token sequence includes: For tokens with multiple parts of speech, the tokens of each part of speech are initialized using the tokens of the words themselves. The initialized Token sequence is input into the masked language model to train the part-of-speech language model. During the process of outputting the masked label sequence, single part-of-speech words in the Token sequence are masked.

2. The training method for a part-of-speech tagger according to claim 1, characterized in that, The loss function for inputting the initialized token sequence into the masked language model to train the part-of-speech language model and output the masked label sequence is expressed as follows: Where m(x) represents the masked words in the given word sequence x, and \m(x) represents the unmasked words in the word sequence.

3. The training method for a part-of-speech tagger according to claim 1, characterized in that, The part-of-speech language model is the BERT model.

4. A training apparatus for a part-of-speech tagger, employing the training method for a part-of-speech tagger according to any one of claims 1-3, characterized in that, include: The conversion module is used to convert word sequences in the training data into token sequences. Initialization module: used to initialize the token sequence; Training module: This module is used to input the initialized token sequence into the masked language model to train the part-of-speech language model to output a masked label sequence. It then queries the part-of-speech mapping table in the training data to find the part-of-speech tags for the non-masked positions in the masked label sequence and annotates them.

5. An electronic device, characterized in that, include: Processor and memory; The processor executes a training method for a part-of-speech tagger as described in any one of claims 1 to 3 by calling programs or instructions stored in the memory.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instructions that cause a computer to perform a training method for a part-of-speech tagger as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Part-of-speech tagging method, device and electronic device

    CN109344406A

  • Language model pre-training method, text processing method and related equipment

    CN116304081A