Language model processing system and language model processing method
By synthesizing context vectors of varying granularities, the language model processing device addresses the issue of inappropriate tokenization in existing models, enabling effective text analysis without the need for costly retraining.
Patent Information
- Application Number
- JP2020209886
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2020-12-18
- Publication Date
- 2024-10-07
- Estimated Expiration
- 2040-12-18
AI Technical Summary
Existing language models like ELMo and BERT do not necessarily provide appropriate context vectors for text analysis due to differing tokenization granularities, making it difficult to select an appropriate model without significant time and financial costs for retraining.
A language model processing device synthesizes context vectors of different granularities by combining character and partial word context vectors using a tokenization function, allowing for context vector sequences that reflect both character and partial word contexts without constructing a new language model.
This approach enables the generation of context vectors suitable for high-level text analysis tasks, such as morphological analysis and sentence classification, by leveraging existing language models efficiently.
Smart Images

Figure 0007562400000001 
Figure 0007562400000002 
Figure 0007562400000003
Abstract
Description
[Technical field]
[0001] The present invention relates generally to language processing technology. [Background technology]
[0002] The performance of text analysis can be improved by converting the input text into an appropriate context vector sequence (one or more context vectors) and performing text analysis using the context vector sequence. Context vector assignment is to assign a context vector (a vector reflecting a meaning according to the context) to each token in a sequence of tokens (token sequence) obtained by dividing (tokenizing) the input text. The sequence of context vectors assigned to a token sequence is called a "context vector sequence." The tokens in the token sequence and the context vectors in the context vector sequence correspond one-to-one. For example, the token sequence "My", "dog", "likes", "hot", "dog"" obtained by tokenizing the text "My dog likes hot dog" is assigned the vector sequence "v_my", "v_dog1", "v_likes", "v_hot", "v_dog2". In this case, for the token "dog", the context vector "v_dog1" corresponding to the first "dog" and the context vector "v_dog2" corresponding to the second "dog" may be assigned different vectors according to the context. That is, the context vector sequence holds different information for each context even for tokens that are homographs, such as "v_dog1" corresponding to the first "dog" in the text and "v_dog2" corresponding to the second "dog" in the text. The context vector sequence also holds appropriate information for each context for tokens other than homographs. Furthermore, the context vector sequence can include syntactic and semantic information that is useful for text analysis, thereby improving the performance of text analysis.
[0003] A context vector sequence for achieving accurate text analysis can be obtained within the framework of a language model that quantitatively handles language. A typical language model is a probabilistic model such as a neural network. In the following description, a neural network is adopted as the language model, but the language model may be a model other than a neural network. Obtaining a context vector sequence using a language model includes quantifying an input token sequence and obtaining a context vector sequence as an output of the language model by inputting the numerical value of the token sequence to the language model. The output of a language model for an input generally depends on a set of parameters (one or more parameters) of the language model (neural network), and the set of parameters is obtained by performing language model training (pre-training) using a large amount of data.
[0004] An example of pre-training of a language model is as follows. A tokenization function is provided that performs tokenization based on the granularity (token unit (fineness)) determined in advance by the developer of the language model. The tokenization function replaces part of the token sequence obtained by tokenizing the text with a special token (masking process). The masked token sequence is input to the language model. Then, in the output portion of the language model, the token before replacement of the special token masked in the masking process is estimated. A loss is calculated from the estimated result and the true result, and the language model is trained based on the loss, and as a result, the parameters of the language model are updated.
[0005] For example, Embeddings from Language Models (ELMo) in Non-Patent Document 1, which is one of the language models, uses Long Short-Term Memory (LSTM) in the neural network and combines forward LSTM and backward LSTM. As another example, Bidirectional Encoder Representations from Transformers (BERT) in Non-Patent Document 2 is constructed by stacking Transformers, which are neural networks equipped with a self-attention mechanism, in multiple stages. [Prior art documents] [Non-patent literature]
[0006] [Non-Patent Document 1] Deep Contextualized Word Representations. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. https: / / www.aclweb.org / anthology / N18-1202 / [Non-Patent Document 2] BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. https: / / www.aclweb.org / anthology / N19-1423 / Summary of the Invention [Problem to be solved by the invention]
[0007] The granularity of the context vector depends on the granularity (token unit) of tokenization performed by a tokenization function associated with the language model. In order for the granularity of the context vector to be appropriate for the text analysis to be performed, a language model accompanied by a tokenization function that performs tokenization at a granularity appropriate for the text analysis must be used. However, it is difficult to always select an appropriate language model depending on the text analysis, and such an appropriate language model is not necessarily publicly available. For example, the language models (ELMo or BERT) disclosed in Non-Patent Document 1 or 2 are not necessarily appropriate for the text analysis to be performed.
[0008] For this reason, the granularity of tokenization performed by the tokenization function associated with the language model being used may differ from the appropriate granularity.
[0009] It would be possible to build a new language model tailored to the appropriate tokenization granularity. However, training a language model (e.g., ELMo or BERT) requires a lot of time and money. Therefore, building a language model tailored to the appropriate granularity is unrealistic. [Means for solving the problem]
[0010] The language model processing device acquires from the text a first token sequence composed of one or more first tokens, each of which is a token of a first granularity corresponding to a first language model. The language model processing device acquires from the text a second token sequence composed of one or more second tokens, each of which is a token of a second granularity different from the first granularity. The language model processing device inputs each of the one or more first tokens in the first token sequence to a first language model of one or more language models, thereby acquiring a first context vector sequence composed of one or more first context vectors corresponding to the one or more first tokens, as an output of the first language model. The language model processing device inputs each of the one or more second tokens in the second token sequence to a first language model of one or more language models or a second language model different from the first language model, thereby acquiring a second context vector sequence composed of one or more second context vectors corresponding to the one or more second tokens, as an output of the first language model or the second language model. A language model processing device combines one or more first context vectors in the first context vector sequence with one or more second context vector sequences in the second context vector sequence, and outputs a combined context vector sequence based on one or more context vectors obtained by combining one or more first context vectors with one or more second context vectors. Effect of the Invention
[0011] According to the present invention, it is possible to obtain a context vector suitable for a higher level task such as text analysis without constructing a new language model. Problems, configurations and effects other than those described above will become apparent from the following description of the embodiments. [Brief description of the drawings]
[0012] [Figure 1] 1 is a functional block diagram of a language model processing device according to a first embodiment. FIG. [Diagram 2]FIG. 2 is an explanatory diagram illustrating an example of an input text and an example of character tokenization. [Diagram 3] FIG. 2 is an explanatory diagram illustrating an example of an input text and an example of subword tokenization. [Figure 4] FIG. 13 is an explanatory diagram showing an example of a volatile device occupancy rate graph in a comparative example. [Diagram 5] FIG. 2 is an explanatory diagram showing an example of a volatility device occupancy rate graph in the first embodiment. [Figure 6] FIG. 11 is a functional block diagram of a language model processing device according to a second embodiment. [Figure 7] FIG. 11 is an explanatory diagram illustrating a character center context vector sequence synthesis unit in the second embodiment. [Figure 8] FIG. 11 is an explanatory diagram illustrating a character center context vector sequence synthesis unit in the second embodiment. [Figure 9] FIG. 11 is a diagram showing an example of a synthesis parameter setting screen in the second embodiment. [Figure 10] FIG. 11 is a functional block diagram of a language model processing device according to a third embodiment. [Figure 11] FIG. 11 is an explanatory diagram showing an example of target span data. [Figure 12] FIG. 13 is an explanatory diagram illustrating a target span context vector synthesis unit in the third embodiment. [Figure 13] FIG. 13 is a diagram showing an example of a synthesis parameter setting screen in the third embodiment. [Figure 14] 2 is a diagram illustrating an example of a hardware configuration of a computer that realizes a language model processing device. [Figure 15] FIG. 13 is an example of a functional block diagram of a language model processing device according to a modified example of the first embodiment. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0013] The embodiments of the present invention will be described with reference to the drawings. In the following, the same or similar elements and processes are denoted by the same reference numerals, and differences will be described and overlapping descriptions will be omitted. In addition, for the following embodiments, differences from the previously described embodiments will be described and overlapping descriptions will be omitted. In addition, each embodiment and each modified example can be combined in part or in whole within the scope consistent with the gist of the present invention.
[0014] In the following description, an "interface unit" may refer to one or more interface devices. The one or more interface devices may be at least one of the following: One or more I / O (Input / Output) interface devices. The I / O (Input / Output) interface devices are interface devices to at least one of the I / O devices and a remote display computer. The I / O interface device to the display computer may be a communications interface device. The at least one I / O device may be a user interface device, e.g., either an input device such as a keyboard and pointing device, or an output device such as a display device. One or more communication interface devices. The one or more communication interface devices may be one or more homogeneous communication interface devices (e.g., one or more NICs (Network Interface Cards)) or two or more heterogeneous communication interface devices (e.g., a NIC and an HBA (Host Bus Adapter)).
[0015] In the following description, a "memory" refers to one or more memory devices, which are an example of one or more storage devices, and may typically be a primary storage device. At least one memory device in the memory may be a volatile memory device or a non-volatile memory device.
[0016] In the following description, a "persistent storage device" may be one or more persistent storage devices, which are an example of one or more persistent storage devices. A persistent storage device may typically be a non-volatile storage device (e.g., an auxiliary storage device), and more specifically, may be, for example, a hard disk drive (HDD), a solid state drive (SSD), a non-volatile memory express (NVME) drive, or a storage class memory (SCM).
[0017] Also, in the following description, "storage device" may be at least memory, including memory and persistent storage device.
[0018] Furthermore, in the following description, a "processor" may be one or more processor devices. The at least one processor device may typically be a microprocessor device such as a CPU (Central Processing Unit), but may also be other types of processor devices such as a GPU (Graphics Processing Unit). The at least one processor device may be a single-core or multi-core. The at least one processor device may be a processor core. The at least one processor device may also be a broader processor device such as a circuit that is a collection of gate arrays written in a hardware description language that performs part or all of the processing (e.g., an FPGA (Field-Programmable Gate Array), a CPLD (Complex Programmable Logic Device), or an ASIC (Application Specific Integrated Circuit)).
[0019] In the following description, functions may be described using the expression "yyy unit", but the functions may be realized by one or more computer programs being executed by a processor, or by one or more hardware circuits (e.g., FPGA or ASIC), or by a combination thereof. When a function is realized by a program being executed by a processor, the function may be at least a part of the processor, since the specified processing is performed using a storage device and / or an interface device, etc., as appropriate. Processing described with a function as the subject may be processing performed by a processor or a device having the processor. A program may be installed from a program source. The program source may be, for example, a program distribution computer or a computer-readable recording medium (e.g., a non-transitory recording medium). The description of each function is an example, and multiple functions may be combined into one function, or one function may be divided into multiple functions.
[0020] Furthermore, in the following description, the "language model processing device" may be a system composed of one or more physical computers, or may be a system (e.g., a cloud computing system) realized on a group of physical computing resources (e.g., a cloud platform). The language model processing device "displays" the display information may be displaying the display information on a display device possessed by the computer, or the computer may transmit the display information to a display computer (in the latter case, the display information is displayed by the display computer).
[0021] In the following description, a text consisting of a character string is input to a language model processing device, and a tokenization function is used to break the text into tokens that are finer than the text.
[0022] The tokenization function is associated with a language model and converts text into a string of tokens. For example, if the text is in English, the tokenization function may separate the text at whitespace characters, break it down into words, and obtain a string of tokens. Alternatively, the tokenization function may separate the input text by characters, break it down into strings, and obtain a string of tokens. Alternatively, if the text is in Japanese, the tokenization function may break the text down into morpheme units. In this way, a tokenization function according to a language model is used for tokenization. For example, a rule-based method, a statistical method, or machine learning is used for tokenization. That is, the tokenization function itself may be a model (e.g., a neural network).
[0023] The tokenization function according to the language model performs tokenization according to a granularity determined in advance by the developer of the language model. For this reason, the language model is not intended to perform tokenization at a granularity different from the granularity determined in advance. Therefore, for example, for a language model that uses a tokenization function with a word as the tokenization granularity, if a tokenization function with a subword (a token sequence obtained by further dividing a word zero or more times) as the tokenization granularity is used, a token sequence different from the expected one will be input, and as a result, the accuracy of the context vector may decrease.
[0024] On the other hand, the granularity of tokenization required for text analysis varies depending on the analysis target, such as characters, words, or subwords.
[0025] In this way, the appropriate granularity of tokenization varies depending on the purpose of text analysis. A language model cannot obtain an appropriate context vector sequence if tokens with a different granularity are input to the tokenizer corresponding to the language model.
[0026] In the following embodiments, the language model processing device inputs a token string of tokens of a second granularity (e.g., character unit) finer than the first granularity to a language model having a tokenization function that performs tokenization of a first granularity (e.g., unit coarser than character unit) corresponding to the language model used, thereby acquiring a second context vector string (context vector string of context vectors of the second granularity). The language model processing device also inputs a token string of tokens of the first granularity (e.g., coarser than character) to the language model, thereby acquiring a first context vector string (context vector string of context vectors of the first granularity). Then, the language model processing device combines the first context vector string with the second context vector string, and outputs (e.g., presents to a user) a context vector of the second granularity that reflects the context of the first granularity. The second granularity is a granularity appropriate for a higher-level task that requires processing of the second granularity, such as morphological analysis.
[0027] Several examples will be described below. Note that the following explanation may be translated into a language according to the country of filing of the present application, but the specific example of text 901 and character token string 102a shown in Fig. 2, the specific example of text 901 and subword token string 103a shown in Fig. 3, and the specific example of text 901 and four characters 1102 shown in Fig. 11 may remain in Japanese regardless of the country of filing of the present application in order to make the explanation easier to understand. [Example 1] <Configuration of the language model processing device 100 according to the first embodiment>
[0028] FIG. 1 is an example of a functional block diagram of a language model processing device 100 according to the first embodiment.
[0029] The language model processing device 100 includes an input unit 101, a character tokenization unit 102, a subword tokenization unit 103, a tokenization function 104-1, a language model unit 104, a context vector sequence synthesis unit 105, and a context vector sequence output unit 106.
[0030] In this embodiment, for example, the language model processing device 100 receives an input of text 901 from a user, and can provide a context vector sequence to the user as an output in response to the input of the text 901. The context vector sequence provided to the user can be applied to applications (examples of higher-level tasks) such as morphological analysis and sentence classification.
[0031] The input unit 101 receives as input a text 901 consisting of a character string. In this embodiment, the character string as the text 901 is an example of Japanese characters, but it may be a character string in another language. In this case, the language model processing device uses a tokenization function according to the language. The text 901 may be text extracted from various types of information such as a web page, a newspaper article, a paper, or a report.
[0032] The input unit 101 accepts text 901 consisting of a character string including at least one character, and outputs the text 901 to the character tokenization unit 102 and the subword tokenization unit 103. An example of the text 901 is as shown in FIG. 2 or FIG. 3.
[0033] The character tokenization unit 102 breaks down the text 901 received from the input unit 101 into character units (an example of a second granularity), obtains a character token string (a token string of character-unit tokens (i.e., characters)), and outputs the character token string to the language model unit 104. For example, as illustrated in Fig. 2, the character tokenization unit 102 converts the text 901 into a character token string 102a. The character tokenization unit 102 is realized, for example, by executing a computer program for converting text into a character token string.
[0034] The partial word tokenization unit 103 inputs the text 901 received from the input unit 101 to a tokenization function 104-1 (a tokenization function that performs tokenization in partial word units) corresponding to the language model unit 104, obtains a partial word token string (a token string of partial word units (i.e., partial words)) obtained from the tokenization function 104-1, and outputs the partial word token string to the language model unit 104. Note that the "partial word unit" is an example of a unit that is coarser than a character unit and finer than a word unit. The partial word unit is an example of the first granularity, but the first granularity may be any unit (for example, the first granularity may be a unit such as a phoneme, a word, an N-gram, or a phrase). Also, an example of the process of the partial word tokenization unit 103 is as shown in FIG. 3. That is, the partial word tokenization unit 103 converts the text 901 into a partial word token string 103a. The tokenization function 104-1 is implemented by a processor executing tokenization software associated with a language model, such as the ELMo, BERT, and RNN language models.
[0035] The language model unit 104 performs inference using a language model (for example, a neural network). The language model unit 104 converts each character token (token in character units) in the character token string 102a received from the character tokenization unit 102 into a character context vector (context vector in character units), thereby calculating a character context vector string that is a context vector string of context vectors in character units. The language model unit 104 also converts each subword token (token in subword units) in the subword token string 103a received from the subword tokenization unit 103 into a subword context vector, thereby calculating a subword context vector string that is a context vector string of context vectors in subword units.
[0036] The language model used by the language model unit 104 is originally developed on the assumption that subwords obtained using the tokenization function 104-1 are received as input.
[0037] However, in this embodiment, a characteristic that the language model can in principle accept tokens of character units (an example of a second granularity) finer than partial word units (an example of a first granularity) as input is utilized. An example of such a characteristic is as follows. That is, when using a language model, a partial word dictionary (a dictionary mechanically created for the language model) is used. The partial word dictionary describes the relationship between partial words (or their values (e.g., hash values or feature values)) and values included in context vectors. Some partial words obtained by tokenization may be characters. Therefore, even if a character is input, it is expected that a context vector corresponding to the character will be obtained. Therefore, it is possible to input a character token string to the language model unit 104 and obtain a character context vector string. At this time, if a character that does not exist in the partial word dictionary used in the language model unit 104 appears, a special symbol character can be input as an unknown word for convenience.
[0038] In this embodiment, the language model is a probabilistic model, and includes, for example, the following formula (1) and a conditional output unit similar to formula (1). Formula (1) indicates the probability that a token w_i will appear after a token sequence w_1, w_2, ..., w_{i-1} is given as a condition in a calculation using a parameter S. P(w_i|w_1,w_2,...,w_{i-1}; S) ···(1)
[0039] The language model may be in any form. The language model may be a neural network or a linear model. Furthermore, for example, the language model unit 104 may initialize parameters of the language model as a neural network, or adjust (pre-learn) parameters of the neural network by supervised or unsupervised learning. When adjusting parameters of the neural network of the language model unit 104 by supervised learning, for example, ELMo, BERT, and RNN language models may be adopted as the language model.
[0040] The language model may be, for example, a pre-trained language model that is publicly available on the Internet or for sale. In this case, the language model can be used for inference without pre-training the language model. In addition, operations such as parameter adjustment, addition, or deletion may be performed on the pre-trained language model.
[0041] The language model unit 104 outputs the converted character context vector sequence and subword context vector sequence to the context vector sequence synthesis unit 105 .
[0042] The context vector sequence synthesis unit 105 synthesizes the character context vector sequence and the subword context vector sequence received from the language model unit 104 to obtain a context vector sequence, and outputs the synthesized context vector sequence to the context vector sequence output unit 106. The process of synthesizing the character context vector sequence and the subword context vector sequence may be a conversion operation using an operation such as vector sum, vector difference, vector product, and vector combination.
[0043] The context vector sequence output unit 106 presents to the user the context vector sequence received from the context vector sequence synthesis unit 105. The presentation of the context vector sequence to the user is an example of outputting a context vector sequence.
[0044] The context vector sequence output unit 106 can also process the context vector sequence received from the context vector sequence synthesis unit 105. Examples of processing include linearly transforming the context vector, nonlinearly transforming the context vector, and normalizing the context vector.
[0045] The context vector sequence output unit 106 can provide the output context vector sequence to a user. In addition, the user can perform further calculations on the provided context vector sequence to create applications such as morphological analysis, named entity extraction, sentence classification, and translation. <Behavior of the computer in Example 1>
[0046] Graph 903 in Fig. 5 is a diagram showing an example of the ratio of a volatile device (e.g., a non-volatile memory) that is occupied by the language model unit 104 according to the first embodiment. On the other hand, graph 902 in Fig. 4 is a diagram showing an example of the ratio of a volatile device that is occupied by the language model unit according to the comparative example.
[0047] The language model unit 104 performs calculations using the volatile device for two token strings, the character token string and the subword token string. Therefore, as shown in graph 903 in Fig. 5, calculations are performed twice for the character token string and the subword token string during processing by the language model unit 104, and therefore it is estimated that the calculation occupancy rate of the volatile device increases twice.
[0048] On the other hand, according to the comparative example, the language model unit performs calculations only on subword token strings, which are token strings of tokens of a granularity determined in advance for the language model. Therefore, as shown in graph 902 of Fig. 4, while the language model unit according to the comparative example performs processing, calculations are only performed on subword token strings, and therefore it is estimated that the calculation occupancy rate of the volatile device increases only once. <Effects of Example 1>
[0049] According to this embodiment, a character token string is obtained in addition to a subword token string from the text 901, and a character context vector string is obtained in addition to a subword context vector string using a language model. Then, by combining these context vector strings with different granularities, it is possible to obtain a context vector string that reflects the context of each granularity of the character and subword. [Example 2]
[0050] A description will be given of the second embodiment. In this description, the differences from the first embodiment will be mainly described, and the description of the commonalities with the first embodiment will be omitted or simplified. <Configuration of the language model processing device 200 according to the second embodiment>
[0051] FIG. 6 is an example of a functional block diagram of the language model processing device 200 according to the second embodiment.
[0052] The language model processing device 200 includes an input unit 101, a character tokenization unit 102, a subword tokenization unit 103, a tokenization function 104-1, a language model unit 104, a character-centered context vector sequence synthesis unit 201, synthesis parameters 201-1, and a context vector sequence output unit 106. That is, the language model processing device 200 includes the character-centered context vector sequence synthesis unit 201 instead of the context vector sequence synthesis unit 105, and further includes synthesis parameters 201-1.
[0053] Regarding text analysis using the language model processing device 200, if the purpose of the text analysis is character-by-character processing, such as morpheme division or part-of-speech estimation, the context vector sequence must be obtained at the granularity of a character.
[0054] Therefore, the character-centered context vector sequence synthesis unit 201 synthesizes (combines) a subword context vector sequence, which is coarser than characters, based on the settings of synthesis parameters 201-1 for the character context vector sequence received from the language model unit 104, to obtain a context vector sequence with character granularity. The character-centered context vector sequence synthesis unit 201 also outputs the synthesized context vector sequence to the context vector sequence output unit 106. <Processing of the language model processing device 200 in the second embodiment>
[0055] There are various possible methods for the synthesis method (method of synthesizing a subword context vector string with a character context vector string) performed by the character center context vector string synthesis unit 201. This is because it is necessary to synthesize a token string of coarse tokens (subword token string in this embodiment) in accordance with a token string of fine tokens (character token string in this embodiment). In this embodiment, the synthesis method is determined by synthesis parameter 201-1.
[0056] The synthesis parameter 201-1 includes the operation definition of synthesis. For the operation definition of synthesis, operations such as addition, subtraction, multiplication, and combination using the vectors of subword tokens, and combinations of at least two of these operations are conceivable.
[0057] Furthermore, the operation may include linear transformation or non-linear transformation. Also, a neural network may be used for the operation.
[0058] FIG. 7 and FIG. 8 are diagrams each showing an example of the character-centered context vector sequence synthesis unit 201.
[0059] In the examples shown in FIGS. 7 and 8, the character context vector sequence 702 is composed of 12 character context vectors, and the subword context vector sequence 703 is composed of 5 subword context vectors. A context vector sequence 701 is output in which the subword context vector sequence 703 is synthesized with respect to the character context vector sequence 702. Note that the number of character context vectors in the character context vector sequence 702 may be any number, but there is a constraint that "the number of subword context vectors in the subword context vector sequence 703 is necessarily smaller than the number of character context vectors". Note that the dimension of the vector may be any number.
[0060] According to the example shown in FIG. 7, for all character context vectors overlapping with the span of the subword context vector (the range from the i-th character to the j-th character satisfying 0 < i < j < N + 1 and N being the number of tokens in the character token sequence), the subword context vector is synthesized by an operation. This operation is defined as an operation on two vectors. In this case, operations such as addition, subtraction, multiplication, and combination are conceivable for the operation.
[0061] On the other hand, in the calculation illustrated in Fig. 7, the calculation is performed uniformly on the character context vector for the subword context vector, and the degree to which each character context vector attaches importance to the subword context vector is not reflected. For example, assume that the text "ABCD" is given (the characters "A", "B", "C" and "D" in "ABCD" are Japanese, and therefore "ABCD" has a meaning in Japanese, but considering that the present specification will be translated into a language corresponding to the country of application, the text is expressed as "ABCD" here). When the subword tokenization unit 103 divides the text "ABCD" into subwords "AB" and "CD", the character "B" included in the text is simply an auxiliary word for "A", and the information of the context vector included in the subword "AB" is not very important.
[0062] In this way, processing according to the contextual importance of each sub-word vector included in the sub-word context vector sequence 703 can be utilized to obtain a more appropriate context vector sequence 701.
[0063] 8, the character-centered context vector sequence synthesis unit 201 employs a weighted synthesis method. That is, for all character context vectors that overlap with the span of a subword context vector, the subword context vector is synthesized by a weighted operation. The weighted operation is defined as a load operation on two vectors. In this case, the weighted operation assigns weights to the extent to which each context vector is weighted for operations such as addition, difference, product, and combination.
[0064] 8, a weight is assigned to each of one or more character context vectors into which a subword context vector in the subword context vector sequence 703 is synthesized. The weight is determined for each character with the granularity of the character, but it may be determined with a granularity coarser than the character. The weight may also be determined by the user. Furthermore, the weight may be assigned automatically. In this case, for example, the weight may be learned as a parameter of a language model (e.g., a neural network) or adjusted using software.
[0065] In addition, operations may be defined for character context vectors that do not overlap with the span of a subword context vector. In this case, operations such as simultaneously combining the subword context vectors before and after a span can be considered.
[0066] FIG. 9 is a diagram showing an example of a synthesis parameter setting screen 900 for controlling the setting of the synthesis parameter 201-1.
[0067] 9, the types of synthesis parameters that can be set include an operation and a weight. For each of the operation and weight, the user is presented with configurable items. According to the synthesis parameter setting screen 900, a multiplication operation and a uniform weight are set, and synthesis parameters 201-1 according to the settings are reflected in the character center context vector sequence synthesis unit 201.
[0068] The composite parameter 201-1 set via the composite parameter setting screen 900 may be a table, text, or database. The composite parameter setting screen 900 may be divided into a plurality of screens. The composite parameter setting screen 900 may also include other information, item names, or options. <Effects of Example 2>
[0069] According to this embodiment, in synthesizing a character context vector string with a subword context vector string, appropriate synthesis into units with a character granularity becomes possible, and character-based context vectors that reflect the context of each character and subword granularity can be obtained. [Example 3]
[0070] A description will be given of the third embodiment. In this description, differences from the first embodiment will be mainly described, and descriptions of commonalities with the first embodiment will be omitted or simplified. <Configuration of the language model processing device 300 according to the third embodiment>
[0071] Regarding text analysis using a language model processing device, if the purpose of the text analysis is span-based processing, such as classification of a given span, the context vector must be obtained at the granularity of the target span. For example, when a target span from the i-th character to the j-th character contains a proper noun, the target span may be processed to classify whether the proper noun is a person's name or an organization name. Therefore, when performing such classification, it is necessary to obtain a single context vector corresponding to the target span from the i-th character to the j-th character and input it to a proper noun classifier.
[0072] FIG. 10 is an example of a functional block diagram of a language model processing device 300 according to the third embodiment.
[0073] The language model processing device 300 includes an input unit 101, a character tokenization unit 102, a subword tokenization unit 103, a tokenization function 104-1, a language model unit 104, a target span context vector synthesis unit 301, synthesis parameters 301-1, target span data 301-2, and a target span context vector output unit 302. That is, the language model processing device 300 includes a target span context vector synthesis unit 301 instead of the context vector sequence synthesis unit 105, includes a target span context vector output unit 302 instead of the context vector sequence output unit 106, and further includes synthesis parameters 301-1 and target span data 301-2.
[0074] The target span context vector synthesis unit 301 synthesizes the character context vector sequence and the subword context vector sequence received from the language model unit 104 based on the settings in the synthesis parameters 301-1 to obtain a single context vector sequence for the target span. The target span context vector synthesis unit 301 also outputs the synthesized context vector to the target span context vector output unit 302. The target span context vector output unit 302 outputs the synthesized context vector sequence. <Processing of the language model processing device 300 in the third embodiment>
[0075] The target span context vector synthesis unit 301 synthesizes the character context vector sequence and the subword context vector sequence received from the language model unit 104 in a manner similar to the operation of synthesizing two vectors in the second embodiment, and performs an aggregation operation on the synthesized context vector sequence corresponding to the target span to convert the synthesized context vector sequence into a single context vector.
[0076] The synthesis parameters 301-1 include a definition of the operation and a definition of the aggregation operation. Also, the target span data 301-2, which defines how the target span is given, represents the target span to be analyzed in the target span context vector synthesis unit 301.
[0077] In the synthesis parameter 301-1, the definition of the operation may be, for example, an operation such as sum, difference, product, and union using subword vectors, or a combination of two or more of these operations. Also, the definition of the aggregation operation may be, for example, an operation such as sum, difference, product, and union of vectors belonging to the target span, or a combination of two or more of these operations.
[0078] For example, if the purpose of the text analysis is to extract named entities, the target span data 301-2 includes data representing spans of proper nouns. Alternatively, if the purpose of the text analysis is to classify sentences, the target span data 301-2 includes data representing spans of sentences. The target span data 301-2 may also include data representing any span consisting of a span of two or more characters. Furthermore, the spans represented by the target span data 301-2 may be multiple overlapping spans or adjacent spans.
[0079] FIG. 11 is a diagram showing an example of the target span data 301-2.
[0080] 11, the target span represented by target span data 301-2 is a proper noun related to a mountain in text 901, and is four consecutive characters 1101. Also, according to the example shown in Fig. 11, target span data 301-2 is tabular data made up of the same number of cells as the characters contained in text 901, and each of four consecutive cells, the same number as the characters corresponding to the target span, contains the same characters as the four characters 1102 described above.
[0081] Although the target span data 301-2 illustrated in FIG. 11 is data in a table format, the data may be in any format. For example, the target span data 301-2 may be in a text or database format. The target span data 301-2 may also include data representing a target span specified by a user. Furthermore, the target span data 301-2 may include data representing a mechanically constructed target span.
[0082] FIG. 12 is a diagram illustrating an example of the target span context vector synthesizer 301. As shown in FIG.
[0083] 12, the character context vector sequence 1202 is composed of 12 character context vectors, and the word sub-sequence context vector sequence 1203 is composed of 5 word sub-sequence context vectors. Furthermore, the target span is specified as the fourth character to the seventh character of the text 901, with the first character being the first character, based on the target span data 301-2. Note that, as in the second embodiment, the number of character context vectors in the character context vector sequence 1202 may be any number, but there is a constraint that the number of word sub-sequence context vectors is necessarily smaller than the number of character context vectors. Note that the number of dimensions of the numeric vector may be any number.
[0084] 12, the target span context vector synthesis unit 301 synthesizes a character context vector sequence 1202 and a subword context vector sequence 1203 to construct a context vector 1201 of the target span. Specifically, for example, the target span context vector synthesis unit 301 first synthesizes all character context vectors and subword context vectors that overlap with the target span by an operation. Next, the target span context vector synthesis unit 301 converts the target span context vector sequence synthesized by the operation into a single vector, the target span context vector 1201, by an aggregation operation. Therefore, the context vector output unit 302 outputs an appropriate context vector of the target span that reflects both the character-based context and the subword-based context.
[0085] An operation is defined as an operation on two vectors. In this case, the operation can be, for example, sum, difference, intersection, or union. An aggregation operation is defined as an operation on a vector sequence that includes two or more vectors. In this case, the aggregation operation can be, for example, sum, difference, intersection, or union of vector sequences.
[0086] Furthermore, the calculations and aggregations may include linear and non-linear transformations, and neural networks may be used in the calculations.
[0087] Furthermore, in the calculation and aggregation calculation, weights may be used in the same manner as in the second embodiment. If weights are used, a weight is assigned to each vector included in each of the subword context vector sequence 1203 and the character context vector sequence 1202. The weight may be determined for each vector, but the weight may be determined in any unit. The weight may be determined by a user. Furthermore, the weight may be assigned automatically. In this case, for example, a method of learning the weights as parameters of a neural network or adjusting them using software may be considered.
[0088] Furthermore, the operation and the aggregation operation may each be different calculations.
[0089] In addition, in this embodiment, the target span context vector is a single vector, but it does not have to be a single vector, in which case a vector sequence of multiple vectors may be output as the target span context vector, or the aggregation process may be repeated.
[0090] In addition, operations may be defined for character context vectors and subword context vectors that do not overlap with the target span. In this case, operations such as simultaneously combining subword vectors before and after the target span may be considered.
[0091] FIG. 13 is a diagram showing an example of a synthesis parameter setting screen 1300 for controlling the setting of the synthesis parameter 301-1.
[0092] 13, the synthesis parameters that can be set include an operation and a weight used for the operation, and an aggregation operation and a weight used for the aggregation operation. For each of the operation and the weight used for the operation, and the aggregation operation and the weight used for the aggregation operation, the user is presented with configurable items. In the synthesis parameter setting screen 1300, the product operation, uniform weight, sum aggregation operation, and auto-adjustment aggregation operation weight are set, and the settings are reflected in the target span context vector synthesis unit 301.
[0093] The composite parameter 301-1 set via the composite parameter setting screen 1300 may be a table, text, or database. The composite parameter setting screen 1300 may be divided into a plurality of screens. The composite parameter setting screen 1300 may include other information, item names, or options. <Effects of Example 3>
[0094] According to this embodiment, a character context vector sequence and a subword context vector sequence are combined in accordance with an arbitrary target span, and a single context vector for the target span that reflects the context of each character and subword at the granularity can be obtained. <Example of Hardware Configuration of Computer 400 for Realizing Language Model Processing Device>
[0095] FIG. 14 shows an example of the hardware configuration of a computer 400 that realizes the language model processing devices 100, 200, and 300.
[0096] The computer 400 includes a processor 401, a storage device 402, an input device 403, an output device 404, and an interface device 405. These components are connected to each other by a bus 406.
[0097] The processor 401 controls the computer 400. The storage device 402 includes a memory (for example, a volatile device) that serves as a working area for the processor 401. The storage device 402 stores programs and data.
[0098] Each of the yyy units of the above-mentioned language model processing devices 100, 200, and 300 may be realized by the processor 401 executing a temporary or non-temporary program stored in the storage device 402. In addition, each piece of data such as the above-mentioned text 901, synthesis parameters 201-1, synthesis parameters 301-1, and target span data 301-2 may be stored in the storage device 402. In addition, each piece of data required for execution of the language model unit 104, tokenization function 104-1, etc. may be stored in the storage device 402.
[0099] In the language model processing devices 100, 200, and 300, for example, the programs executed by the processor 401 may include an OS (Operating System). In addition, in the language model processing devices 100, 200, and 300, the programs executed may include each program such as an input program, a character tokenization program, a subword tokenization program, a language model program, a tokenization program, a context vector sequence synthesis program, a character-centered context vector sequence synthesis program, a target span context vector synthesis program, a context vector sequence output program, and a target span context vector output program. For example, in the language model processing device 100, the processor 401 executes and operates these programs, and can function as the input unit 101, the character tokenization unit 102, the subword tokenization unit 103, the language model unit 104, the tokenization function 104-1, the context vector sequence synthesis unit 105, and the context vector sequence output unit 106.
[0100] In FIG. 14, each element of software, such as the OS and each program, is stored in some area of the storage device 402 .
[0101] The input device 403 is a device through which a user executes command and data input to the language model processing devices 100, 200, and 300. The input device 403 includes, for example, a mouse, a keyboard, a touch panel, a microphone, and a scanner.
[0102] The output device 404 outputs data output by the language model processing devices 100, 200, and 300. The output device 404 may be, for example, a display, a printer, or a speaker. When the output device 404 is a display, the output device 404 may display, for example, a synthesis parameter setting screen 900 or 1300. When the output device 404 is a display or a printer, the output device 404 may display, for example, a graph 902 or a graph 903.
[0103] The interface device 405 is connected to a network and can transmit and receive each piece of data. The input device 403 and the output device 404 may be omitted. Furthermore, the language model processing devices 100, 200, and 300 may transmit and receive data from a terminal via a network.
[0104] The functions of the language model processing devices 100, 200, and 300 can be implemented in a computer system consisting of one or more computers including a single or multiple processors and a volatile or non-volatile storage medium, and including a single or multiple storage devices. When implemented in a computer system consisting of multiple computers, the computers communicate with each other via a network. In this case, some of the functions of the language model processing device may be implemented in a single computer, and the other parts may be implemented in computers other than the above-mentioned computer.
[0105] The above embodiments have been described in detail to make the present invention easier to understand, and are not necessarily limited to those having all the elements and configurations described. Therefore, the present invention is not limited to the above embodiments, and may include various modifications within a reasonable range. For example, as long as there is no contradiction, a part of the elements and configurations of one embodiment may be replaced with the configurations of another embodiment, and the elements and configurations of another embodiment may be added to the elements and configurations of one embodiment. In addition, for a part of the elements and configurations of each embodiment, addition, deletion, replacement, integration, or distribution of the elements and configurations may be performed. In addition, the elements, configurations, and processes shown in the embodiments may be appropriately distributed, integrated, or replaced based on processing efficiency or implementation efficiency.
[0106] Furthermore, the language model processing devices 100, 200, and 300 may be used for languages other than Japanese instead of or in addition to Japanese, but are expected to be highly useful in analyzing text written in languages such as Japanese or Chinese in which characters occur in successive words without any explicit distinction (e.g., blank spaces) between words.
[0107] The above description can be summarized, for example, as follows. Note that the following summary may include new explanations (for example, explanations of modified examples) that are not included in the above description.
[0108] The language model processing device includes a first tokenization unit (e.g., a subword tokenization unit 103), a second tokenization unit (e.g., a character tokenization unit 102), a language model unit (e.g., a language model unit 104, or a language model unit 1550 described later with reference to FIG. 15), a synthesis unit (e.g., a context vector sequence synthesis unit 105, a character center context vector sequence synthesis unit 201, or a target span context vector synthesis unit 301), and an output unit (e.g., a context vector sequence output unit 106, or a target span context vector output unit 302).
[0109] The first tokenization unit obtains from a text (e.g., text 901) a first token sequence (e.g., subword token sequence 103a) composed of one or more first tokens, each of which is a token of a first granularity (e.g., subword unit) corresponding to a first language model.
[0110] The second tokenization unit obtains from the text a second token string (e.g., character token string 102a) composed of one or more second tokens, each of which is a token of a second granularity (e.g., character unit) different from the first granularity.
[0111] The language model unit obtains, as an output of the first language model, a first context vector sequence (e.g., a subword context vector sequence) composed of one or more first context vectors (e.g., subword context vectors) corresponding to the one or more first tokens, by inputting each of the one or more first tokens in the first token sequence to a first language model among the one or more language models. The language model unit obtains, as an output of the first language model, a second context vector sequence (e.g., a character context vector sequence) composed of one or more second context vectors (e.g., character context vectors) corresponding to the one or more second tokens, by inputting each of the one or more second tokens in the second token sequence to a first language model among the one or more language models or a second language model different from the first language model.
[0112] The combiner combines all or a part of the first context vectors in the first context vector sequence with all or a part of the second context vector sequence in the second context vector sequence, and the output unit outputs a combined context vector sequence based on one or more context vectors obtained by combining all or a part of the first context vectors with all or a part of the second context vectors.
[0113] In this way, the second token sequence is obtained from the text in addition to the first token sequence, and the second context vector sequence is obtained in addition to the first context vector sequence using at least the first language model. Then, these context vector sequences with different granularities are combined. This makes it possible to obtain an appropriate context vector sequence that reflects the context of the first granularity in addition to the context of the second granularity appropriate for a higher-level task such as text analysis without constructing a new language model. Note that the token being input to the language model may mean that the token itself is input, but typically, the value of the token (e.g., a value such as a hash value or a feature value) is input.
[0114] The second granularity may be a granularity finer than the first granularity. For example, at least one of the following (A) to (C) may be adopted. (A) The synthesis unit may synthesize all or a part of the first context vectors with all or a part of the second context vectors. This makes it possible to obtain a context vector in which a coarse-grained context is associated with a fine-grained context. Furthermore, the synthesis unit may synthesize all or a part of the first context vectors with all or a part of the second context vectors based on the weights for all or a part of the second context vectors and the weights for all or a part of the first context vectors. This makes it possible to obtain a more appropriate context vector sequence that reflects the weights of the contexts. (B) One or more first tokens and one or more second tokens may be input to the first language model. That is, one first language model is used to obtain both the first context vector sequence and the second context vector sequence. This makes it possible to avoid an increase in model size, and thus it is expected that the learning load and the consumed memory capacity will be reduced. In addition, since some second tokens are expected to be the same as the first tokens and the same dictionary is used, it is expected that the processing will be efficient. (C) The whole or a part of the second context vector sequence may be a part of two or more second context vectors respectively corresponding to two or more second tokens belonging to a target span having a range larger than one second token. The whole or a part of the first context vector sequence may be a part of one or more first context vectors respectively corresponding to one or more first tokens including a first token to which at least one of the two or more second tokens belongs. The synthesis unit may synthesize one or more first context vectors with two or more second context vectors, and obtain a target span context vector sequence that is one or more context vectors aggregating the two or more second context vectors into which the whole or a part of the first context vectors are synthesized. The target span context vector sequence may be a synthesized context vector sequence. This makes it possible to obtain a single context vector for the target span that reflects the contexts of the first granularity and the second granularity.
[0115] In (C), the synthesis unit may synthesize one or more first context vectors with two or more second context vectors based on the weights for each of the two or more second context vectors and the weights for each of the one or more first context vectors, which is expected to result in more appropriate synthesis that reflects the weights of the contexts.
[0116] In (C), the synthesis unit may acquire a target span context vector sequence by aggregating two or more second context vectors based on the weights for each of the two or more second context vectors. For example, the weighted operation described with reference to Fig. 8 may be applied to the aggregation operation described with reference to Fig. 12. This is expected to result in more appropriate aggregation that reflects the context weights.
[0117] In the above description, any rule may be adopted as the rule for combining context vectors of different granularities. For example, any of the following rules may be adopted. The first token is composited with all second tokens whose ranges overlap the range of the first token. A first token whose range exactly matches the range of a second token is composited into that second token. A first token is composited into a second token whose start of range matches the start of the first token's range.
[0118] The one or more second tokens may be input to the second language model. As a result, the one or more second tokens may be acquired by a tokenization function (function for acquiring tokens of a second granularity) corresponding to the second language model, so that it is expected to acquire a more appropriate second token sequence and a more appropriate second context vector sequence corresponding to the second token sequence. For example, the modified example illustrated in FIG. 15 may be applied to the first embodiment. That is, the language model unit 1550 may be able to use a language model 1502 for character units (an example of a second granularity) in addition to a language model 1501 (an example of a first language model) for subword units (an example of a first granularity). The language model 1502 may be accompanied by a tokenization function 1502-1 for character units. The character token unit 1502-2 may acquire a character token sequence using the tokenization function 1502-1. The language model unit 1550 may obtain a subword context vector sequence by inputting the subword token sequence to the language model 1501, and obtain a character context vector sequence by inputting the character token sequence to the language model 1502. In this way, the use of different language models corresponding to different granularities may be applied to at least one of the second and third embodiments instead of or in addition to the first embodiment. Also, even in the example in which a plurality of different language models are used, the acquisition of a target span context vector sequence and the execution of an operation or an aggregation operation according to a weight may be adopted. That is, any combination of the first to third embodiments described above and the modified example illustrated in FIG. 15 may be used.
Claims
1. A subword tokenizer that acquires from a text a subword token string composed of one or more subword tokens corresponding to a language model developed on the assumption that subwords are accepted as input; a character tokenizer for obtaining a character token string from the text, the character token string being composed of one or more character tokens; a language model unit that uses one or more sub-word tokens in the sub-word token string as an input to the language model, thereby obtaining, as an output of the language model, a sub-word context vector string composed of one or more sub-word context vectors corresponding to the one or more sub-word tokens, and that uses one or more character tokens in the character token string as an input to the language model, thereby obtaining, as an output of the language model, a character context vector string composed of one or more character context vectors corresponding to the one or more character tokens, a synthesis unit that synthesizes all or a part of the sub-word context vectors in the sub-word context vector sequence and all or a part of the character context vectors in the character context vector sequence; an output unit that outputs a composite context vector sequence based on one or more context vectors obtained by combining all or a part of the subword context vectors and all or a part of the character context vectors; Equipped with the whole or part of the character context vector sequence is a part of two or more character context vectors respectively corresponding to two or more character tokens belonging to a target span (a range from an i-th character to a j-th character, satisfying 0<i<j<N+1, where N is the number of tokens in the character token sequence), the whole or part of the sub-word context vector sequence is a part of one or more sub-word context vectors corresponding to one or more sub-word tokens including a sub-word token to which at least one of the two or more character tokens belongs, the synthesis unit synthesizes the one or more subword context vectors with the two or more character context vectors to obtain a target span context vector sequence that is one or more context vectors aggregating the two or more character context vectors into which the one or more subword context vectors have been synthesized; the target span context vector sequence is the composite context vector sequence; A language model processor.
2. the synthesis unit synthesizes the one or more sub-word context vectors with the two or more character context vectors based on a weight for each of the two or more character context vectors and a weight for each of the one or more sub-word context vectors. The language model processing device according to claim 1 .
3. the synthesis unit acquires the target span context vector sequence by aggregating the two or more character context vectors based on a weight for each of the two or more character context vectors. The language model processing device according to claim 1 .
4. A computer obtains from a text a subword token string composed of one or more subword tokens corresponding to a language model developed on the assumption that the computer will receive subwords as input; A computer obtains a character token string from the text, the character token string being composed of one or more character tokens; a computer inputs one or more sub-word tokens in the sub-word token sequence into the language model, and obtains, as an output of the language model, a sub-word context vector sequence composed of one or more sub-word context vectors corresponding to the one or more sub-word tokens, respectively; a computer inputs one or more character tokens in the character token string into the language model, and obtains, as an output of the language model, a character context vector string composed of one or more character context vectors corresponding to the one or more character tokens, respectively; a computer combines all or a part of the sub-word context vector sequence in the sub-word context vector sequence with all or a part of the character context vectors in the character context vector sequence; a computer outputs a composite context vector sequence based on one or more context vectors obtained by combining all or a part of the subword context vector and all or a part of the character context vector; the whole or part of the character context vector sequence is a part of two or more character context vectors respectively corresponding to two or more character tokens belonging to a target span (a range from an i-th character to a j-th character, satisfying 0<i<j<N+1, where N is the number of tokens in the character token sequence), the whole or part of the sub-word context vector sequence is a part of one or more sub-word context vectors corresponding to one or more sub-word tokens including a sub-word token to which at least one of the two or more character tokens belongs, a computer combines the one or more subword context vectors with the two or more character context vectors in the combination of the subword context vectors and the character context vectors, and obtains a target span context vector sequence which is one or more context vectors aggregating the two or more character context vectors into which the one or more subword context vectors have been combined; the target span context vector sequence is the composite context vector sequence; A language model processing method comprising:
5. A subword token string composed of one or more subword tokens corresponding to a language model developed on the assumption that subwords are accepted as input is obtained from a text, obtaining a character token string from the text, the character token string being composed of one or more character tokens; by inputting one or more sub-word tokens in the sub-word token sequence into the language model, and obtaining, as an output of the language model, a sub-word context vector sequence composed of one or more sub-word context vectors corresponding to the one or more sub-word tokens, respectively; by inputting one or more character tokens in the character token string into the language model, the language model outputs a character context vector string including one or more character context vectors each corresponding to the one or more character tokens; combining all or a part of the sub-word context vector sequence in the sub-word context vector sequence with all or a part of the character context vectors in the character context vector sequence; the computer outputs a composite context vector sequence based on one or more context vectors obtained by combining all or a part of the subword context vector and all or a part of the character context vector; Have the computer do this, the whole or part of the character context vector sequence is a part of two or more character context vectors respectively corresponding to two or more character tokens belonging to a target span (a range from an i-th character to a j-th character, satisfying 0<i<j<N+1, where N is the number of tokens in the character token sequence), the whole or part of the sub-word context vector sequence is a part of one or more sub-word context vectors corresponding to one or more sub-word tokens including a sub-word token to which at least one of the two or more character tokens belongs, a computer combines the one or more subword context vectors with the two or more character context vectors in the combination of the subword context vectors and the character context vectors, and obtains a target span context vector sequence which is one or more context vectors aggregating the two or more character context vectors into which the one or more subword context vectors have been combined; the target span context vector sequence is the composite context vector sequence; Computer program.
Citation Information
Patent Citations
Morphological analysis learning device, morphological analysis device, method and program
JP2019144844A
Intent Classification Method and System
US20200050667A1
