Phrase vector generation device, phrase vector generation method, and program
The phrase vector generation device addresses the challenges of reflecting context information and training data limitations by using BERT and RNN-based methods to generate accurate and context-aware phrase vectors, improving the representation of semantically similar phrases.
Patent Information
- Application Number
- PCT/JP2023/016496
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-04-26
- Publication Date
- 2024-10-31
AI Technical Summary
Conventional methods for generating phrase vectors fail to accurately reflect surrounding context information and often have insufficient training data to bring vectors of phrases with the same meaning closer together, resulting in inappropriate distance measurements between phrase vectors.
A phrase vector generation device and method that inputs a set of sentences as sequences of basic tokens, performs token string conversion, pre-learning processing using BERT, and updates parameter variables to generate phrase vectors that integrate surrounding context information and token information, using techniques like RNN and pooling to ensure accurate representation.
The proposed solution generates appropriate phrase vectors that accurately reflect surrounding context information and bring vectors of semantically similar phrases closer together, improving the accuracy of phrase vector representation.
Smart Images

Figure JP2023016496_31102024_PF_FP_ABST
Abstract
Description
Phrase vector generation device, phrase vector generation method and program
[0001] The present invention relates to a phrase vector generation device, a phrase vector generation method, and a program.
[0002] The basic units obtained by dividing a string of characters, such as a natural language, are called base tokens. An example of a base token is a word. In recent neural network processing, due to computational constraints and the need to deal with unknown words, subwords, which are obtained by further dividing words, are often used, and these subwords are another example of base tokens.
[0003] A sentence can be viewed as a sequence of basic tokens.
[0004] On the other hand, a string of characters consisting of a sequence of multiple basic tokens that are part of a sentence is called a phrase. If a word is taken as the basic token, a compound word consisting of a sequence of multiple words is a phrase. If a subword is taken as the basic token, a word consisting of a sequence of multiple subwords is a phrase.
[0005] The difference between basic tokens is called a type. A method based on BERT, described in Non-Patent Document 1, is a method for generating type vectors to quantify the semantic similarity between types.
[0006] In a BERT-based approach, a set of sentences is input to BERT, and an embedding vector, each element of which is a parameter variable, is associated with each type of basic token in the set. Each sentence in the set is treated as a sequence of embedding vectors of the type corresponding to each token in the sentence, and the set of sentences is pre-trained using the BERT neural network. As a result, values of parameter variables in BERT, including each element of the embedding vector, are derived. The embedding vectors of each type after pre-training take into account the surrounding context information of the tokens of that type in each sentence in the set of sentences. When a sentence is then input to BERT, the BERT neural network processes the sentence as a sequence of embedding vectors of the type corresponding to each token in the sentence, and an output vector of the same dimension as the embedding vector is derived for each token in the sentence. The output vector corresponding to each token takes into account the surrounding context information of that token in the sentence.
[0007] Furthermore, as a method for generating sentence vectors for quantifying the semantic similarity between sentences, there is a method based on Sentence BERT described in Non-Patent Document 2.
[0008] In a method based on Sentence BERT, as shown in Figure 1, sentences A and B with the same meaning are input to two pre-trained BERTs with the same parameter variables. For each sentence, sentence vectors u and v are derived by pooling the output vectors of each token in the sentence, and the values of the parameter variables in the BERT are updated so that the sentence vectors u and v are the same. Examples of vectors obtained by pooling include the average vector of the output vectors of each token in the sentence, and a vector whose element values are the maximum value of the corresponding element values of the output vectors of each token in the sentence. After this process, the sentence is input to the BERT, and the sentence vector of the sentence is derived by pooling the output vectors of each token in the sentence. These sentence vectors tend to be close to sentence vectors corresponding to sentences with the same meaning.
[0009] Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova, "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding", NAACL, pp.4171-4186, 2019. Nils Reimers, Iryna Gurevych, "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks", ACL, pp.3982-3992, 2019.
[0010] One method for generating a phrase vector for a phrase, which is a string of characters made up of a sequence of basic tokens that are part of a sentence, is to treat the phrase as a sentence, input the phrase into BERT after updating the values of parameter variables using Sentence BERT, and derive the phrase vector for the phrase by pooling the output vectors of each token in the phrase.
[0011] However, there are generally not many pairs of semantically identical but different phrases used in training Sentence BERT (updating the parameter variable values).Also, there are not many cases where each sentence in a pair of semantically identical sentences used for training contains different semantically identical phrases.
[0012] Because there is little training data for bringing the vectors of phrases with the same meaning closer together, the distance between phrase vectors tends to be inappropriate depending on the configuration of the basic tokens that form the phrase. As an example, consider three phrases in which the basic tokens are words, as shown in Figure 2. In Figure 2, each basic token is surrounded by a square. Semantically, the distance between "Cardiovascular Basic Research Forum 2022" and "Academic Lecture of the Japanese Society of Cardiology" is closer than the distance between "Academic Lecture of the Japanese Society of Cardiology" and "Academic Lecture of the Japanese Society of Nutrition." However, since all basic tokens except for one basic token are identical in the latter pair, the distance between the latter pair in the phrase vectors derived by Sentence BERT is closer than the distance between the former pair.
[0013] In general, the basic tokens that make up a phrase are thought to have a hierarchy in terms of the degree of influence they have on the meaning of the phrase. In each of the three phrases shown in Figure 3, the basic tokens enclosed in solid boxes are thought to have a greater influence on the meaning of the phrase than the basic tokens enclosed in dashed boxes.
[0014] The extent to which the basic tokens that make up such a phrase affect the meaning of the phrase is thought to be related to information about the surrounding context of the phrase, as shown in Figure 4. The more semantically related a constituent basic token is to the surrounding context, the greater its influence on the meaning of the phrase. In Figure 4, the basic tokens enclosed in boxes in the surrounding context and the basic tokens enclosed in solid boxes within the phrase are closely related semantically.
[0015] In general, the meaning of a phrase is naturally influenced by the information of the basic tokens that make up the phrase, but it is also thought to be influenced by information about the phrase's surrounding context. The above is one factor. Because the meaning of a phrase is influenced by the surrounding context information of a phrase, it is thought that phrases with similar surrounding context information tend to be semantically close to each other. In Figure 2, the surrounding context information for "Cardiovascular Basic Research Forum 2022" and "Japanese Society of Cardiology Academic Conference" is similar, while the surrounding context information for "Japanese Society of Cardiology Academic Conference" and "Japanese Society of Nutrition Academic Conference" is dissimilar. Therefore, if the surrounding context information of the phrase is taken into consideration when generating phrase vectors, it can be expected that the distance between the former pair will be closer than the distance between the latter pair.
[0016] If we call the set of sentences input in the pre-training of BERT a corpus, the surrounding context of a phrase in the corpus is also the surrounding context of the basic tokens that make up the phrase, so the embedding vectors and output vectors of the basic tokens that make up the phrase after pre-training take into account the surrounding context information of the phrase in the corpus. Therefore, even if a phrase vector is generated using only the vector information of the basic tokens that make up the phrase, it may appear at first glance that the generated phrase vector takes into account the surrounding context information of the phrase in the corpus.
[0017] However, the surrounding context of a basic token in a phrase does not include the phrase itself, but also includes the surrounding context of a sentence in which the basic token appears. The surrounding context of a phrase is included in the intersection of the surrounding contexts of the basic tokens that make up the phrase. Figure 5 illustrates this, in which the surrounding context of the phrase "Bank of Japan" is included in the intersection of the surrounding contexts of the basic tokens "Japan" and "Bank" that make up the phrase. The context of a sentence such as "I exchanged money at the bank to go sightseeing in Japan" is included in the intersection of the surrounding contexts of "Japan" and "Bank" but not in the surrounding context of "Bank of Japan." As such, the intersection of the surrounding contexts in the corpus that is taken into account by the vectors of each basic token that makes up a phrase is different from the surrounding context of the phrase in the corpus, and noise information unrelated to the phrase is present. This creates a problem in that the phrase vector generated from the vectors of each basic token that makes up a phrase does not accurately reflect the surrounding context information of the phrase in the corpus.
[0018] As described above, conventional methods have two problems: 1) there is little training data to bring the vectors of phrases with the same meaning closer together; and 2) the surrounding context information of phrases in the corpus cannot be accurately reflected. This results in problems such as inappropriate distances between generated phrase vectors.
[0019] The present invention has been made in view of the above points, and has as its object to generate appropriate phrase vectors.
[0020] To solve the above problem, the phrase vector generation device has a token sequence conversion means that inputs a set of sentences as a sequence of basic tokens, which are the basic units of a character string, and generates new sentences by replacing a basic token sequence A consisting of a plurality of basic tokens that form part of the sentence with a phrase token formed by concatenating the basic tokens in A, or by replacing a basic token A', which is also a phrase token in the sentence, with a token sequence formed by the plurality of tokens that make up A'; and a token sequence conversion means that inputs a set of sentences as a sequence of basic tokens or phrase tokens, and associates an embedding vector, each element of which is a parameter variable, with each type that is a difference between the basic tokens or phrase tokens in the set, and converts each sentence in the set into a sequence of embedding vectors of the type corresponding to each token in the sentence, and converts the set into a sequence of embedding vectors of the type corresponding to each token in the sentence. The neural network includes a pre-learning processing means for performing a learning process on a neural network including a BERT and deriving values of parameter variables in the neural network including each element of the embedding vector; and a parameter variable updating means for processing the neural networks B and C, which have the same parameter variables after the processing by the pre-learning processing means, inputting a set of pairs of a sentence E and a sentence D in which a phrase token G in E is replaced with a string F of tokens that make up G, inputting D to B and E to C for each pair D and E in the set, and updating the values of B and C and the parameter variables in the integration process so that a vector H obtained by integrating the output vectors of each token in F using an integration process including a neural network such as an RNN or pooling is the same as the output vector I of G.
[0021] The phrase vector generation device further includes a phrase vector derivation means for inputting a sentence into the neural network and deriving, for any token sequence that is part of the sentence, a vector obtained by integrating the output vectors of each token in the token sequence through the integration process, as the vector of the phrase corresponding to the token sequence.
[0022] An appropriate phrase vector can be generated.
[0023] 1 is a diagram for explaining a method based on Sentence BERT. FIG. 1 is a diagram showing three examples of phrases when basic tokens are words. FIG. 2 is a diagram for explaining differences in the degree of influence of basic tokens on the meaning of a phrase. FIG. 3 is a diagram for explaining the relationship between the degree of influence of basic tokens on the meaning of a phrase and information on the surrounding context of the phrase. FIG. 4 is a diagram for explaining that the surrounding context of a phrase is included in the intersection of the surrounding contexts of the basic tokens that make up the phrase. FIG. 5 is a diagram showing an example of the hardware configuration of a phrase vector generation device 10 in an embodiment of the present invention. FIG. 6 is a diagram showing an example of the functional configuration of a phrase vector generation device 10 in an embodiment of the present invention. FIG. 7 is a diagram for explaining the processing content of a token sequence conversion means 11. FIG. 8 is a diagram showing a matrix U in which p embedding vectors are arranged in order as a 1 × r matrix. FIG. 9 is a diagram showing how a type sequence is input to a neural network including BERT. FIG. 10 is a diagram showing the processing content of a parameter variable update means 13.
[0024] The following describes an embodiment of the present invention with reference to the accompanying drawings. The following description takes as an example a case where a word is taken as a basic token and a compound word is taken as a phrase, which is a character string made up of a basic token sequence consisting of multiple basic tokens that are part of a sentence. However, the same applies to cases where other units are taken for the basic token and phrase, including cases where a subword is taken as a basic token and a word is taken as a phrase.
[0025] 6 is a diagram showing an example of the hardware configuration of a phrase vector generation device 10 according to an embodiment of the present invention. The phrase vector generation device 10 shown in FIG. 6 includes a drive device 100, an auxiliary storage device 102, a memory device 103, a processor 104, and an interface device 105, all of which are interconnected via a bus B.
[0026] The program that realizes the processing in the phrase vector generation device 10 is provided by a recording medium 101 such as a CD-ROM. When the recording medium 101 storing the program is set in the drive device 100, the program is installed from the recording medium 101 to the auxiliary storage device 102 via the drive device 100. However, the program does not necessarily have to be installed from the recording medium 101, but may be downloaded from another computer via a network. The auxiliary storage device 102 stores the installed program as well as necessary files, data, etc.
[0027] When an instruction to start the program is received, the memory device 103 reads and stores the program from the auxiliary storage device 102. The processor 104 is a CPU or a GPU (Graphics Processing Unit), or a CPU and a GPU, and executes functions related to the phrase vector generation device 10 in accordance with the program stored in the memory device 103. The interface device 105 is used as an interface for connecting to a network.
[0028] FIG. 7 is a diagram showing an example of the functional configuration of a phrase vector generation device 10 according to an embodiment of the present invention. Arrows between means indicate the order of processing performed by each means. In FIG. 7, the phrase vector generation device 10 includes a token string conversion means 11, a pre-learning processing means 12, a parameter variable update means 13, and a phrase vector derivation means 14. These units are realized by the processor 104 executing one or more programs installed in the phrase vector generation device 10. In this embodiment, the phrase vector generation device 10 performs a learning process using training data, which is performed using only the token string conversion means 11, the pre-learning processing means 12, and the parameter variable update means 13, and a process of deriving a vector of an arbitrary phrase after the learning process, which is performed using only the phrase vector derivation means 14.
[0029] [First embodiment of the present invention] A learning process using learning data according to a first embodiment of the present invention will be described. The learning process using learning data is performed using only the token string conversion means 11, the pre-learning processing means 12, and the parameter variable update means 13.
[0030] First, the processing performed by the token string conversion means 11 will be described.
[0031] The token string conversion means 11 receives a set of sentences as a string of basic tokens, which are the basic units of a character string, and generates new sentences by replacing a basic token string A consisting of multiple basic tokens that form part of a sentence in the set with a phrase token formed by concatenating the basic tokens in A, or by replacing a basic token A', which is also a phrase token in the sentence, with a token string consisting of the multiple tokens that make up A'.
[0032] Details are provided below.
[0033] The token string (a) in Figure 8 is an example of a sentence in a set of sentences as a basic token string. Each basic token is surrounded by a square. For such a sentence, the token string conversion means 11 generates a sentence by replacing a basic token string A consisting of multiple basic tokens that form part of the sentence with a phrase token formed by concatenating the basic tokens in A. There can be multiple basic token strings to be replaced in a single sentence, and it is possible to generate a sentence by replacing only one of them, or to generate a sentence by replacing multiple tokens.
[0034] The token string (b) is a sentence in which the basic token strings "electronic" and "piano" in the token string (a) are replaced with the phrase token "electronic piano."
[0035] The token string (c) is a sentence in which the basic token strings "music" and "school" in the token string (a) are replaced with the phrase token "music school."
[0036] Token sequence (d) is a sentence in which the basic token sequences "electronic" and "piano" in token sequence (a) are replaced with the phrase token "electronic piano," and the basic token sequences "music" and "school" are replaced with the phrase token "music school."
[0037] Here, if the frequency of a certain phrase is low in the corpus, which is a set of sentences input to the subsequent processing by the pre-training processing means 12, it may be possible that the surrounding context information of that phrase in the corpus cannot be accurately reflected in the generation vector of that phrase. Also, if all phrases are processed in the processing by the pre-training processing means 12, the number of different types of tokens may increase, resulting in a large amount of calculation. To avoid these problems, the token string conversion means 11 may be configured not to replace phrases with low frequency in the corpus.
[0038] Furthermore, in a vocabulary set, which is a set of different basic tokens, there may be basic tokens that are made up of sequences of other basic tokens. For example, a vocabulary set may include an "electronic piano" that is made up of the sequence of basic tokens "electronic" and "piano." Such a basic token made up of a sequence of other basic tokens is also a phrase token.
[0039] The token string conversion means 11 generates a sentence in which a basic token A', which is also a phrase token in the sentence, is replaced with a token string consisting of the multiple tokens that make up A'. Here, the tokens that make up A' are usually basic tokens, but they may also be phrase tokens. Also, there can be multiple basic tokens to be replaced in a single sentence, and the sentence may be generated in which only one of them is replaced, or in which multiple tokens are replaced.
[0040] For example, if the basic tokens are "electronic," "piano," and "electronic piano," the token sequence (a) is generated by replacing the basic token "electronic piano" in the token sequence (b) with the basic token sequence "electronic" and "piano."
[0041] Furthermore, the token string conversion means 11 may replace both basic token strings with phrase tokens and phrase tokens with token strings within one sentence.
[0042] For example, if the basic tokens are "electronic," "piano," and "electronic piano," then in token sequence (b), the basic token sequences "music" and "school" are replaced with the phrase token "music school," and the basic token "electronic piano" is replaced with the basic token sequences "electronic" and "piano," thereby generating token sequence (c).
[0043] The token string conversion means 11 can change the combination of whether or not to replace basic token strings with phrase tokens and whether or not to replace phrase tokens with token strings, depending on the sentence in the input sentence set. Depending on the sentence, it may be possible that neither replacement process is performed.
[0044] It is also possible to adopt a configuration in which no replacement processing is performed on any sentences in the input sentence set, i.e., no processing is performed by the token string conversion means 11. In this configuration, phrase tokens in other means refer to phrase tokens that are also basic tokens included in a vocabulary set, which is a set of variations on the original basic tokens.
[0045] Next, the processing contents of the pre-learning processing means 12 will be described.
[0046] The pre-training processing means 12 inputs a set of sentences as a sequence of basic tokens or phrase tokens, associates an embedding vector, each element of which is a parameter variable, with each different type of basic token or phrase token in the set, and performs a training process on the set using a neural network including a BERT, treating each sentence in the set as a sequence of embedding vectors of a type corresponding to each token in the sentence, and derives the values of the parameter variables in the neural network that include each element of the embedding vector.
[0047] Details are provided below.
[0048] The pre-training processing means 12 receives as input a set of sentences from the sentence set input to the token string conversion means 11 and sentences generated by the token string conversion means 11. The sentences in the input sentence set are sequences of basic tokens or phrase tokens. Here, the pre-training processing means 12 can also receive as input only the set of sentences generated by the token string conversion means 11.
[0049] The pre-learning processing means 12 calculates each type x, which is a difference between basic tokens or phrase tokens in the input sentence set. i (1≦i≦p). The pre-learning processing means 12 i (1≦i≦p), each element of the embedding vector u is a parameter variable.i = (u ik ) 1≦k≦r (1≦i≦p) are associated with each other. Fig. 9 shows a matrix U in which the p embedding vectors are arranged in order as a 1 x r matrix.
[0050] Let x be a string of types corresponding to basic tokens or phrase tokens in any sentence in the input sentence set. m_g (1≦g≦h). There can be multiple identical types in this type string. Note that the "_g" in m_g in the text corresponds to the subscript of m in the drawings.
[0051] The pre-learning processing means 12 inputs this type sequence into a neural network including BERT. Figure 10 shows this. After input, each type x m_g is the corresponding embedding vector u m_g The embedding vector u after transformation is m_g (1≦g≦h) are subjected to computation in the neural network, and a sequence of output vectors with dimension r corresponding to each input token is generated. g (1≦g≦h) is obtained (output vectors corresponding to the same type of token in different positions will generally have different vector values).
[0052] In practice, the type [CLS] representing the beginning of a sentence and its embedding vector u [CLS] , the type [SEP] representing the end of the sentence and its embedding vector u [SEP] The pre-learning processing means 12 performs processing to insert [CLS] at the beginning of a sentence and [SEP] at the end of a sentence in an input token string. The neural network obtains output vectors corresponding to each of these.
[0053] The pre-learning processing means 12 performs neural network learning processing (such as Masked Language Modeling in BERT) on the input sentence set to generate each embedding vector u i = (u ik ) 1≦k≦r The parameter variables of each element (1≦i≦p) and the values of other parameter variables in the neural network are derived. This learning process is called pre-learning.
[0054] After pre-training, each type of embedding vector accurately reflects the surrounding context of that type of token in each sentence in the corpus, which is a set of input sentences. Therefore, phrase vectors, i.e., embedding vectors of a type corresponding to a phrase token, accurately reflect the surrounding context of that phrase in the corpus.
[0055] A phrase vector accurately reflects the surrounding context information of the phrase in the corpus, but different phrases may have similar surrounding context information in the corpus, and a phrase cannot be determined by surrounding context information alone. To generate an appropriate phrase vector, information on the tokens that make up the phrase is also required. For this reason, the following processing by the parameter variable update means 13 is carried out to generate an appropriate phrase vector.
[0056] After pre-training, when a sentence is input to the neural network, the neural network processes the sentence as a sequence of embedding vectors of a type corresponding to each token in the sentence, and derives an output vector of dimension r corresponding to each token in the sentence. This output vector corresponding to each token reflects the surrounding context information of the token in each sentence in the corpus, as well as the surrounding context information of the token in the input sentence.
[0057] Next, the processing contents of the parameter variable updating means 13 will be described.
[0058] The parameter variable update means 13 processes neural networks B and C having the same parameter variables after processing by the pre-learning processing means 12, and inputs a set of pairs of sentence E and sentence D in which phrase token G in E is replaced with a string F of tokens that make up G. For each pair D, E in the set, D is input to B and E is input to C, and the values of B, C, and the parameter variables in the integration process are updated so that a vector H obtained by integrating the output vectors of each token in F using an integration process including a neural network such as an RNN or pooling is the same vector as the output vector I of G.
[0059] Details are provided below.
[0060] FIG. 11 is a diagram showing the processing contents of the parameter variable updating means 13 using an example of a pair of sentences.
[0061] The parameter variable update means 13 processes neural networks B and C that have the same parameter variables after the processing by the pre-learning processing means 12. Since B and C have the same corresponding parameter variables, the values of the corresponding parameter variables are always the same.
[0062] The parameter variable updating means 13 inputs a set of pairs of sentence E and sentence D in which phrase token G in E has been replaced with a string F of tokens that make up G. In the example of D and E in FIG. 11 , each token is surrounded by a solid or dashed line box, and the phrase token "ongaku gakkou" (music school) surrounded by a solid line in sentence E is G, and the string of tokens "ongaku" (music) and "gakkou" (school) surrounded by a solid line in sentence D is F, with F being the string of tokens that make up G. Here, each token in F is usually a basic token, but may also be a phrase token. For example, phrase token G "Tokyo Ongaku Gakkou" (Tokyo Music School) may be replaced with the string F of the basic token "Tokyo" and phrase token "ongaku gakkou" (music school).
[0063] When the parameter variable update means 13 inputs D into B and E into C for each pair D, E in the input set, the neural network processing results in an output vector of dimension r for each token in the input sentence.
[0064] The output vector of each token in the token sequence F does not accurately reflect the surrounding context information of the phrase token G in the corpus. On the other hand, the output vector I of G accurately reflects the surrounding context information of G in the corpus, but does not reflect the information of the tokens that make up G.
[0065] The token sequence F and phrase token G have the same character string, and in the sentences D and E in which they exist, the token sequences other than themselves are completely identical, so the vector to be derived from F should be the same as the output vector I of G. For this reason, the parameter variable updating means 13 updates the parameter variables so that vector H, which is obtained by integrating the output vectors of each token in F, becomes the same as the output vector I of G.
[0066] Specifically, the parameter variable updating means 13 sequentially inputs the output vector of each token in F into a neural network such as an RNN (recurrent neural network) to obtain an integrated vector H with a dimension number of r. Alternatively, the parameter variable updating means 13 obtains the integrated vector H with a dimension number of r by pooling the output vectors of each token in F. The parameter variable updating means 13 updates the values of parameter variables (including elements of each type of embedded vector) in the integration process of the neural networks B, C, and RNN, etc., so that the sum of the difference between the cosine similarity between the integrated vector H and the output vector I of phrase token G and the maximum value of the cosine similarity, 1, for all pairs in the input set is minimized. Alternatively, the parameter variable values may be updated so that the sum of the distance between the integrated vector H and the output vector I of phrase token G for all pairs in the input set is minimized.
[0067] By doing so, the vector based on the context information surrounding the phrase in the corpus and the vector based on the token information constituting the phrase will come closer together. After the processing by the parameter variable update means 13, the neural network and the parameter variables in the integration process will have the property of deriving an appropriate phrase vector that also reflects the context information surrounding the phrase in the corpus from the sequence of output vectors of each token constituting the phrase.
[0068] [Second embodiment of the present invention] The second embodiment of the present invention is carried out after the learning process of the first embodiment of the present invention, and derives a vector of an arbitrary phrase using only the phrase vector deriving means 14.
[0069] The processing contents of the phrase vector deriving means 14 will now be described.
[0070] The phrase vector derivation means 14 inputs a sentence into a neural network trained by the first embodiment of the present invention, and for any token sequence that forms part of the sentence, derives a vector by integrating the output vectors of each token in the token sequence through an integration process as the vector of the phrase corresponding to the token sequence.
[0071] The neural network after processing by the parameter variable update means 13 and the parameter variables in the integration process have the property of deriving an appropriate phrase vector that also reflects the surrounding context information of the phrase in the corpus from the string of output vectors of each token that makes up a phrase. Therefore, the phrase vector derivation means 14 inputs an arbitrary sentence to the neural network, and the vector that is derived by integrating the output vectors of each token in an arbitrary token string that makes up part of the sentence in the integration process will be an appropriate vector for the phrase, which is the character string made up of the token string.
[0072] [Effects of the embodiment of the present invention] Conventional methods have had the problem of not being able to accurately reflect the surrounding context information of a phrase in a corpus. However, in this embodiment, the output vector of a phrase token that accurately reflects the surrounding context information of a phrase in a corpus is brought closer to the vector obtained by integrating the output vectors of each constituent token, so that the integrated vector generated from the output vectors of each constituent token accurately reflects the surrounding context information of the phrase in the corpus. Therefore, for any phrase, a phrase vector that accurately reflects the surrounding context information of the phrase in the corpus can be generated from only the sequence of output vectors of its constituent tokens.
[0073] Furthermore, conventional methods have had the problem of having little training data for approximating the vectors of phrases with the same meaning, but in this embodiment, in order to approximate the output vector of a phrase token and the integrated vector from the constituent token sequence for the large number of phrase types present in the corpus, the values of parameter variables correspond to the correspondence between the sequence of output vectors of constituent tokens and phrase vectors in various patterns. Therefore, for any phrase, the phrase vector generated using such parameter variables from the sequence of output vectors of its constituent tokens will be appropriate.
[0074] 2 is input to the phrase vector derivation means 14, and the output vectors of the basic tokens that make up the phrase are integrated in an integration process to derive a phrase vector that reflects the surrounding context information of the phrase in the corpus. The surrounding context information of "Cardiovascular Basic Research Forum 2022" and "Academic Lecture of the Japanese Society of Cardiology" is similar, while the surrounding context information of "Academic Lecture of the Japanese Society of Cardiology" and "Academic Lecture of the Japanese Society of Nutrition" is dissimilar, so the distance between the former pair of derived phrase vectors is closer than the distance between the latter pair.
[0075] When a phrase is ambiguous, the meaning of the phrase may change depending on the sentence in which it appears. When a phrase is part of a sentence, the sentence is input to the phrase vector derivation means 14, and the phrase vector generated from the phrase also reflects the surrounding context information of the phrase in the sentence. In this way, in this embodiment, not only when the entire sentence is a phrase, but also when the phrase is part of a sentence, it is possible to generate a phrase vector that accurately represents the meaning of the phrase in the sentence.
[0076] Although the method of limiting the differences in phrase tokens obtained by substitution in the token string conversion means 11 has been described due to restrictions on the amount of calculation required for processing by the pre-learning processing means 12, there are other ways to avoid such restrictions.
[0077] As mentioned above, a vocabulary set, which is a set of different basic tokens, may contain basic tokens that are made up of sequences of other basic tokens. For example, if a basic token is a word, the vocabulary set may include "Chiba Prefecture," which is made up of the sequence of basic tokens "Chiba" and "Prefecture." If a basic token is a subword, and each character is included in the vocabulary set, a subword of the basic token will consist of a sequence of basic tokens for each character that make up the subword.
[0078] When the token string conversion means 11 replaces a basic token string A, it replaces it only if the phrase token formed by concatenating basic tokens in A is included in the original vocabulary set, and when it replaces a basic token A' that is also a phrase token, it replaces it only with the basic token string that makes up A'. In this way, the set of types handled by the pre-training processing means 12 can be kept within the range of the original vocabulary set, and the problem of computational complexity is eliminated.
[0079] Furthermore, by adopting a configuration in which the processing of the token string conversion means 11 is not performed, the problem of the amount of calculation can be eliminated.
[0080] The parameter variable updating means 13 replaces a basic token as a phrase token G with a string F of shorter tokens (typically, basic tokens consisting of one character), thereby deriving an appropriate vector for the basic token G. This allows the phrase vector deriving means 14 to derive an appropriate vector for a character string (typically, an unknown word) equivalent to one basic token consisting of a string of shorter tokens (typically, basic tokens consisting of one character) from the token string.
[0081] Although the embodiments of the present invention have been described in detail above, the present invention is not limited to such specific embodiments, and various modifications and changes are possible within the scope of the gist of the present invention described in the claims.
[0082] 10 Phrase vector generating device 11 Token string conversion means 12 Pre-learning processing means 13 Parameter variable update means 14 Phrase vector deriving means 100 Drive device 101 Recording medium 102 Auxiliary storage device 103 Memory device 104 Processor 105 Interface device B Bus
Claims
1. A token sequence conversion means for inputting a set of sentences as a sequence of basic tokens, which are basic units of character strings, and for each sentence in the set, generating a new sentence by replacing a basic token sequence A consisting of multiple basic tokens that form part of the sentence with a phrase token formed by concatenating the basic tokens in A, or by replacing a basic token A', which is also a phrase token in the sentence, with a token sequence consisting of multiple tokens that make up A'; a pre-learning processing means for inputting a set of sentences as a sequence of basic tokens or phrase tokens, associating an embedding vector, each element of which is a parameter variable, with each type that is a difference between the basic tokens or phrase tokens in the set, treating each sentence in the set as a sequence of embedding vectors of a type corresponding to each token in the sentence, performing a learning process on the set using a neural network including BERT, and deriving values for parameter variables in the neural network that include each element of the embedding vector; The phrase vector generation device is characterized in that it processes the neural networks B and C, each of which has the same parameter variables after processing by the pre-learning processing means, and inputs a set of pairs of a sentence E and a sentence D in which a phrase token G in E has been replaced with a string F of tokens that make up G, and comprises a parameter variable updating means for updating the values of B and C and the parameter variables in the integration process so that a vector H obtained by integrating the output vectors of each token in F using an integration process including a neural network such as an RNN or pooling is the same vector as the output vector I of G.
2. The phrase vector generation device according to claim 1, further comprising a phrase vector derivation means for inputting a sentence into the neural network and deriving, for any token sequence that is part of the sentence, a vector obtained by integrating the output vectors of each token in the token sequence through the integration process as a phrase vector corresponding to the token sequence.
3. A pre-learning processing means for inputting a set of sentences as a sequence of basic tokens, which are basic units of character strings, and associating an embedding vector, each element of which is a parameter variable, with each type, which is the difference between the basic tokens in the set, and performing a learning process for a neural network including BERT on the set, with each sentence in the set being treated as a sequence of embedding vectors of a type corresponding to each basic token in the sentence, and deriving values of parameter variables in the neural network including each element of the embedding vector; The phrase vector generation device is characterized in that it processes the neural networks B and C, each of which has the same parameter variables after processing by the pre-learning processing means, and inputs a set of pairs of a sentence E and a sentence D in which a basic token G in E, which is also a phrase token formed by concatenating basic tokens in a basic token string consisting of a plurality of basic tokens, is replaced with a string F of basic tokens that make up G, and comprises a parameter variable updating means for updating the values of B and C and the parameter variables in the integration process so that a vector H obtained by integrating the output vectors of each basic token in F using an integration process including a neural network such as an RNN or pooling is the same vector as the output vector I of G.
4. The phrase vector generation device according to claim 3, further comprising a phrase vector derivation means for inputting a sentence into the neural network and deriving, for any basic token sequence that is part of the sentence, a vector obtained by integrating the output vectors of each basic token in the basic token sequence in the integration process, as a phrase vector corresponding to the basic token sequence.
5. A token sequence conversion procedure for inputting a set of sentences as a sequence of basic tokens, which are basic units of character strings, and for each sentence in the set, replacing a basic token sequence A consisting of multiple basic tokens that form part of the sentence with a phrase token formed by concatenating the basic tokens in A, or replacing a basic token A', which is also a phrase token in the sentence, with a token sequence consisting of the multiple tokens that make up A', thereby generating a new sentence; a pre-learning procedure for inputting a set of sentences as a sequence of basic tokens or phrase tokens, associating an embedding vector, each element of which is a parameter variable, with each type that is a difference between the basic tokens or phrase tokens in the set, treating each sentence in the set as a sequence of embedding vectors of a type corresponding to each token in the sentence, performing a learning process on the set with a neural network including BERT, and deriving values of parameter variables in the neural network that include each element of the embedding vector; A phrase vector generation method characterized in that the neural networks B and C, which have the same parameter variables after the pre-learning processing procedure, are used as processing targets, a set of pairs of a sentence E and a sentence D in which a phrase token G in E has been replaced with a string of tokens F that make up G are input, and for each pair D and E in the set, D is input to B and E is input to C, and a parameter variable update procedure is executed by a computer to update B and C and the values of the parameter variables in the integration process so that a vector H obtained by integrating the output vectors of each token in F using an integration process including a neural network such as an RNN or pooling is the same vector as the output vector I of G.
6. A pre-training process step of inputting a set of sentences as a sequence of basic tokens, which are the basic units of a string, and associating an embedding vector, each element of which is a parameter variable, with each type of different basic token in the set, treating each sentence in the set as a sequence of embedding vectors of a type corresponding to each basic token in the sentence, performing a training process on the set using a neural network including BERT, and deriving values for parameter variables in the neural network including each element of the embedding vector; A phrase vector generation method characterized in that the neural networks B and C, which have the same parameter variables after the pre-learning processing procedure, are processed as the processing targets, and a set of pairs of a sentence E and a sentence D in which a basic token G in E, which is also a phrase token formed by concatenating basic tokens in a basic token string consisting of a plurality of basic tokens, is replaced with a string F of basic tokens that make up G, and for each pair D and E in the set, D is input to B and E is input to C, and a parameter variable update procedure is executed by a computer to update B and C and the values of the parameter variables in the integration process so that a vector H obtained by integrating the output vectors of each basic token in F using an integration process including a neural network such as an RNN or pooling is the same vector as the output vector I of G.
7. A program for causing a computer to function as the phrase vector generating device according to any one of claims 1 to 4.
Citation Information
Patent Citations
Word vector representation method and device
CN113536800A
