Text input method and related device
Through the end-to-end neural network structure and the fusion candidate word vector library, unified modeling and collaborative decoding of general input and name input is realized, solving the problem of inefficient name input in the existing technology, and improving input efficiency and decoding effect.
Patent Information
- Application Number
- CN202111666573.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-12-31
AI Technical Summary
The existing input method is inefficient when entering a person's name. The decoding results rely on the general engine and context text content, and the user needs to manually switch the engine, resulting in the unintelligent input experience. The decoding results rely on the richness of surnames and name resources, affecting the input efficiency.
Using an end-to-end neural network structure, the unified modeling and collaborative decoding of common input and person-name input is realized by obtaining the semantic features of strings and fusion candidate word vector library, and the general semantic features of candidate words are fused and decoded words are generated. , using probability value weighted fusion features to improve decoding accuracy.
It realizes smarter decoding choices, displays more reasonable structures, improves the efficiency of name input, avoids additional operation costs for users, and ensures the decoding effect. At the same time, it uniformly models the decoding of general input and name input.
Smart Images

Figure CN114356116B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a text input method and related devices. Background Art
[0002] As electronic devices become more and more popular in people's daily lives and work, input methods, as the interactive portal between people and electronic devices, play an increasingly important role, greatly facilitating people's input process. However, as a common scenario in daily input, name input is quite different from general input. Except for a few commonly used names, it is difficult to directly obtain the desired name decoding candidate results, which in turn causes great inconvenience to name input.
[0003] At present, the input of names in current input methods is mainly based on general engine decoding. When the corresponding name is in the dictionary, the corresponding name can be decoded; if it is not in the dictionary, the user can only enter the name word by word by filtering single words. There are mainly the following defects: (1) Directly using the general engine decoding, the number of decoded names is too small. Except for a few high-frequency names in the dictionary, almost all of them must be composed of characters selected by the user, which seriously affects the input efficiency; (2) The general decoding engine and the name decoding engine are constructed separately, which requires two decodings, which is inefficient and requires the user to switch manually, and the input experience is not smart enough; (3) The judgment of the probability of name input depends on the name decoding ability of the general decoding engine or the context text content; (4) Directly using common surnames, given names and other resources for matching decoding is insufficient, and the decoding results are seriously dependent on the richness of surnames, given names and other resources, and on the effects of pre-decoding steps such as syllable segmentation. Therefore, it is necessary to propose a new method to solve the above problems. Summary of the invention
[0004] The main technical problem solved by the present application is to provide a text input method and related devices, which can realize unified modeling and collaborative decoding of general input and name input.
[0005] In order to solve the above technical problems, a technical solution adopted in the present application is: to provide a text input method, including: obtaining a character string and a fused candidate word vector library; wherein the character string includes a key sequence, a language sequence and a stroke sequence; inputting the character string into a decoding model to obtain a decoded word of the character string; wherein the decoding model is used to obtain the semantic features of the character string, and utilize the semantic features of the character string and the fused candidate word vector library to obtain the decoded word of the character string; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are the fused semantic features of the candidate characters, the fused semantic features of the candidate characters are the weighted fusion of the general semantic features of the candidate characters and the semantic features of the candidate characters' names, and the decoded word is a combination of the candidate characters of each character in the character string.
[0006] Among them, the decoding model is also used to obtain the probability value of the character string being a name character string, and use the probability value as the weight coefficient of the candidate character's name semantic feature to weightedly fuse the candidate character's general semantic features and the candidate character's name semantic features, and the sum of the weight coefficient of the candidate character's general semantic features and the weight coefficient of the candidate character's name semantic features is 1.
[0007] Among them, the decoding model includes an end-to-end neural network structure, the end-to-end neural network structure includes a prediction module, the prediction module includes an encoder and a classification network connected to the encoder, the encoder is used to encode the character string to obtain the semantic features of the character string, and the classification network is used to obtain the probability value of the character string being a human name character string.
[0008] Among them, the end-to-end neural network structure also includes a decoding module; the decoding module is used to obtain candidate semantic features matching the current character from the fused candidate word vector library character by character, and there are multiple candidate semantic features matching the current character; the decoding information of the previous character is integrated to calculate the probability of each candidate semantic feature matching the current character.
[0009] Among them, the network structure of the encoder is BiLSTM or a compressed pre-trained language representation training model BERT; the network structure of the classification network is a classification network including a fully connected layer; and the network structure of the decoding module is a long short-term memory network LSTM or a transformer model.
[0010] Among them, the text input method also includes: obtaining sample corpus, the sample corpus is a pinyin string, the pinyin string carries a text label and a probability label, the text label is used to identify the text corresponding to the pinyin string, and the probability label is used to identify whether the text corresponding to the pinyin string is a general text or a name text; inputting the sample corpus into an initial end-to-end neural network, calculating the loss of the end-to-end neural network, and the loss is a weighted fusion of the probability loss and the text loss; based on the loss, iteratively updating the parameters of the end-to-end neural network until the training cutoff condition is met.
[0011] Among them, the text input method also includes: constructing a basic candidate word vector library, the basic candidate word vector library includes a general word library and a personal noun library, the general word library includes multiple general semantic features, and the personal noun library includes multiple personal name semantic features; the acquisition of the fused candidate word vector library includes: acquiring the general semantic features and personal name semantic features of the candidate words of each character in the character string from the basic candidate word vector library; weighted fusion of the general semantic features of the candidate words and the personal name semantic features of the candidate words to obtain the fused semantic features of the candidate words to form the fused candidate word vector library.
[0012] Among them, the construction of the basic candidate word vector library includes: obtaining a general text corpus and a personal name text corpus; inputting the general text corpus into a first language model to obtain the general semantic features of each character in the general text corpus, and inputting the personal name text corpus into a second language model to obtain the personal name semantic features of each character in the personal name text corpus, so as to form the basic candidate word vector library.
[0013] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a text input device, including: an acquisition module, used to acquire a character string and a fused candidate word vector library; a decoding word module, connected to the acquisition module, used to input the character string into a decoding model to obtain a decoded word of the character string; wherein the decoding model is used to acquire the semantic features of the character string, and utilize the semantic features of the character string and the fused candidate word vector library to obtain the decoded word of the character string; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are the fused semantic features of the candidate characters, the fused semantic features of the candidate characters are the weighted fusion of the general semantic features of the candidate characters and the semantic features of the candidate characters' names, and the decoding word is a combination of the candidate characters of each character in the character string.
[0014] To solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, comprising a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the text input method mentioned in any of the above embodiments.
[0015] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a storage device storing program instructions that can be executed by a processor, wherein the program instructions are used to implement the text input method mentioned in any of the above embodiments.
[0016] Different from the prior art, the beneficial effect of the present application is as follows: the text input method provided by the present application includes: first obtaining a character string and a fused candidate word vector library, then inputting the character string into a decoding model to obtain a decoded word of the character string; wherein the decoding model is used to obtain the semantic features of the character string, and obtain the decoded word of the character string by using the semantic features of the character string and the fused candidate word vector library; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are the fused semantic features of the candidate characters, the fused semantic features of the candidate characters are the weighted fusion of the general semantic features of the candidate characters and the semantic features of the names of the candidate characters, and the decoded word is a combination of the candidate characters of the characters in the character string. Through this design method, based on the integrated modeling of neural networks, unified modeling and collaborative decoding of general input and name input are realized, so that one model completes the decoding of general input and the decoding of name input, and more reasonable structures are displayed more intelligently, and while ensuring the decoding effect, more operation costs are avoided for users, thereby improving the decoding effect of names and improving the efficiency of name input. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0018] Figure 1 It is a flowchart of an implementation method of the text input method of the present application;
[0019] Figure 2 yes Figure 1 A schematic flow chart of an implementation method corresponding to step S1 in FIG.
[0020] Figure 3 It is a flowchart of an implementation method of constructing a basic candidate word vector library;
[0021] Figure 4 This is a schematic diagram of the structure of the deep neural network name decoding model;
[0022] Figure 5 It is a schematic diagram of a framework of an implementation method of a text input device of the present application;
[0023] Figure 6 It is a schematic diagram of a framework of an implementation mode of an electronic device of the present application;
[0024] Figure 7 It is a structural diagram of an implementation method of a storage device of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] In the current input method, the input of names is mainly based on general engine decoding. When the corresponding name is in the dictionary, the corresponding name can be decoded; if it is not in the dictionary, the user can only enter the name word by word through single-word filtering. For the problem of name input, some people have proposed the following solutions: by comparing the intersection and sorting relationship between name candidates and general term candidates, the probability of name input can be inferred, and then the name candidates can be displayed; by displaying the surname and the first name separately, the possible combinatorial explosion problem in the display of names can be solved; by triggering the name mode through some preset conditions (the number of syllables and the inclusion of the name in the general candidates), adding resources such as surnames, common names, and common full names, and displaying the matched names in a separate name panel. For name recognition, some people have proposed the following solutions: using the ngram model to recognize the name of the text sequence after word segmentation; using a method similar to named entity recognition to train the name annotation model and recognize the name in the text. In addition, some people have proposed to predict whether the following text is a name based on the content of the previous text that has been entered, and recommend names based on the content of the previous text and the social relationship of the user account. The above solutions usually have the following defects: (1) Directly using the general engine for decoding, the number of decoded names is too small. Except for a few high-frequency names in the dictionary, almost all of them require users to select characters by themselves, which seriously affects input efficiency; (2) Building a general decoding engine and a name decoding engine separately requires two decodings, which is inefficient and requires users to manually switch, and the input experience is not smart enough; (3) Judging the probability of name input depends on the name decoding ability of the general decoding engine or the context text content; (4) Directly using common surnames, given names and other resources for matching and decoding is insufficient, and the decoding results are heavily dependent on the richness of surnames, given names and other resources, and on the effects of pre-decoding steps such as syllable segmentation.
[0027] The text input method provided by this application is introduced in detail below.
[0028] See also Figure 1 , Figure 1 1 is a flowchart of an implementation method of the text input method of the present application. The above text input method specifically includes:
[0029] S1: Get the string and fusion candidate word vector library.
[0030] Specifically, the string includes a key sequence, a language sequence, and a stroke sequence. The input content of the user is a string, which can be a pinyin string or the like, and is not limited herein. Additionally, the string can include one or more characters. For example, the string can be a single character "wang", or the string "wangjunkai", including multiple characters such as "wang", "jun", and "kai", which is not limited herein. In this embodiment, the fusion candidate word vector library includes multiple candidate semantic features. The candidate semantic feature is the fused semantic feature of the candidate character, and the fused semantic feature of the candidate character is the weighted fusion of the general semantic feature of the candidate character and the personal name semantic feature of the candidate character.
[0031] Please refer to Figure 2 , Figure 2 is Figure 1 a schematic flowchart of an implementation manner corresponding to step S1 in
[0032] S10: Obtain the general semantic feature and the personal name semantic feature of the candidate character of each character in the string from the basic candidate word vector library.
[0033] Specifically, if the string is "wangjun kai", then obtain the general semantic feature V g and the personal name semantic feature V r of the candidate character of each character "wang", "jun", and "kai" from the basic candidate word vector library. For example, the candidate characters of "wang" may be "王", "汪", "旺", etc., the candidate characters of "jun" may be "俊", "军", "君", etc., and the candidate characters of "kai" may be "凯", "恺", "楷", etc. Obtain the general semantic feature V g and the personal name semantic feature V r of these candidate characters from the basic candidate word vector library.
[0034] The key to the poor decoding effect of the current general engine for names is that there are large differences between the characteristics of names and general texts, and there is a problem of inconsistent semantic space. For example, in general texts, the probability of "Ting, Dan" and the like appearing is lower than that of "Ting, but", but the probability of appearing in names is significantly higher; common characters such as "Wang, Wang" rarely appear in names, and uncommon characters such as "Zi, Xin" are frequently used in names; "Wen" is usually used with "Xue, An, Jian" and the like in general texts, and in names, it often appears with "Jie, Tao, Bin" and the like. Therefore, for general texts and names, different semantic representations are trained for each character, and different representations are selected according to the situation to achieve more intelligent decoding. In this embodiment, the model can be first trained based on the language model task using general text corpus and name text corpus to obtain general word vector representation and person noun vector representation. In this regard, a simple word2vec, LSTM model or a more complex BERT model can be used to train a character-level language model, or a general word vector representation can be obtained based on an existing pre-trained language model, and then fine-tuned using a person name text material to obtain a person noun vector representation. This application does not make specific limitations here.
[0035] Preferably, in this embodiment, before step S1, the method further includes: constructing a basic candidate word vector library. Specifically, the basic candidate word vector library includes a general word library and a person noun library. The general word library includes a plurality of general semantic features V g , the person name database includes multiple person name semantic features V r .
[0036] Please participate Figure 3 , Figure 3 1 is a flow chart of an implementation method of constructing a basic candidate word vector library. Specifically, the steps of constructing a basic candidate word vector library include:
[0037] S20: Obtain general text corpus and name text corpus.
[0038] S21: Input the general text corpus into the first language model to obtain the general semantic features of each character in the general text corpus, and input the name text corpus into the second language model to obtain the name semantic features of each character in the name text corpus to form a basic candidate word vector library.
[0039] Specifically, the first language model and the second language model are network structures similar to semantic recognition, and the specific structure is not limited here. The universal text corpus is input into the first language model to obtain the universal semantic features V of each word in the universal text corpus g , to form a general vocabulary; input the name text corpus into the second language model to obtain the name semantic features V of each character in the name text corpus r, to form a personal name dictionary. Finally, the general dictionary and the personal name dictionary are combined to form a basic candidate word vector library. For example, for the character "Wang", there will be a semantic vector of "Wang" in the general dictionary, that is, the general semantic feature V g , and there will also be a semantic vector of "Wang" in the personal name dictionary, that is, the personal name semantic feature V r .
[0040] S11: Weightedly fuse the general semantic feature of the candidate character and the personal name semantic feature of the candidate character to obtain the fused semantic feature of the candidate character, and form a fused candidate word vector library.
[0041] Specifically, in this embodiment, for each candidate character, the general semantic feature V of the candidate character obtained in the above step S10 g and the personal name semantic feature V r are weightedly fused, and the fused semantic feature V of the candidate character is calculated. Finally, the fused semantic features V of all candidate characters form a fused candidate word vector library.
[0042] For example, the input string will have corresponding Chinese characters. For example, "wangjunkai" has three characters: "wang", "jun", "kai", and they will respectively correspond to multiple candidate characters. For example, "wang" can be "王", "汪", "旺", etc.; that is, all the characters with the pinyin "wang" need to be found in the basic candidate word vector library. Since the basic candidate word vector library includes the general dictionary and the personal name dictionary, two semantic vectors of "Wang" are found from these two libraries respectively, and then they are fused so that "Wang" corresponds to a fused semantic feature V. In the fused candidate word vector library, only the fused semantic features V of the candidate characters corresponding to the pinyin "wang", "jun", "kai" are included, and each candidate character corresponds to a fused semantic feature V. Therefore, this fused candidate word vector library can be used as the vector library for decoding the string "wangjunkai", and the fusion of this vector library is not done by a neural network, but by an independent database, and the neural network can call and obtain the data inside. Optionally, in this embodiment, the fusion module for executing step S11 can be a separate module and can be connected to the module for executing step S10.
[0043] S2: Input the string into the decoding model to obtain the decoded word of the string.
[0044] Specifically, in this embodiment, the above decoding model is used to obtain the semantic feature H of the string, and use the semantic feature H of the string and the fused candidate word vector library to obtain the decoded word of the string. In addition, in this embodiment, the decoded word is a combination of the candidate characters of each character in the string.
[0045] In addition, in this embodiment, the decoding model is also used to obtain the probability value P that the character string is a human name character string, and the probability value P is used as the human name semantic feature V of the candidate character. r The weight coefficient is used to weight the universal semantic features V of the candidate words. g Semantic features of names with candidate characters V r In this embodiment, the general semantic feature V of the candidate word g The weight coefficient of the candidate word and its semantic feature V r The sum of the weight coefficients is 1, so the probability value of the string being a universal string is 1-P.
[0046] In this example, see Figure 4 , Figure 4 It is a structural diagram of a deep neural network name decoding model. The decoding model includes an end-to-end neural network structure (not shown), the end-to-end neural network structure includes a prediction module 10, the prediction module 10 includes an encoder 100 and a classification network 102 connected to the encoder 100, the encoder 100 is used to encode the string to obtain the semantic feature H of the string, and the classification network 102 is used to obtain the probability value P of the string being a name string. In general, when decoding using the decoding model, a string is input, and the encoder 100 is used to encode the overall semantic feature H of the string, and then the probability value P of the string belonging to the name string is calculated. The probability value P is calculated using the classification network 102, and the classification network 102 is a probability distribution network structure, which is used to output the probability value P of the string belonging to the name string.
[0047] In addition, in the present embodiment, the end-to-end neural network structure further includes a decoding module 12, and the decoding module 12 can execute the process through a decoder. Specifically, the decoding module 12 is used to obtain candidate semantic features that match the current character from the fused candidate word vector library character by character, wherein there are multiple candidate semantic features that match the current character. In addition, the decoding information of the previous character is fused to calculate the probability of each candidate semantic feature matching the current character. Specifically, when decoding the current character string, the candidate semantic feature H corresponding to the current character string output by the encoder 100 is input into the decoding module 12, and the decoding module 12 simultaneously obtains the candidate semantic feature H corresponding to the current character string from the fused candidate word vector library, and the obtained candidate semantic feature H is multiple. For a character string, a fused candidate word vector library is constructed once, and then this fused candidate word vector library can be directly called when decoding the characters later; when a new character string comes in, a fused candidate word vector library corresponding to the new character string is constructed again. When decoding, multiple characters in the current character string are decoded one by one, and when decoding each character, the information of the previous character will be referred to. As Figure 4As shown in the figure, when decoding the first character "wang", a null value is entered because there is no character before it. <s>Please continue reading Figure 4 , starting from the leftmost branch, when decoding the first character "wang", the semantic feature H of the string is obtained through the encoder 100, and the vector data V of "wang" is obtained 0 , where the above vector data V 0 Can be multiple, get the data of the previous character, the data of the previous character is <s>(i.e., empty value), combined with semantic feature H and vector data V 0 , <s>To calculate the probability U of each candidate semantic feature matching the current character, further calculate the probability value P of the current character belonging to a name character, and output each candidate word and its probability value. Specifically, the candidate words can be sorted by the size of the probability value, and then the second character, the third character, and finally the last character can be decoded, such as Figure 4 As shown, the rightmost branch is considered to be the end. In actual application, the decoder is actually a branch, and the structure includes all the structures from bottom to top in the figure; Figure 4 The branches from left to right in the code are only used to indicate the step-by-step character decoding. In order to explain more clearly that there is a relationship between the characters, the previous character information should be referred to. Figure 4 Four steps are drawn in the figure, representing the four moments of this branch, rather than including four independent branches to solve different characters respectively.
[0048] The structure of the decoding model is as follows Figure 4 As shown, the overall steps are as follows: perform name semantic feature V on the input content r Extract and predict the probability of the name; select the general semantic feature V in proportion according to the predicted probability of the name g Semantic features of names with candidate characters V r Fusion is performed; finally, the semantic feature H is combined with the fused semantic feature V for decoding.
[0049] Specifically, Figure 4 As shown, the user input content example is the pinyin string "wangjunkai", the pinyin string is first converted into a corresponding feature vector E, and the semantic feature H of the pinyin string is obtained after passing through the encoder 100, that is:
[0050] H=Encoder(E)(1)
[0051] The specific structure of the encoder 100 is not specifically limited here, and BiLSTM or a compressed pre-trained language representation training model BERT can be used, wherein BiLSTM is composed of a forward long short-term memory network LSTM and a backward long short-term memory network LSTM. Of course, in other embodiments, the network structure of the encoder 100 can also be other network models, which is not limited in this application. A classification network 102 is connected after the encoder 100 for classification to obtain the probability value P of decoding in the name space, that is, the semantic feature V of the name. r The probability value of is P, where the network structure of the classification network 102 is a classification network including a fully connected layer. g The weight coefficient of the name and the semantic feature V r The sum of the weight coefficients is 1, then the corresponding probability value of decoding in the universal space is 1-P, that is, the universal semantic feature V g The probability value is 1-P. Specifically, the semantic feature V r The calculation formula of the probability value P is as follows:
[0052] P=σ(W*H+b)(2)
[0053] Among them, is the sigmoid activation function, is the learnable weight, and is the learnable bias.
[0054] According to the above semantic features of names V r The probability values P are respectively derived from the general semantic features V g and semantic features of names V r The character semantic representation vector is selected from , thereby obtaining the fused semantic feature V. The specific calculation method is shown in formula (3):
[0055] V=(1-P)*V g +P*V r (3)
[0056] Among them, V represents the fusion semantic feature, and P represents the semantic feature V of the name r The probability value represents the general semantic feature, and represents the semantic feature of the name. In the extreme case, when P is 1, that is, based on the input pinyin string, it can be directly determined that the user wants to enter a name, then the semantic feature of the name is directly used to decode in the semantic space of the name; conversely, when P is 0, it is completely decoded in the general semantic space. In this way, the coordinated decoding and unified modeling of general input and name input can be achieved, so that one model can complete the decoding of general input and name input, avoiding the problem of poor decoding effect of a general decoding engine for names, and by learning the semantic distribution of characters in general text and name text respectively, while decoding general text and name text in an integrated manner, the respective characteristics of general text and name text can be accurately modeled.
[0057] Then, the semantic feature H and the fused semantic feature V obtained in the above steps are used to gradually decode the final text, that is, the decoded word of the above string, through the decoding module 12. The specific decoding steps are: first, the current step information is combined with different input information with emphasis according to the current step information to generate the current step information representation. The specific calculation method is shown in formula (4):
[0058] U i =Decoder(attention(H,V i ),V i )(4)
[0059] where, represents the fused semantic feature corresponding to the string of the i-th input; represents the calculation formula determined according to the network structures of different decoding modules, which is not specifically limited here. In addition, the network structure of the decoding module 12 can be a long short-term memory network (LSTM) or a Transformer model. Of course, in other embodiments, the network structure of the decoding module 12 can also be other network models, which are not limited in this application. In this embodiment, represents the attention mechanism, which can focus on using different input information according to different decoding steps. For example, when decoding "jun", the model can calculate according to the attention mechanism and place more attention on the input "jun". Correspondingly, the obtained can be "jun", "jun1", "jun2" (assuming "君" and "军" are represented as "jun1" and "jun2" in a certain encoding) etc.
[0060] Finally, the probabilities of each character at the current step are calculated from the current step information representation through the softmax function, so as to generate the probabilities of each character in the final decoding prediction result. The specific calculation is shown in formula (5):
[0061]
[0062] where, represents the character prediction result at position i, and X represents the content of the input string. In this way, the input probability of the person name can be directly predicted according to the user's input content, avoiding the dependence on other information and being not restricted by the input scenario and other decoding results; at the same time, the general word vector and the person name word vector are fused according to the input probability of the person name, so as to obtain the fused character semantic representation vector, realizing the automatic selection and fusion of the decoding states of the two, and avoiding the problems of low decoding efficiency of the two engines and manual switching.
[0063] The training corpus is input into the network to optimize the objective function and adjust the model parameters. The prediction result is compared with the real label gap through the objective function, and the network model parameters are iteratively updated by the optimization algorithm, such as the stochastic gradient descent algorithm, which is not specifically limited here. Therefore, in this embodiment, the method also includes: A. Obtaining sample corpus. Specifically, the sample corpus is a pinyin string, and the pinyin string carries a text label and a probability label. In this embodiment, the text label is used to identify the text corresponding to the pinyin string, and the probability label is used to identify whether the text corresponding to the pinyin string is a general text or a name text. Specifically, the general text corpus and the name text corpus are taken respectively and annotated, the pinyin string is obtained and the pinyin string is used as input, and the corresponding general text or name text is a decoded output probability label. In this embodiment, the probability label of the name corpus can be marked with "1", and the probability label of the general corpus can be marked with "0". Of course, in other embodiments, the marking method can be other, which is not limited here. B. Input the sample corpus into the initial end-to-end neural network and calculate the loss of the end-to-end neural network. Specifically, in this embodiment, the loss is a weighted fusion of the probability loss and the text loss. C. Based on the loss, iteratively update the parameters of the end-to-end neural network until the training cutoff condition is met. Specifically, in this embodiment, the training includes two optimization goals, which are the prediction of the probability of the intermediate name input and the decoding of the final decoded text. The final joint optimization goal is:
[0064] L=αL r +(1-α)L d (6)
[0065] Among them, represents the proportion of the intermediate name input probability prediction task. Iterate the training to the specified conditions, end the optimization to obtain the final general input and name input collaborative decoding model, which is used for subsequent decoding tasks, that is, use the sample corpus to iteratively train and optimize according to the objective function to generate the final decoding model. Optionally, the above-mentioned steps of training the model can be performed before step S1 or before step S2, and the present application is not limited here. This overall neural network training-based method is more comprehensive in modeling than the vocabulary statistical scheme, and can decode more reasonable candidate characters; at the same time, the different characteristics of general text and names.
[0066] After obtaining the trained decoding model, the trained decoding model is used for decoding, and more decoding in the name space or in the general space is automatically selected according to the content of the input string to obtain the name or general text display sorting, thereby realizing the integrated decoding and collaborative sorting of name input and general input. The order of the steps to be implemented is: a. First, the input information is extracted through the encoder, and the probability of name input is judged; then the general word vector and the person noun vector are selected in proportion to fuse, and the character fusion semantic vector representation is obtained, and the tendency of subsequent decoding to the general semantic space and the name semantic space is determined; finally, the pinyin semantic features extracted from the input content are combined with the character semantic vector representation, and the candidates and corresponding probability scores are gradually decoded. In the decoding process, as many candidate results and corresponding scores as possible are retained through beam search, and in order to improve the decoding efficiency, obviously impossible paths are cut off at each step. b. By setting a score filtering threshold, the candidate results with poor scores in the decoding results are filtered, and only the decoding candidate results with higher quality are displayed. At the same time, according to the different characteristics of general texts and names, names have more possible combinations, and the constraints on decoding scores are lower. The threshold can be adjusted according to the prediction probability of the name, so that more possible results can be displayed when decoding the name. Of course, in other embodiments, this step may not be set, and this application is not limited here.
[0067] Through this design, one engine can complete the decoding of general input and name input at the same time, ensuring the decoding effect while avoiding introducing more operating costs to users. In addition, by learning the semantic distribution of characters in general text and names respectively, one engine can achieve the effect of two engines decoding separately. The probability of inputting a name is directly calculated according to the user input content to avoid dependence on other information, and the automatic selection of the decoding state of the two is achieved based on the probability fusion features. Based on the integrated modeling of neural networks, unified modeling and collaborative decoding of general input and name input are achieved, so that one model can complete the decoding of general input and name input, and more reasonable structures are displayed more intelligently, thereby improving the name decoding effect and improving the efficiency of name input.
[0068] See also Figure 5 , Figure 5 It is a schematic diagram of the framework of an implementation method of the text input device of the present application.
[0069] Specifically, the text input device comprises:
[0070] The acquisition module 20 is used to acquire a character string and a fusion candidate word vector library; wherein the character string includes a key sequence, a language sequence and a stroke sequence.
[0071] The decoding word module 22 is connected to the acquisition module 20 and is used to input the character string into the decoding model to obtain the decoding word of the character string. The decoding model is used to obtain the semantic features of the character string, and obtain the decoding word of the character string by using the semantic features of the character string and the fused candidate word vector library; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are the fused semantic features of the candidate characters, and the fused semantic features of the candidate characters are the weighted fusion of the general semantic features of the candidate characters and the semantic features of the names of the candidate characters. The decoding word is a combination of the candidate characters of each character in the character string.
[0072] In an application scenario, the decoding model is also used to obtain the probability value of a character string being a name character string, and the probability value is used as the weight coefficient of the candidate character's name semantic feature to weightedly fuse the candidate character's general semantic features and the candidate character's name semantic features. The sum of the weight coefficient of the candidate character's general semantic features and the weight coefficient of the candidate character's name semantic features is 1.
[0073] Specifically, in this embodiment, the decoding model includes an end-to-end neural network structure, which includes a prediction module. The prediction module includes an encoder and a classification network connected to the encoder. The encoder is used to encode the character string to obtain the semantic features of the character string, and the classification network is used to obtain the probability value of the character string being a human name character string.
[0074] Furthermore, the end-to-end neural network structure also includes a decoding module; obtaining candidate semantic features matching the current character from the fused candidate word vector library character by character, and there are multiple candidate semantic features matching the current character; fusing the decoding information of the previous character to calculate the probability of each candidate semantic feature matching the current character.
[0075] Optionally, the network structure of the encoder is BiLSTM or a compressed pre-trained language representation model BERT; the network structure of the classification network is a classification network including a fully connected layer; and the network structure of the decoding module is a long short-term memory network LSTM or a transformer model.
[0076] Specifically, in the present embodiment, the text input device further includes a training module, whose two ends are respectively connected to the acquisition module 20 and the decoding word module 22. Specifically, the training module includes a first sub-acquisition module, a loss module and an iteration module which are sequentially connected to each other. The first sub-acquisition module is used to acquire sample corpus, the sample corpus is a pinyin string, the pinyin string carries a text label and a probability label, the text label is used to identify the text corresponding to the pinyin string, the probability label is used to identify whether the text corresponding to the pinyin string is a general text or a name text, the loss module is used to input the sample corpus into the initial end-to-end neural network, calculate the loss of the end-to-end neural network, the loss is a weighted fusion of the probability loss and the text loss, and the iteration module is used to iteratively update the parameters of the end-to-end neural network based on the loss until the training cutoff condition is met.
[0077] Specifically, in the present embodiment, the text input device further includes a construction module, which is connected to the acquisition module 20 or the decoding word module 22, and is used to construct a basic candidate word vector library, the basic candidate word vector library includes a general word library and a person noun library, the general word library includes a plurality of general semantic features, and the person noun library includes a plurality of person name semantic features. In addition, in the present embodiment, the decoding word module 22 further includes a second sub-acquisition module, the second sub-acquisition module includes a first acquisition module and a weighted fusion module connected to each other, the first acquisition module is used to acquire the general semantic features and person name semantic features of the candidate words of each character in the character string from the basic candidate word vector library, the weighted fusion module is used to weight the general semantic features of the candidate words and the person name semantic features of the candidate words, obtain the fused semantic features of the candidate words, and form a fused candidate word vector library.
[0078] Specifically, in this embodiment, the above-mentioned construction module includes a second acquisition module and a formation module that are interconnected. The second acquisition module is used to acquire a general text corpus and a name text corpus. The formation module is used to input the general text corpus into the first language model to obtain the general semantic features of each character in the general text corpus, and input the name text corpus into the second language model to obtain the name semantic features of each character in the name text corpus to form a basic candidate word vector library.
[0079] See also Figure 6 , Figure 6 Schematic diagram of the framework of an embodiment of an electronic device of the present application. The electronic device includes a memory 200 and a processor 202 coupled to each other. Specifically, in the present embodiment, program instructions are stored in the memory 200, and the processor 202 is used to execute the program instructions to implement the text input method mentioned in any of the above embodiments. Specifically, the electronic device includes but is not limited to: a desktop computer, a laptop computer, a tablet computer, a server, etc., which are not limited here. In addition, the processor 202 can also be called a CPU (Central Processing Unit). The processor 202 may be an integrated circuit chip with signal processing capabilities. The processor 202 may also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. In addition, the processor 202 may be implemented by multiple integrated circuit chips.
[0080] See also Figure 7 , Figure 7 It is a structural diagram of an implementation of a storage device of the present application. The storage device 30 stores program instructions 300 that can be executed by a processor. The program instructions 300 are used to implement the text input method mentioned in any of the above embodiments.
[0081] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0082] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0083] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0084] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0085] In summary, different from the prior art, the text input method provided by the present application includes: first obtaining a character string and a fused candidate word vector library, then inputting the character string into a decoding model to obtain a decoded word of the character string; wherein the decoding model is used to obtain the semantic features of the character string, and the decoded word of the character string is obtained by using the semantic features of the character string and the fused candidate word vector library; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are the fused semantic features of the candidate characters, the fused semantic features of the candidate characters are the weighted fusion of the general semantic features of the candidate characters and the semantic features of the names of the candidate characters, and the decoded word is a combination of the candidate characters of each character in the character string. Through this design method, based on the integrated modeling of neural networks, unified modeling and collaborative decoding of general input and name input are realized, so that one model completes the decoding of general input and the decoding of name input, and more intelligent choices are displayed. More reasonable structures, and while ensuring the decoding effect, more operating costs are avoided for users, thereby improving the decoding effect of names and improving the efficiency of name input.
[0086] The above description is only an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.< / s> < / s> < / s>
Claims
1. A text input method, characterized in that: include: Obtain a character string and a fusion candidate word vector library; wherein the character string includes a key sequence, a language sequence and a stroke sequence; Input the character string into a decoding model to obtain a decoded word of the character string; The decoding model is used to obtain the semantic features of the string, and obtain the decoded word of the string by using the semantic features of the string and the fused candidate word vector library; the fused candidate word vector library includes multiple candidate semantic features, the candidate semantic features are fused semantic features of candidate characters, the fused semantic features of candidate characters are weighted fusion of the general semantic features of candidate characters and the semantic features of the names of candidate characters, and the decoded word is a combination of candidate characters of each character in the string; the text input method also includes: Constructing a basic candidate word vector library, wherein the basic candidate word vector library includes a general word library and a person noun library, wherein the general word library includes a plurality of general semantic features, and the person noun library includes a plurality of person name semantic features; Obtaining the fused candidate word vector library includes: obtaining the general semantic features and name semantic features of the candidate words of each character in the character string from the basic candidate word vector library; weightedly fusing the general semantic features of the candidate words and the name semantic features of the candidate words to obtain the fused semantic features of the candidate words to form the fused candidate word vector library.
2. The text input method according to claim 1, characterized in that: The decoding model is also used to obtain a probability value that the character string is a name character string, and use the probability value as a weight coefficient of the candidate character's name semantic feature to weightedly fuse the general semantic feature of the candidate character with the candidate character's name semantic feature, wherein the sum of the weight coefficient of the general semantic feature of the candidate character and the weight coefficient of the candidate character's name semantic feature is 1.
3. The text input method according to claim 2, characterized in that: The decoding model includes an end-to-end neural network structure, the end-to-end neural network structure includes a prediction module, the prediction module includes an encoder and a classification network connected to the encoder, the encoder is used to encode the character string to obtain the semantic features of the character string, and the classification network is used to obtain the probability value of the character string being a name character string.
4. The text input method according to claim 3, characterized in that: The end-to-end neural network structure also includes a decoding module; The decoding module is used to obtain candidate semantic features matching the current character from the fused candidate word vector library character by character, and there are multiple candidate semantic features matching the current character; The decoding information of the previous character is integrated to calculate the probability of matching each candidate semantic feature of the current character.
5. The text input method according to claim 4, characterized in that: The network structure of the encoder is BiLSTM or a compressed pre-trained language representation model BERT; The network structure of the classification network is a classification network including a fully connected layer; The network structure of the decoding module is a long short-term memory network LSTM or a transformer model.
6. The text input method according to claim 3, characterized in that: The text input method also includes: Acquire a sample corpus, wherein the sample corpus is a pinyin string, and the pinyin string carries a text label and a probability label, wherein the text label is used to identify the text corresponding to the pinyin string, and the probability label is used to identify whether the text corresponding to the pinyin string is a general text or a name text; Inputting the sample corpus into an initial end-to-end neural network, and calculating the loss of the end-to-end neural network, wherein the loss is a weighted fusion of probability loss and text loss; Based on the loss, parameters of the end-to-end neural network are iteratively updated until a training cutoff condition is met.
7. The text input method according to claim 1, characterized in that: The construction of the basic candidate word vector library includes: Obtain general text corpus and name text corpus; The general text corpus is input into the first language model to obtain the general semantic features of each character in the general text corpus, and the name text corpus is input into the second language model to obtain the name semantic features of each character in the name text corpus to form the basic candidate word vector library.
8. A text input device, characterized in that: include: The acquisition module is used to obtain the string and the fusion candidate word vector library; A decoding word module, connected to the acquisition module, is used to input the character string into a decoding model to obtain a decoding word of the character string; wherein the decoding model is used to obtain the semantic features of the character string, and obtain the decoding word of the character string by using the semantic features of the character string and the fused candidate word vector library; the fused candidate word vector library includes a plurality of candidate semantic features, wherein the candidate semantic features are fused semantic features of candidate characters, wherein the fused semantic features of the candidate characters are a weighted fusion of the general semantic features of the candidate characters and the semantic features of the names of the candidate characters, and the decoding word is a combination of the candidate characters of the characters in the character string; A construction module, connected to the acquisition module or the decoding word module, for constructing a basic candidate word vector library, wherein the basic candidate word vector library includes a general word library and a person noun library, wherein the general word library includes a plurality of general semantic features, and the person noun library includes a plurality of person name semantic features; Obtaining the fused candidate word vector library includes: obtaining the general semantic features and name semantic features of the candidate words of each character in the character string from the basic candidate word vector library; weightedly fusing the general semantic features of the candidate words and the name semantic features of the candidate words to obtain the fused semantic features of the candidate words to form the fused candidate word vector library.
9. An electronic device, characterized in that: The invention comprises a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the text input method according to any one of claims 1 to 7.
10. A storage device, characterized in that: Program instructions that can be executed by a processor are stored, and the program instructions are used to implement the text input method according to any one of claims 1 to 7.
