WO2020001329A1 - 一种输入预测方法及装置 - Google Patents

一种输入预测方法及装置 Download PDF

Info

Publication number
WO2020001329A1
WO2020001329A1 PCT/CN2019/091755 CN2019091755W WO2020001329A1 WO 2020001329 A1 WO2020001329 A1 WO 2020001329A1 CN 2019091755 W CN2019091755 W CN 2019091755W WO 2020001329 A1 WO2020001329 A1 WO 2020001329A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
vocabulary
state parameter
current text
neural network
Prior art date
Application number
PCT/CN2019/091755
Other languages
English (en)
French (fr)
Inventor
贾亚伟
吴晓强
Original Assignee
北京金山安全软件有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京金山安全软件有限公司 filed Critical 北京金山安全软件有限公司
Priority to US16/761,216 priority Critical patent/US11409374B2/en
Publication of WO2020001329A1 publication Critical patent/WO2020001329A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/274Converting codes to words; Guess-ahead of partial word inputs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/02Input arrangements using manually operated switches, e.g. using keyboards or dials
    • G06F3/023Arrangements for converting discrete items of information into a coded form, e.g. arrangements for interpreting keyboard generated codes as alphanumeric codes, operand codes or instruction codes
    • G06F3/0233Character input methods
    • G06F3/0237Character input methods using prediction or retrieval techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/242Dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/268Morphological analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/02Input arrangements using manually operated switches, e.g. using keyboards or dials
    • G06F3/023Arrangements for converting discrete items of information into a coded form, e.g. arrangements for interpreting keyboard generated codes as alphanumeric codes, operand codes or instruction codes
    • G06F3/0233Character input methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • G06F3/04886Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures by partitioning the display area of the touch-screen or the surface of the digitising tablet into independently controllable areas, e.g. virtual keyboards or menus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present application relates to the technical field of input methods, and in particular, to an input prediction method and device.
  • the word prediction function is often set in the input method client, that is, the function of predicting the next text that the user will enter based on the text currently entered by the user. Forecast text.
  • the input method client determines the predicted text, the predicted text is displayed to the user for the user to select and input.
  • the input method client is an input method application.
  • the input method client can use a recurrent neural network to determine the predicted text.
  • the recurrent neural network may infer the predicted text of the currently input text according to the previous text of the currently input text.
  • this input prediction method can more accurately determine the predicted text, when determining the predicted text, the recurrent neural network needs to perform calculation processing on the previous text, and determine the currently input predicted text according to the calculation processing result of the previous text. It takes a long time to predict the text, so it is an urgent problem to reduce the time it takes to determine the predicted text as much as possible.
  • the purpose of the embodiments of the present application is to provide an input prediction method and device, so as to reduce the time consumed for determining the predicted text.
  • the specific technical solution is as follows.
  • an input prediction method where the method includes:
  • first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; the first state parameter is: a preset recurrent neural network according to the first text The state parameter of the previous text and the first text are determined; the recurrent neural network is trained according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • the predicted text of the current text is determined from the vocabulary according to the state parameters of the current text.
  • the method further includes:
  • the state parameter of the current text is stored in a cache.
  • the step of determining a predicted text of the current text from the vocabulary according to a state parameter of the current text includes:
  • the predicted text of the current text is determined according to each target vocabulary.
  • the step of determining the predicted text of the current text according to each target vocabulary includes:
  • the dictionary library is used to store multiple Morpheme
  • the predicted text of the current text is selected from each target vocabulary and each candidate morpheme according to the vocabulary score of each target vocabulary and the score of each candidate morpheme.
  • the method includes:
  • the network parameters during the operation of the recurrent neural network are obtained in the following manner:
  • Integer approximation is performed on the decimal-type parameters in the network parameters when the training is completed, and the obtained processed network parameters are used as the network parameters during the operation of the recurrent neural network.
  • the method is applied to a client, and the installation file of the client is obtained in the following manner:
  • An operation function other than an operation function in the original code in the initial installation file is removed to obtain an installation file of the client.
  • an input prediction device where the device includes:
  • a text acquisition module which is used to acquire the input current text
  • a parameter obtaining module is configured to obtain a first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; and the first state parameter is a preset recurrent neural network Determined according to a state parameter of a previous text of the first text and the first text; the recurrent neural network is trained according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • a parameter determining module configured to input both the current text and the first state parameter into the recurrent neural network, and the recurrent neural network determines the state parameter of the current text according to the first state parameter;
  • the text prediction module is configured to determine a predicted text of the current text from the vocabulary according to a state parameter of the current text.
  • the device further includes:
  • the parameter buffer module is configured to save the state parameter of the current text in a cache after determining the state parameter of the current text.
  • the text prediction module includes:
  • a first determining submodule configured to determine a vocabulary score of each vocabulary in the vocabulary according to a state parameter of the current text
  • a selection submodule configured to select a target vocabulary from each vocabulary of the vocabulary according to each vocabulary score
  • the second determining submodule is configured to determine the predicted text of the current text according to each target vocabulary.
  • the second determining submodule is specifically configured to:
  • the predicted text of the current text is selected from each target vocabulary and each candidate morpheme.
  • the method includes:
  • the network parameters during the operation of the recurrent neural network are obtained by the following operations:
  • Integer approximation is performed on the decimal-type parameters in the network parameters when the training is completed, and the obtained processed network parameters are used as the network parameters during the operation of the recurrent neural network.
  • the device is applied to a client, and the installation file of the client is obtained by the following operations:
  • An operation function other than an operation function in the original code in the initial installation file is removed to obtain an installation file of the client.
  • an embodiment of the present application provides an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • the processor is configured to implement any one of the input prediction methods provided in the first aspect when executing a program stored in the memory.
  • an embodiment of the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any input prediction provided by the first aspect is implemented. method.
  • an embodiment of the present application provides an application program, where the application program is used to execute any input prediction method provided in the first aspect at runtime.
  • the input prediction method and device can obtain the state parameters of the first text from the cache, and input both the current text and the state parameters of the first text into the recurrent neural network, and the recurrent neural network according to the state of the first text
  • the parameters determine the state parameters of the current text, and determine the predicted text of the current text from the vocabulary based on the state parameters of the current text.
  • the state parameter of the first text is not determined by the recurrent neural network according to the state parameter of the previous text of the first text, but the state parameter of the first text is directly obtained from the cache That is enough, it is possible to reduce the time taken to determine the predicted text.
  • the implementation of any product or method of this application does not necessarily need to achieve all the advantages described above at the same time.
  • FIG. 1 is a schematic flowchart of an input prediction method according to an embodiment of the present application.
  • FIG. 2 is an input / output structure diagram of a recurrent neural network according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of an output result of an input method client interface provided by an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of determining a prediction result according to an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an input prediction device according to an embodiment of the present application.
  • FIG. 6 is another schematic structural diagram of an input prediction apparatus according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a specific structure of the text prediction module 304 in the embodiment shown in FIG. 5;
  • FIG. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • embodiments of the present application provide a method and device for input prediction. The following describes this application in detail through specific embodiments.
  • FIG. 1 is a schematic flowchart of an input prediction method according to an embodiment of the present application.
  • the method can be applied to an electronic device, and can be specifically applied to a client in the electronic device.
  • the client may be an input method application installed in an electronic device.
  • the electronic device may be a computer, a server, a mobile device, or the like.
  • the mobile device can be a smart phone, a tablet, etc.
  • the method includes the following steps:
  • Step S101 Acquire the input current text.
  • the current text may be the current text input by the user.
  • the client receives the current text entered by the user, in order to facilitate the user's input, the text that the user wants to enter after the current text can be inferred, that is, the predicted text of the current text is determined and displayed to the user, so that the user can read from the displayed Selecting from predictive text saves time for entering text and can give users a good input experience.
  • the client can obtain the current text when the prediction condition is met, that is, trigger the prediction input.
  • the prediction condition may include: when the pause period after the user enters the current text is greater than a preset duration threshold; or when the prediction button is triggered after the user enters the current text.
  • the current text can include different situations in different language types.
  • the current text in the English language, can be a word or a part of a word, for example, it can be posted, p, or po.
  • the current text in Chinese language, can be a single character or part of a stroke of a character.
  • Step S102 Obtain a first state parameter of the first text from the buffer.
  • the first text is a previous text of the current text.
  • the first state parameter is: the preset recurrent neural network is determined according to the state parameter of the previous text of the first text and the first text.
  • the recurrent neural network is trained according to a preset vocabulary. The vocabulary is used to store individual words.
  • the recurrent neural network may be a long short-term memory network (LSTM).
  • LSTM long short-term memory network
  • the LSTM can solve the prediction problem of time series.
  • Each vocabulary in the vocabulary is a vocabulary obtained from the collected corpus.
  • the vocabulary can include a large number of words, for example, the vocabulary can contain 20,000 words.
  • the vocabulary can also be presented in the form of a vocabulary, and each vocabulary can be arranged in the vocabulary in a predetermined order, for example, according to the first letter, or according to the number of letters included.
  • Each vocabulary in the vocabulary is different in different language types.
  • each word in the vocabulary can be a word or a phrase.
  • each word in the vocabulary can be a single word, or a word or phrase composed of two or more words.
  • an English language is used as an example to describe the input prediction method.
  • Step S103 Both the current text and the first state parameter are input into a recurrent neural network, and the recurrent neural network determines the state parameter of the current text according to the first state parameter.
  • the state parameter can be understood as the internal memory or internal knowledge of the neural network.
  • the state parameter refers to the state parameter of the hidden layer in the recurrent neural network. Different current text has different state parameters corresponding to the current text.
  • the state parameter may be a vector of a preset dimension, for example, a 100-dimensional vector.
  • the preset state parameter can be used as the first state parameter, and step S103 is directly executed.
  • the state parameters of the current text can also be stored in the cache. In this way, when determining the predicted text of the next text, the state parameters of the previous text can be obtained directly from the cache.
  • the current text When the current text is input into the recurrent neural network, the current text can be mapped to a vector, and the current text in the form of a vector is input to the recurrent neural network.
  • Step S104 Determine the predicted text of the current text from the vocabulary according to the state parameters of the current text.
  • the recurrent neural network is trained according to the vocabulary.
  • the state parameters of the current text can reflect the association between the current text and the vocabulary in the vocabulary. Therefore, after obtaining the state parameters of the current text, it can be determined from the vocabulary which words can be used as the predicted text of the current text according to the state parameters of the current text.
  • the state parameter of the current text is used as a reference for the state parameter of the previous text, the state parameter of the current text takes into account the meaning of the entire sentence, and the predicted text determined based on the state parameter of the current text is more accurate.
  • this embodiment can obtain the state parameters of the first text from the cache, input the current text and the state parameters of the first text into the recurrent neural network, and the recurrent neural network determines the current text according to the state parameters of the first text. And determine the predicted text of the current text from the vocabulary based on the state parameters of the current text.
  • the state parameters of the first text need not be determined by the recurrent neural network according to the state parameters of the previous text of the first text, but the state parameters of the first text are directly obtained from the cache. Yes, so it can reduce the time taken to determine the predicted text and improve the user experience.
  • the prediction of a word depends only on the first or two words in the context, which makes it difficult to predict the input the user really wants.
  • Statistical language models can be unigram, bigram, and trigram models.
  • a recurrent neural network is used to predict the input text, and the state parameter of the previous word is required for each prediction. In this way, the state parameter of the current text takes into account the information of all texts before the current text, so the determined predicted text is also more accurate.
  • the mobile device's processing power and storage space are relatively small, and the user's use of mobile devices for text input is very sensitive to the time-consuming prediction, and a delay of more than 200ms will make Users experience significant latency perception.
  • the state parameter of the previous text is cached and directly obtained from the cache when needed, which can shorten the prediction time, making it possible to apply a recurrent neural network to a mobile device for local prediction.
  • step S104 determining the predicted text of the current text from the vocabulary according to the state parameters of the current text, including the following steps 1a to 3a.
  • Step 1a Determine the vocabulary score of each vocabulary in the vocabulary according to the state parameters of the current text.
  • the vocabulary score can be understood as the probability that each vocabulary appears after the current text.
  • the transformation matrix is used to obtain the score vector corresponding to the state parameters of the current text and all the words in the vocabulary.
  • Each element in the scoring vector corresponds to each vocabulary in the vocabulary.
  • the elements in the scoring vector are the words of the corresponding vocabulary. score.
  • the conversion matrix may be a preset matrix.
  • the state parameter of the current text is a matrix of 1 ⁇ 100
  • the transformation matrix is a matrix of 100 ⁇ 20,000, where 20,000 is the total number of words in the vocabulary.
  • each vocabulary score may be a score after normalization processing. Specifically, after multiplying the state parameter of the current text with the transformation matrix to obtain a score vector, each element in the score vector can also be normalized to obtain each vocabulary score.
  • the vocabulary score of each vocabulary is saved. In the cache. In this way, when input prediction is performed on the next text of the current text, it can be directly obtained from the cache.
  • Step 2a Select a target vocabulary from each vocabulary in the vocabulary according to each vocabulary score.
  • a specified number of vocabulary with the highest vocabulary score can be selected from all vocabularies in the vocabulary as the target vocabulary. For example, when the specified number is 5, specifically, each vocabulary score can be sorted in order from high to low or low to high, and the vocabulary in the vocabulary library corresponding to the highest 5 vocabulary scores in the sorted vocabulary score. As the target vocabulary.
  • the vocabulary in the vocabulary library corresponding to the vocabulary score greater than the first scoring threshold may be selected as the target vocabulary. For example, if the first scoring threshold is 75, a vocabulary with a vocabulary score greater than 75 can be selected as the target vocabulary.
  • Step 3a Determine the predicted text of the current text according to each target vocabulary.
  • each target word can be directly determined as the predicted text of the current text.
  • the predicted text of the current text can also be obtained after performing preset processing on each target vocabulary.
  • the vocabulary score of each vocabulary in the vocabulary can be obtained according to the state parameters of the current text, and the target vocabulary is selected from the vocabulary according to the vocabulary score, which provides a specific implementation method for obtaining the predicted text based on the state parameters .
  • the current text may be a complete morpheme or a non-complete morpheme.
  • the current text can be a word or part of a word, that is, a single letter or a combination of several letters. Therefore, in order to enable the determined predicted text to complete incomplete morphemes and correct the wrong prediction input by the user, the present application also provides the following embodiments.
  • step 3a determines the predicted text of the current text according to each target vocabulary
  • steps 3a-1 to 3a-4 may be included.
  • Step 3a-1 Match the current text with the morphemes in the preset dictionary library, and use the morphemes in the successfully matched dictionary library as candidate morphemes that are similar to the current text.
  • the dictionary library is used to store multiple complete morphemes.
  • the morphemes in the dictionary library can be understood as the smallest semantic combination in the language type corresponding to the dictionary library. For example, when the language type is English, each morpheme in the dictionary library is a single word; when the language type is Chinese, each morpheme in the dictionary library is a single word.
  • the method includes: using the morpheme prefixed by the current text as the successful morpheme; and / or, calculating the similarity between the current text and the morpheme in the dictionary library, respectively, The morphemes whose similarity is greater than the threshold of similarity are taken as the morphemes with successful matching.
  • the above matching process includes words obtained by completing the current text and words obtained by performing error correction.
  • each candidate morpheme can include: posted, post, person, and photo.
  • the goud may be a word entered by the user.
  • the candidate morphemes that can be obtained include: good, goad, and other words.
  • each candidate morpheme may be a word including the partial stroke.
  • the string similarity algorithm can be an edit distance algorithm (Levenshtein Distance) or an Euclidean distance algorithm (Euclidean distance).
  • Step 3a-2 Obtain a vocabulary score of each vocabulary in the vocabulary determined when input prediction is performed on the first text.
  • the vocabulary score of each vocabulary in the vocabulary determined during the input prediction of the first text may be directly obtained from the cache.
  • Step 3a-3 Determine the score of each morpheme to be selected from the vocabulary scores of each vocabulary in the vocabulary determined during the input prediction of the first text.
  • This step may specifically include: using the vocabulary score of each vocabulary in the vocabulary determined during the input prediction of the first text as the reference vocabulary score, matching each candidate morpheme with each vocabulary in the vocabulary, and the matching is successful
  • the reference vocabulary score corresponding to the vocabulary in the vocabulary library is used as the score of the candidate morpheme.
  • the vocabulary includes am, like, post, book and other words.
  • the vocabulary scores of the words in the above vocabulary are: am-0.94, like-0.52, post-0.32 , Book-0.01.
  • the candidate morpheme is am, it can be determined that the score of am is 0.94.
  • the candidate morpheme is book, it can be determined that the score of book is 0.01.
  • the first text is the previous text of the current text.
  • the score of each morpheme to be selected is determined from the vocabulary scores of each vocabulary corresponding to the first text. The effect of the previous text on the current text is considered, so the score of the selected morpheme is determined. More reasonable.
  • the score of each morpheme to be selected may be determined from the score of each vocabulary in the preset vocabulary.
  • Step 3a-4 According to the vocabulary score of each target vocabulary and the score of each candidate morpheme, select a predicted text of the current text from each target vocabulary and each candidate morpheme.
  • each target vocabulary and each candidate morpheme can be selected as candidates, and a preset number of candidates with the highest scores can be selected from each candidate as the predicted text of the current text.
  • a candidate target with a score greater than a preset second score threshold may be selected from each candidate target as the predicted text of the current text.
  • the target vocabulary is the vocabulary determined by the recurrent neural network, and the morphemes to be selected are the vocabulary obtained by completing and correcting the current text. According to the vocabulary score of the target vocabulary and the score of each candidate morpheme, the predicted text of the current text is selected from the target vocabulary and the candidate morphemes, and prediction, completion and error correction for the current text can be considered at the same time.
  • this embodiment can be combined with a dictionary library to determine each candidate morpheme that is close to the current text.
  • Each candidate morpheme can be a complement or correction word of the current text, and the The prediction text takes into account prediction, completion, and error correction, so the determined prediction text is more accurate and reasonable.
  • the method may include:
  • the state parameters of the current text are determined according to the network parameters and the first state parameters during the operation of the recurrent neural network.
  • the network parameters during the recurrent neural network operation are obtained in the following manner:
  • the approximation processing of this embodiment may also be referred to as a fixed-point operation.
  • the decimal parameter can be approximated as an integer parameter in accordance with a preset approximation principle.
  • the approximate processing principle may be a rounding principle or a rounding principle.
  • the integer size processing of the decimal type parameter can reduce the model size of the recurrent neural network, thereby reducing the size of the client space .
  • this embodiment in order to compress the size of the client, this embodiment may also perform a certain compression process on the client to which the above method is applied.
  • the installation file of the client can be obtained by using the steps shown in steps 1b to 2b below.
  • Step 1b Obtain an initial installation file generated according to the client's original code, and obtain the operation function in the client's original code.
  • a preset installation file generation algorithm can be used. Because the installation file generation tool generates an initial installation file based on the client's original code, it adds a lot of additional arithmetic functions, which will increase the size of the client installation file.
  • the installation file generating tool may be a Visual Studio (VS) or the like.
  • An operation function can also be referred to as an operation (op).
  • the operation functions in the client's original code may be saved by the programmer during the process of writing the code, or they may be operation functions in the client's original code obtained from the written original code by using other algorithms.
  • Step 2b The operation functions other than the operation functions in the original code are removed from the initial installation file to obtain a client installation file.
  • the operation functions in the original code are useful operation functions, and other operation functions are useless operation functions.
  • useless arithmetic functions include tf.gather and tf.concat. After removing these useless arithmetic functions, the size of the client installation file can be reduced.
  • FIG. 2 shows an input-output structure diagram of a recurrent neural network.
  • the recurrent neural network is LSTM
  • Ht-1 is the first state parameter
  • input is the input current text
  • Ht is the determined state parameter of the current text
  • Ct-1 and Ct are the cell states of the recurrent neural network at time t-1 and time t, respectively.
  • the LSTM can memorize relatively long context information and can determine what kind of information can enter the next moment through the LSTM. Therefore, LSTM can solve the problem of long dependence in context prediction.
  • the output of the hidden state of the LSTM passes through the prediction layer (projection) and will map the state parameter Ht into a vector of the same size as the vocabulary.
  • the vector passes through the normalization layer (softmax) to become a probability distribution on the vocabulary, that is, a score distribution.
  • the words needed for output are sorted by probability.
  • the LSTM determines which information can pass through the forget gate gating unit:
  • the gating unit determines which information passes through the sigmoid function. For the input gate gating unit, the process includes:
  • the output gate gating unit determines what kind of information output is needed:
  • p is the vocabulary score determined for each vocabulary in the vocabulary.
  • softmax () is a normalization function.
  • Wf, Wi, Wc, Wo, Wp, bf, bi, bc, bo and bp are all network parameters of the LSTM during operation.
  • Is a general multiplication symbol.
  • * Is the Hadamard product symbol.
  • xt is the value converted from the current text to a vector
  • is the sigmoid function
  • tanh is the hyperbolic tangent function in the trigonometric function.
  • the size of a recurrent neural network is generally tens of megabytes or even hundreds of megabytes, and the LSTM-based recurrent neural network inference time is about 20-30ms, that is, the time to determine a predicted text is about 20-30ms.
  • the time taken by the model is unacceptable when the context entered by the user is too long.
  • the size of the model can be reduced by fixed-pointing and selecting only operation operations op without affecting the accuracy of the model.
  • the client performs input prediction in the manner of the foregoing embodiment.
  • a sentence beginning tag ⁇ S> is added by default as the input predicted by the above.
  • the client's result output is:
  • FIG. 3 is a schematic diagram of an output result of an input method client interface.
  • the interface displays the input box, as well as the predicted text display area below and the area where the preset virtual keyboard is located.
  • the client detects that the user needs to enter text, and at this time, the output results of I, I don't, I'm, if, it, and it's can be displayed in the predicted text display area for User selection.
  • the output prediction result is:
  • FIG. 4 is a schematic flowchart of determining a prediction result based on an LSTM.
  • the LSTM model is first loaded and the vocabulary is read to initialize the LSTM.
  • the client detects the presence of the input current text (word list), it determines whether there is a state parameter of the previous text of the current text in the cache. If it exists, it obtains the state parameter of the previous text from the cache and changes the previous one.
  • the state parameter of the text and the current text are input into the LSTM, and the LSTM determines the state parameter of the current text according to the state parameter of the previous text, and updates the state parameter of the previous text in the cache to the state parameter of the current text.
  • the preset state parameter and the current text are input into the LSTM, and the LSTM determines the state parameter of the current text according to the preset state parameter, and sets the current text State parameters are stored in the cache.
  • the client After obtaining the state parameters of the current text, the client continues to determine the predicted text of the current text from the vocabulary according to the state parameters of the current text, and uses it as the output prediction result.
  • FIG. 5 is a schematic structural diagram of an input prediction apparatus according to an embodiment of the present application.
  • the device can be applied to an electronic device, and can be specifically applied to a client in the electronic device. This embodiment corresponds to the method embodiment shown in FIG. 1.
  • the device includes:
  • a text acquisition module 301 configured to acquire the input current text
  • a parameter obtaining module 302 is configured to obtain a first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; and the first state parameter is a preset recurrent nerve
  • the network is determined according to a state parameter of a previous text of the first text and the first text; the recurrent neural network is completed according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • a parameter determining module 303 configured to input both the current text and the first state parameter into the recurrent neural network, and the recurrent neural network determines the state parameter of the current text according to the first state parameter;
  • the text prediction module 304 is configured to determine a predicted text of the current text from the vocabulary according to a state parameter of the current text.
  • the device further includes:
  • the parameter cache module 305 is configured to store the state parameters of the current text in a cache after determining the state parameters of the current text.
  • the text prediction module 304 includes:
  • a first determining submodule 3041 configured to determine a vocabulary score of each vocabulary in the vocabulary according to a state parameter of the current text
  • a selection sub-module 3042 configured to select a target vocabulary from each vocabulary of the vocabulary according to each vocabulary score
  • the second determining submodule 3043 is configured to determine the predicted text of the current text according to each target vocabulary.
  • the second determining submodule is specifically configured to:
  • the dictionary library is used to store multiple Morpheme
  • the predicted text of the current text is selected from each target vocabulary and each candidate morpheme.
  • the method when the recurrent neural network determines the state parameter of the current text according to the first state parameter, the method includes:
  • the network parameters during the operation of the recurrent neural network are obtained by the following operations:
  • Integer approximation is performed on the decimal-type parameters in the network parameters when the training is completed, and the obtained processed network parameters are used as the network parameters during the operation of the recurrent neural network.
  • the device is applied to a client, and the installation file of the client is obtained by the following operations:
  • An operation function other than an operation function in the original code in the initial installation file is removed to obtain an installation file of the client.
  • the technical effect of the device embodiment is not described herein again.
  • the device embodiment since it is basically similar to the method embodiment, it is described relatively simply. For the relevant part, refer to the description of the method embodiment.
  • FIG. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the electronic device includes a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete communication with each other through the communication bus 404;
  • the processor 401 is configured to implement the input prediction method provided in the embodiment of the present application when a program stored in the memory 403 is executed.
  • the method includes:
  • first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; the first state parameter is: a preset recurrent neural network according to the first text The state parameter of the previous text and the first text are determined; the recurrent neural network is trained according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • the predicted text of the current text is determined from the vocabulary according to the state parameters of the current text.
  • the communication bus 404 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, or the like.
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • the communication bus 404 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, the figure only uses a thick line, but it does not mean that there is only one bus or one type of bus.
  • the communication interface 402 is used for communication between the electronic device and other devices.
  • the memory 403 may include random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory.
  • RAM Random Access Memory
  • NVM Non-Volatile Memory
  • the memory 403 may also be at least one storage device located far from the foregoing processor.
  • the processor 401 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), and the like; it may also be a digital signal processor (DSP), special integration Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • CPU central processing unit
  • NP network processor
  • DSP digital signal processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • the state parameters of the first text can be obtained from the cache, and both the current text and the state parameters of the first text are input to the recurrent neural network.
  • the recurrent neural network determines the state parameters of the current text according to the state parameters of the first text. And determine the predicted text of the current text from the vocabulary based on the state parameters of the current text.
  • the state parameters of the first text need not be determined by the recurrent neural network according to the state parameters of the previous text of the first text, but the state parameters of the first text are directly obtained from the cache. Yes, so it can reduce the time taken to determine the predicted text and improve the user experience.
  • An embodiment of the present application further provides a computer-readable storage medium.
  • a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the input prediction method provided in the embodiment of the present application is implemented.
  • the method includes:
  • first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; the first state parameter is: a preset recurrent neural network according to the first text The state parameter of the previous text and the first text are determined; the recurrent neural network is trained according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • the predicted text of the current text is determined from the vocabulary according to the state parameters of the current text.
  • the state parameters of the first text can be obtained from the cache, and both the current text and the state parameters of the first text are input to the recurrent neural network.
  • the recurrent neural network determines the state parameters of the current text according to the state parameters of the first text And determine the predicted text of the current text from the vocabulary based on the state parameters of the current text.
  • the state parameters of the first text need not be determined by the recurrent neural network according to the state parameters of the previous text of the first text, but the state parameters of the first text are directly obtained from the cache. Yes, so it can reduce the time taken to determine the predicted text and improve the user experience.
  • An embodiment of the present invention further provides an application program, which is used to execute the input prediction method provided by the embodiment of the present application at runtime.
  • the application implements the following steps when executed by a processor:
  • first state parameter of a first text from a cache; wherein the first text is a previous text of the current text; the first state parameter is: a preset recurrent neural network according to the first text The state parameter of the previous text and the first text are determined; the recurrent neural network is trained according to a preset vocabulary; the vocabulary is used to store each vocabulary;
  • the predicted text of the current text is determined from the vocabulary according to the state parameters of the current text.
  • the state parameters of the first text can be obtained from the cache, and the state parameters of the current text and the first text are input into the recurrent neural network.
  • the neural network determines the state parameters of the current text according to the state parameters of the first text, and determines the predicted text of the current text from the vocabulary according to the state parameters of the current text.
  • the state parameters of the first text need not be determined by the recurrent neural network according to the state parameters of the previous text of the first text, but the state parameters of the first text are directly obtained from the cache. Yes, so it can reduce the time taken to determine the predicted text and improve the user experience.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Human Computer Interaction (AREA)
  • Biomedical Technology (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • Evolutionary Computation (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Probability & Statistics with Applications (AREA)
  • Machine Translation (AREA)

Abstract

本申请实施例提供了一种输入预测方法及装置。该方法包括:获取输入的当前文本;从缓存中获取第一文本的第一状态参量;将所述当前文本和所述第一状态参量均输入所述循环神经网络,由循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;根据当前文本的状态参量,从词汇库中确定当前文本的预测文本;其中,第一文本为当前文本的前一文本;第一状态参量为:预设的循环神经网络根据第一文本的前一文本的状态参量和第一文本确定;循环神经网络为根据预设的词汇库训练完成;词汇库用于存储各个词汇。应用本申请实施例提供的方案,能够减少确定预测文本的耗费时间。

Description

一种输入预测方法及装置
本申请要求于2018年6月28日提交中国专利局、申请号为201810691065.3、发明名称为“一种输入预测方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及输入法技术领域,特别是涉及一种输入预测方法及装置。
背景技术
为了提升用户使用输入法时的便捷性,在输入法客户端中常常设置有词预测功能,即基于用户当前输入的文本,预测用户所要输入的下一个文本的功能,所预测的文本可以称为预测文本。当输入法客户端确定出预测文本后,将预测文本展示给用户,以供用户选择输入。其中,输入法客户端即为输入法应用程序。
在根据当前输入的文本确定预测文本时,输入法客户端可以采用循环神经网络确定预测文本。具体的,循环神经网络可以根据当前输入的文本的前一文本推测当前输入的文本的预测文本。
虽然这种输入预测方式能够较准确地确定预测文本,但是,循环神经网络在确定预测文本时,需要对前一文本进行计算处理,根据前一文本的计算处理结果确定当前输入的预测文本,确定预测文本所耗费的时间较长,因此,尽可能地减少确定预测文本所耗费的时间,是亟待解决的问题。
发明内容
本申请实施例的目的在于提供了一种输入预测方法及装置,以减少确定预测文本的耗费时间。具体的技术方案如下。
第一方面,本申请实施例提供了一种输入预测方法,所述方法包括:
获取输入的当前文本;
从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根 据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
可选的,在确定所述当前文本的状态参量之后,所述方法还包括:
将所述当前文本的状态参量保存在缓存中。
可选的,所述根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本的步骤,包括:
根据所述当前文本的状态参量,确定所述词汇库中各个词汇的词汇评分;
根据各个词汇评分,从所述词汇库的各个词汇中选择目标词汇;
根据各个目标词汇,确定所述当前文本的预测文本。
可选的,所述根据各个目标词汇,确定所述当前文本的预测文本的步骤,包括:
将所述当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的所述字典库中的语素作为与所述当前文本相近的待选语素;所述字典库用于存储多个语素;
获取对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分;
从对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分中,确定各个待选语素的评分;
根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择所述当前文本的预测文本。
可选的,所述循环神经网络,根据所述第一状态参量确定所述当前文本的状态参量时,包括:
根据所述循环神经网络作业时的网络参数以及所述第一状态参量,确定所述当前文本的状态参量;
其中,所述循环神经网络作业时的网络参数采用以下方式得到:
获取所述循环神经网络训练完成时的网络参数;
对所述训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为所述循环神经网络作业时的网络参数。
可选的,所述方法应用于客户端,所述客户端的安装文件采用以下方式得到:
获取根据所述客户端的原始代码生成的初始安装文件,获取所述客户端的原始代码中的运算函数;
去除所述初始安装文件中除所述原始代码中的运算函数之外的运算函数,得到所述客户端的安装文件。
第二方面,本申请实施例提供了一种输入预测装置,所述装置包括:
文本获取模块,用于获取输入的当前文本;
参量获取模块,用于从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
参量确定模块,用于将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
文本预测模块,用于根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
可选的,所述装置还包括:
参量缓存模块,用于在确定所述当前文本的状态参量之后,将所述当前 文本的状态参量保存在缓存中。
可选的,所述文本预测模块,包括:
第一确定子模块,用于根据所述当前文本的状态参量,确定所述词汇库中各个词汇的词汇评分;
选择子模块,用于根据各个词汇评分,从所述词汇库的各个词汇中选择目标词汇;
第二确定子模块,用于根据各个目标词汇,确定所述当前文本的预测文本。
可选的,所述第二确定子模块,具体用于:
将所述当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的所述字典库中的语素作为与所述当前文本相近的待选语素;所述字典库用于存储多个语素;
获取对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分;
从对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分中,确定各个待选语素的评分;
根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择所述当前文本的预测文本。
可选的,所述循环神经网络,根据所述第一状态参量确定所述当前文本的状态参量时,包括:
根据所述循环神经网络作业时的网络参数以及所述第一状态参量,确定所述当前文本的状态参量;
其中,所述循环神经网络作业时的网络参数采用以下操作得到:
获取所述循环神经网络训练完成时的网络参数;
对所述训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为所述循环神经网络作业时的网络参数。
可选的,所述装置应用于客户端,所述客户端的安装文件采用以下操作得到:
获取根据所述客户端的原始代码生成的初始安装文件,获取所述客户端的原始代码中的运算函数;
去除所述初始安装文件中除所述原始代码中的运算函数之外的运算函数,得到所述客户端的安装文件。
第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;
存储器,用于存放计算机程序;
处理器,用于执行存储器上所存放的程序时,实现第一方面提供的任一输入预测方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现第一方面提供的任一输入预测方法。
第五方面,本申请实施例提供了一种应用程序,所述应用程序用于在运行时执行第一方面提供的任一输入预测方法。
本申请实施例提供的输入预测方法及装置,可以从缓存中获取第一文本的状态参量,将当前文本和第一文本的状态参量均输入循环神经网络,由循环神经网络根据第一文本的状态参量确定当前文本的状态参量,并根据当前文本的状态参量从词汇库中确定当前文本的预测文本。本申请实施例在确定当前文本的预测文本时,无需由循环神经网络根据第一文本的前一文本的状态参量确定第一文本的状态参量,而是直接从缓存中获取第一文本的状态参量即可,因此能够减少确定预测文本的耗费时间。当然,实施本申请的任一产品或方法并不一定需要同时达到以上所述的所有优点。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实 施例或现有技术描述中所需要使用的附图作简单的介绍。显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的输入预测方法的一种流程示意图;
图2为本申请实施例提供的循环神经网络的一种输入输出结构图;
图3为本申请实施例提供的输入法客户端界面的一种输出结果示意图;
图4为本申请实施例提供的确定预测结果的一种流程示意图;
图5为本申请实施例提供的输入预测装置的一种结构示意图;
图6为本申请实施例提供的输入预测装置的另一种结构示意图;
图7为图5所示实施例中文本预测模块304的一种具体结构示意图;
图8为本申请实施例提供的电子设备的一种结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整的描述。显然,所描述的实施例仅仅是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。
为了减少确定预测文本的耗费时间,本申请实施例提供了一种输入预测方法及装置。下面通过具体实施例,对本申请进行详细说明。
图1为本申请实施例提供的输入预测方法的一种流程示意图。该方法可以应用于电子设备,具体可以应用于电子设备中的客户端。客户端可以是安装在电子设备中的输入法应用程序。电子设备可以为计算机、服务器、移动设备等设备。移动设备可以为智能手机、平板电脑等。该方法包括如下步骤:
步骤S101:获取输入的当前文本。
其中,上述当前文本可以是用户输入的当前文本。当客户端接收到用户输入的当前文本时,为了方便用户的输入,可以推测用户在当前文本之后想要输入的文本,即确定当前文本的预测文本,并显示给用户,这样用户可以 从显示的预测文本中进行选择,节省了输入文本的时间,可以给用户良好的输入体验。
在获取当前文本时,客户端可以在预测条件满足时获取到当前文本,即触发预测输入。预测条件可以包括:用户输入当前文本之后的停顿时长大于预设时长阈值时;或者,在用户输入当前文本之后,预测按钮被触发时。
在不同的语言类型中,当前文本可以包括不同情况。举例来说,在英语语言中,当前文本可以为一个单词或单词的一部分,例如可以为posted、p或者po等。在汉语语言中,当前文本可以为一个字,也可以为字的部分笔画。
步骤S102:从缓存中获取第一文本的第一状态参量。
其中,第一文本为当前文本的前一文本。第一状态参量为:预设的循环神经网络根据第一文本的前一文本的状态参量和第一文本确定。循环神经网络为根据预设的词汇库训练完成。该词汇库用于存储各个词汇。
循环神经网络可以为长短时记忆网络(Long Short Term Memmory,LSTM)。该LSTM能够解决时间序列的预测问题。
词汇库中的各个词汇为根据收集的语料库得到的词汇。词汇库中可以包括较多数量条词汇,例如词汇库可以包含2万条词汇。词汇库也可以以词汇表的形式呈现,各个词汇可以按照预设顺序排列在词汇表中,例如按照首字母排列,或者按照所包括的字母数量的多少排列。在不同的语言类型中,词汇表中的各个词汇的情况不同。在英语语言中,词汇表中的每个词汇可以是单词,也可以是词组。在汉语语言中,词汇表中的每个词汇可以是单个的字,也可以是两个以上的字组成的词或短语。为了方便说明,本申请实施例中多以英语语言为例对输入预测方法进行说明。
步骤S103:将当前文本和第一状态参量均输入循环神经网络,由循环神经网络根据第一状态参量确定当前文本的状态参量。
其中,状态参量可以理解为神经网络的内部记忆或内部知识。该状态参量是指循环神经网络中隐藏层的状态参量。当前文本不同,对应得到的当前文本的状态参量也不同。状态参量可以为预设维数的向量,例如100维的向量。
当当前文本为第一个文本时,当前文本不存在前一文本。这种情况下可 以将预设状态参量作为第一状态参量,直接执行步骤S103。
在确定当前文本的状态参量之后,还可以将当前文本的状态参量保存在缓存中。这样,在确定下一文本的预测文本时,可以直接从缓存中获取前一文本的状态参量。
在将当前文本输入循环神经网络时,可以将当前文本映射为向量,将向量形式的当前文本输入循环神经网络。
步骤S104:根据当前文本的状态参量,从词汇库中确定当前文本的预测文本。
循环神经网络是根据词汇库训练完成的,上述当前文本的状态参量可以反映出当前文本与词汇库中词汇的关联。因此,在得到当前文本的状态参量之后,可以根据当前文本的状态参量,从词汇库中确定哪些词汇可以作为当前文本的预测文本。并且,由于当前文本的状态参量是以前一文本的状态参量作为参考的,因此,当前文本的状态参量考虑了整个句子的意思,根据当前文本的状态参量确定的预测文本更准确。
由上述内容可知,本实施例可以从缓存中获取第一文本的状态参量,将当前文本和第一文本的状态参量均输入循环神经网络,由循环神经网络根据第一文本的状态参量确定当前文本的状态参量,并根据当前文本的状态参量从词汇库中确定当前文本的预测文本。本实施例在确定当前文本的预测文本时,无需由循环神经网络根据第一文本的前一文本的状态参量确定第一文本的状态参量,而是直接从缓存中获取第一文本的状态参量即可,因此能够减少确定预测文本的耗费时间,能提高用户体验。
在采用统计语言模型确定预测文本的方案中,对词语进行预测时仅依赖上下文中的前一个或两个词语,这样很难预测用户真正想要的输入。统计语言模型可以为unigram、bigram和trigram等模型。而本实施例中,采用循环神经网络对输入的文本进行预测,每次预测时都需要用到前一词的状态参量。这样,当前文本的状态参量就考虑了当前文本之前的所有文本的信息,因此所确定的预测文本也更准确。
当将循环神经网络应用于移动设备进行预测时,由于移动设备的处理能力和存储空间相对较小,而用户使用移动设备进行文本输入时对预测的耗时 又非常敏感,超过200ms的延迟都会让用户产生明显的延迟感知。本实施例中,将前一文本的状态参量进行缓存,在需要时直接从缓存中获取,能够缩短预测时间,使得将循环神经网络应用于移动设备进行本地预测成为现实。
在本申请的另一实施例中,基于图1所示实施例,步骤S104,根据当前文本的状态参量,从词汇库中确定当前文本的预测文本的步骤,包括以下步骤1a~步骤3a。
步骤1a:根据当前文本的状态参量,确定词汇库中各个词汇的词汇评分。
其中,词汇评分可以理解为每个词汇出现在当前文本之后的概率。
确定词汇库中各个词汇的词汇评分时,具体可以包括以下方式:
通过转换矩阵得到当前文本的状态参量与词汇库中所有词汇对应的评分向量,该评分向量中的各个元素均与词汇库中的各个词汇一一对应,评分向量中的元素即为对应词汇的词汇评分。
其中,转换矩阵可以为预设矩阵。例如,当前文本的状态参量为1×100的矩阵,转换矩阵为100×2万的矩阵,其中,2万是词汇库中词汇的总条数。将当前文本的状态参量与转换矩阵相乘后,得到2万维的评分向量,该评分向量中的每个元素就是对应词汇的词汇评分。
为了方便后续处理,各个词汇评分可以为经过归一化处理后的评分。具体的,在将当前文本的状态参量与转换矩阵相乘得到评分向量后,还可以对该评分向量中的每个元素进行归一化处理,得到各个词汇评分。
在另一实施方式中,在针对当前文本,确定词汇库中各个词汇的词汇评分之后,即在将对当前文本进行输入预测时确定词汇库中各个词汇的词汇评分之后,将该各个词汇评分保存在缓存中。这样能够方便在对当前文本的下一文本进行输入预测时可以直接从缓存中获取。
步骤2a:根据各个词汇评分,从词汇库的各个词汇中选择目标词汇。
在选择目标词汇时,可以从词汇库的所有词汇中选择指定数量个词汇评分最高的词汇,作为目标词汇。例如,指定数量为5时,具体的,可以将各个词汇评分按照从高到低或从低到高的顺序排序,将排序后的词汇评分中最高的5个词汇评分对应的词汇库中的词汇作为目标词汇。
也可以是,将大于第一评分阈值的词汇评分对应的词汇库中的词汇选择 为目标词汇。例如,第一评分阈值为75,那么便可以将词汇库中词汇评分大于75的词汇选择为目标词汇。
步骤3a:根据各个目标词汇,确定当前文本的预测文本。
具体的,可以直接将各个目标词汇确定为当前文本的预测文本。也可以对各个目标词汇进行预设处理后得到当前文本的预测文本。
综上,本实施例中可以根据当前文本的状态参量得到词汇库中各个词汇的词汇评分,根据词汇评分从词汇库中选择目标词汇,为根据状态参量得到预测文本提供了一种具体的实施方式。
在本申请的另一实施例中,由于当前文本可能为完整语素,也可能为非完整语素。例如,在英语语言中,当前文本可以为单词,也可以为单词的一部分,即单个字母或者几个字母的组合。因此,为了使得确定的预测文本能够实现对非完整语素的补全,以及对用户输入的错误预测进行纠错,本申请还提供了以下实施例。
在本实施例中,上述步骤3a,根据各个目标词汇确定所述当前文本的预测文本时,可以包括以下步骤3a-1~3a-4。
步骤3a-1:将当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的字典库中的语素作为与当前文本相近的待选语素。
其中,字典库用于存储多个完整语素。字典库中的语素可以理解为字典库对应的语言类型中的最小语义结合体。例如,当语言类型为英语时,字典库中的每个语素即为单个的单词;当语言类型为汉语时,字典库中的每个语素均为单个的字。
将当前文本分别与字典库中的语素进行匹配时,包括:将以当前文本为前缀的语素作为匹配成功的语素;和/或,计算当前文本分别与字典库中的语素之间的相似度,将相似度大于相似度阈值的语素作为匹配成功的语素。上述匹配过程,包含了对当前文本进行补全得到的词和进行纠错得到的词。
例如,当前文本为p时,各个待选语素可以包括:posted,post,person和photo等。当前文本为goud时,该goud可能是用户输错的词,这时根据相似度计算,可以得到的待选语素包括:good,goad等词。当前文本是部分笔画时,各个待选语素可以是包括该部分笔画的字。
在计算当前文本与语素之间的相似度时,可以采用预设的字符串相似度算法。字符串相似度算法可以为编辑距离算法(Levenshtein Distance)或欧氏距离算法(Euclidean distance)等。
步骤3a-2:获取对第一文本进行输入预测时确定的词汇库中各个词汇的词汇评分。
具体的,可以从缓存中直接获取对第一文本进行输入预测时确定的词汇库中各个词汇的词汇评分。
步骤3a-3:从对第一文本进行输入预测时确定的词汇库中各个词汇的词汇评分中,确定各个待选语素的评分。
本步骤具体可以包括:将对第一文本进行输入预测时确定的词汇库中各个词汇的词汇评分作为参考词汇评分,将每个待选语素分别与词汇库中的各个词汇进行匹配,将匹配成功的词汇库中的词汇对应的参考词汇评分,作为该待选语素的评分。
例如,词汇库中包括am,like,post,book等词,对第一文本I进行输入预测时,确定上述词汇库中的词的词汇评分分别为:am-0.94,like-0.52,post-0.32,book-0.01。当待选语素为am时,则可以确定am的评分为0.94。当待选语素为book时,可以确定book的评分为0.01。
第一文本为当前文本的前一文本,从第一文本对应的各个词汇的词汇评分中确定各个待选语素的评分,考虑了前一文本对当前文本的影响,因此确定的待选语素的评分比较合理。
当当前文本不存在前一文本时,可以从预设的词汇库中各个词汇的评分中,确定各个待选词素的评分。
步骤3a-4:根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择当前文本的预测文本。
在选择当前文本的预测文本时,可以将各个目标词汇以及各个待选语素均作为待选目标,从各个待选目标中选择预设数量个评分最高的待选目标作为当前文本的预测文本。也可以是,从各个待选目标中选择评分大于预设的第二评分阈值的待选目标,作为当前文本的预测文本。
目标词汇为根据循环神经网络确定的词汇,待选语素为对当前文本进行 补全和纠错后得到的词汇。根据目标词汇的词汇评分以及各个待选语素的评分,从目标词汇以及待选语素中选择当前文本的预测文本,可以同时考虑针对当前文本的预测、补全和纠错。
综上,本实施例可以结合字典库,确定与当前文本相近的各个待选语素,每个待选语素可以为当前文本的补全词或者纠正词,根据待选语素和目标词汇确定当前文本的预测文本,兼顾了预测、补全和纠错,因此确定的预测文本更准确、合理。
当将循环神经网络应用在移动设备中时,由于移动设备的处理能力和存储空间都有一定限制,为了压缩客户端的大小,减少空间占用,本申请还提供了以下实施例。
在本实施例中,循环神经网络根据第一状态参量确定当前文本的状态参量时,可以包括:
根据循环神经网络作业时的网络参数以及第一状态参量,确定当前文本的状态参量。
其中,循环神经网络作业时的网络参数采用以下方式得到:
获取循环神经网络训练完成时的网络参数,对训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为循环神经网络作业时的网络参数。本实施例的近似处理也可以称为定点化操作。
在对小数型参数进行整数近似处理时,可以按照预设的近似处理原则,将小数型参数近似为整数型参数。其中,近似处理原则可以为四舍五入原则,或者五舍六入原则等。
本实施例中,由于小数型参数相比于整数型参数要占用更多的存储空间,对小数型参数进行整数近似处理时可以减小循环神经网络的模型大小,进而减少客户端占用空间的大小。
在本申请的另一实施例中,为了压缩客户端的大小,本实施例还可以对上述方法所应用的客户端进行一定的压缩处理。本实施例中,客户端的安装文件可以采用以下步骤1b~2b所示步骤得到。
步骤1b:获取根据客户端的原始代码生成的初始安装文件,获取客户端的原始代码中的运算函数。
在生成初始安装文件时,可以采用预设的安装文件生成算法。由于安装文件生成工具在根据客户端的原始代码生成初始安装文件时,会添加很多额外的运算函数,这会增加客户端安装文件的大小。
其中,安装文件生成工具可以为可视化工作室(Visual Studio,VS)等。运算函数也可以称为运算操作(operation,op)。
本实施例中,客户端的原始代码中的运算函数可以是由程序员在编写代码过程中保存的,也可以是采用其他算法从编写好的原始代码中获取的客户端的原始代码中的运算函数。
步骤2b:去除初始安装文件中除原始代码中的运算函数之外的运算函数,得到客户端的安装文件。
原始代码中的运算函数为有用的运算函数,除此之外的运算函数为无用的运算函数。例如,无用的运算函数包括tf.gather和tf.concat等。去除这部分无用的运算函数后,能够减小客户端安装文件的大小。
下面结合具体实例对本申请再做详细说明。
参见图2,图2所示为循环神经网络的一种输入输出结构图。其中,循环神经网络为LSTM,Ht-1为第一状态参量,input为输入的当前文本,Ht为确定的当前文本的状态参量。Ct-1和Ct分别为t-1时刻和t时刻时循环神经网络的细胞状态。当用户在t时刻输入字符posted时,输入层(embedding)会将posted映射为向量,然后和时间t-1的状态参量Ht-1一起作为t时刻LSTM的输入。通过LSTM内的输入门、遗忘门、输出门等门控单元,LSTM能够记忆比较长的上下文信息并能决定什么样的信息能够通过LSTM进入下一时刻。因此,LSTM能够解决上下文预测中的长依赖问题。接着,LSTM的隐藏状态的输出经过预测层(projection)将把状态参量Ht映射为与词汇库大小相同的向量。最后该向量经过归一化层(softmax)成为词表上的一个概率分布也就是评分分布。最后按概率大小排序输出(output)所需要的词语。
具体的,LSTM通过遗忘门门控单元来决定哪些信息可以通过:
f=σ(Wf·[Ht-1,xt]+bf)
该门控单元通过sigmoid函数决定哪信息通过。对于输入门门控单元,处理过程包括:
i=σ(Wi·[Ht-1,xt]+bi)
c=tanh(Wc·[Ht-1,xt]+bc)
通过上述两个公式可以在输入门中添加需要的信息。输出门门控单元则决定了需要什么样的信息输出:
o=σ(Wo·[Ht-1,xt]+bo)
Ht=o*tanh(c)
由于本实施例最终需要在词汇表上的概率分布,因此还需要通过projection层和softmax将Ht变为词汇表上的概率分布:
y=Wp·Ht+bp
p=softmax(y)
其中,p即为针对词汇表中的每个词汇确定的词汇评分。softmax()为归一化函数。Wf,Wi,Wc,Wo,Wp,bf,bi,bc,bo和bp均为LSTM在作业时的网络参数。“·”为一般乘法符号。“*”为哈达马乘积(hadamard product)符号。xt为将当前文本转换为向量后的值,σ为sigmoid函数,tanh为三角函数中的双曲正切函数。
循环神经网络的大小一般是几十兆甚至上百兆,并且基于LSTM的循环神经网络推测(inference)一次的时间大概是20~30ms,也就是确定一次预测文本的时间大概是20~30ms。当用户输入的上下文过长时模型所花费的时间是不可接受的。针对模型大小的问题,首先可以通过在不影响模型准确率的情况下通过定点化以及选取只用到的运算操作op来减小模型的大小。针对模型推测时间问题,可以运用LSTM循环迭代的特性使用缓存保存LSTM的上一个状态参量。当计算当前文本的状态参量时,只需去缓存中获取而无需重复计算,这很大程度上减少了模型推测的时间。
例如,假设用户想要输入的语句为I posted a photo on Facebook。客户端采用上述实施例的方式进行输入预测。在检测到用户需要输入文本时,首先是默认加入一个句首开始标记<S>作为空上文预测的输入,此时客户端的结果输出为:
I,I don't,I'm,if,it,it's
参见图3,该图3为输入法客户端界面的一种输出结果示意图。该界面中 展示了输入框,以及下方的预测文本展示区域和预设虚拟键盘所在区域。当用户将光标移动至输入框中时,客户端检测到用户需要输入文本,此时可以在预测文本展示区域显示I,I don't,I'm,if,it和it's的输出结果,供用户选择。当用户从上述输出结果中选择I,此时以“<S>I”作为输入,输出的预测结果是:
don't know,don't,love,am
由于没有用户想要的词,用户接着输入p,此时以<S>I p作为输入,输出的预测结果是:
posted a,posted,promise,pray,put
用户选择词组posted a,此时以<S>I posted a作为输入,输出的预测结果是:
new,new vedio,photo,picture
用户选择词photo,此时以<S>I posted a photo作为输入,输出的预测结果是:
of,of my,to,on
用户选择词on,此时以<S>I posted a photo on作为输入,输出的预测结果是:
my,my blog,Facebook,Instagram,the
用户选择“Facebook”,输入完成。可见,基于LSTM的智能输入法可以在很大程度上提高用户的输入效率。
参见图4,该图4为基于LSTM确定预测结果的一种流程示意图。其中,当客户端被启用时,首先会加载LSTM模型并读取词汇表,对LSTM进行初始化。当客户端检测到存在输入的当前文本(word list)时,判断缓存中是否存在该当前文本的前一文本的状态参量,如果存在,则从缓存中获取前一文本的状态参量,将前一文本的状态参量和当前文本输入LSTM,由LSTM根据前一文本的状态参量确定该当前文本的状态参量,并将缓存中前一文本的状态参量更新为当前文本的状态参量。如果缓存中不存在该当前文本的前一文本的状态参量,则将预设的状态参量和当前文本输入LSTM,由LSTM根据预设的状态参量确定该当前文本的状态参量,并将当前文本的状态参量保 存在缓存中。在得到当前文本的状态参量之后,客户端继续根据当前文本的状态参量从词汇表中确定当前文本的预测文本,并作为输出的预测结果。
图5为本申请实施例提供的输入预测装置的一种结构示意图。该装置可以应用于电子设备,具体可以应用于电子设备中的客户端。本实施例与图1所示方法实施例相对应,该装置包括:
文本获取模块301,用于获取输入的当前文本;
参量获取模块302,用于从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
参量确定模块303,用于将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
文本预测模块304,用于根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
在本申请的另一实施例中,基于图5所示实施例,如图6所示,该装置还包括:
参量缓存模块305,用于在确定所述当前文本的状态参量之后,将所述当前文本的状态参量保存在缓存中。
在本申请的另一实施例中,基于图5所示实施例,如图7所示,文本预测模块304包括:
第一确定子模块3041,用于根据所述当前文本的状态参量,确定所述词汇库中各个词汇的词汇评分;
选择子模块3042,用于根据各个词汇评分,从所述词汇库的各个词汇中选择目标词汇;
第二确定子模块3043,用于根据各个目标词汇,确定所述当前文本的预测文本。
在本申请的另一实施例中,基于图5所示实施例,第二确定子模块具体 用于:
将所述当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的所述字典库中的语素作为与所述当前文本相近的待选语素;所述字典库用于存储多个语素;
获取对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分;
从对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分中,确定各个待选语素的评分;
根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择所述当前文本的预测文本。
在本申请的另一实施例中,基于图5所示实施例,循环神经网络根据所述第一状态参量确定所述当前文本的状态参量时,包括:
根据所述循环神经网络作业时的网络参数以及所述第一状态参量,确定所述当前文本的状态参量;
其中,所述循环神经网络作业时的网络参数采用以下操作得到:
获取所述循环神经网络训练完成时的网络参数;
对所述训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为所述循环神经网络作业时的网络参数。
在本申请的另一实施例中,基于图5所示实施例,该装置应用于客户端,客户端的安装文件采用以下操作得到:
获取根据所述客户端的原始代码生成的初始安装文件,获取所述客户端的原始代码中的运算函数;
去除所述初始安装文件中除所述原始代码中的运算函数之外的运算函数,得到所述客户端的安装文件。
由于上述装置实施例是基于方法实施例得到的,与该方法具有相同的技术效果,因此装置实施例的技术效果在此不再赘述。对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。
图8为本申请实施例提供的电子设备的一种结构示意图。该电子设备包 括处理器401、通信接口402、存储器403和通信总线404,其中,处理器401,通信接口402,存储器403通过通信总线404完成相互间的通信;
存储器403,用于存放计算机程序;
处理器401,用于执行存储器403上所存放的程序时,实现本申请实施例提供的输入预测方法。该方法包括:
获取输入的当前文本;
从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
上述电子设备提到的通信总线404可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。该通信总线404可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
通信接口402用于上述电子设备与其他设备之间的通信。
存储器403可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器403还可以是至少一个位于远离前述处理器的存储装置。
上述处理器401可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组 件。
可见,本实施例可以从缓存中获取第一文本的状态参量,将当前文本和第一文本的状态参量均输入循环神经网络,由循环神经网络根据第一文本的状态参量确定当前文本的状态参量,并根据当前文本的状态参量从词汇库中确定当前文本的预测文本。本实施例在确定当前文本的预测文本时,无需由循环神经网络根据第一文本的前一文本的状态参量确定第一文本的状态参量,而是直接从缓存中获取第一文本的状态参量即可,因此能够减少确定预测文本的耗费时间,能提高用户体验。
本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现本申请实施例提供的输入预测方法。该方法包括:
获取输入的当前文本;
从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
可见,本实施例可以从缓存中获取第一文本的状态参量,将当前文本和第一文本的状态参量均输入循环神经网络,由循环神经网络根据第一文本的状态参量确定当前文本的状态参量,并根据当前文本的状态参量从词汇库中确定当前文本的预测文本。本实施例在确定当前文本的预测文本时,无需由循环神经网络根据第一文本的前一文本的状态参量确定第一文本的状态参量,而是直接从缓存中获取第一文本的状态参量即可,因此能够减少确定预测文本的耗费时间,能提高用户体验。
本发明实施例还提供了一种应用程序,该应用程序用于在运行时执行本申请实施例提供的输入预测方法。该应用程序被处理器执行时实现以下步骤:
获取输入的当前文本;
从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
可见,本发明实施例所提供的方案中,应用程序被处理器执行时,可以从缓存中获取第一文本的状态参量,将当前文本和第一文本的状态参量均输入循环神经网络,由循环神经网络根据第一文本的状态参量确定当前文本的状态参量,并根据当前文本的状态参量从词汇库中确定当前文本的预测文本。本实施例在确定当前文本的预测文本时,无需由循环神经网络根据第一文本的前一文本的状态参量确定第一文本的状态参量,而是直接从缓存中获取第一文本的状态参量即可,因此能够减少确定预测文本的耗费时间,能提高用户体验。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。
以上所述仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内所做的任何修改、等同替换、改进等,均包含在本申请的保护范围内。

Claims (15)

  1. 一种输入预测方法,其特征在于,所述方法包括:
    获取输入的当前文本;
    从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
    将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
    根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
  2. 根据权利要求1所述的方法,其特征在于,在确定所述当前文本的状态参量之后,所述方法还包括:
    将所述当前文本的状态参量保存在缓存中。
  3. 根据权利要求1所述的方法,其特征在于,所述根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本的步骤,包括:
    根据所述当前文本的状态参量,确定所述词汇库中各个词汇的词汇评分;
    根据各个词汇评分,从所述词汇库的各个词汇中选择目标词汇;
    根据各个目标词汇,确定所述当前文本的预测文本。
  4. 根据权利要求3所述的方法,其特征在于,所述根据各个目标词汇,确定所述当前文本的预测文本的步骤,包括:
    将所述当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的所述字典库中的语素作为与所述当前文本相近的待选语素;所述字典库用于存储多个语素;
    获取对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分;
    从对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分中,确定各个待选语素的评分;
    根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择所述当前文本的预测文本。
  5. 根据权利要求1所述的方法,其特征在于,所述循环神经网络,根据所述第一状态参量确定所述当前文本的状态参量时,包括:
    根据所述循环神经网络作业时的网络参数以及所述第一状态参量,确定所述当前文本的状态参量;
    其中,所述循环神经网络作业时的网络参数采用以下方式得到:
    获取所述循环神经网络训练完成时的网络参数;
    对所述训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为所述循环神经网络作业时的网络参数。
  6. 根据权利要求1所述的方法,其特征在于,所述方法应用于客户端,所述客户端的安装文件采用以下方式得到:
    获取根据所述客户端的原始代码生成的初始安装文件,获取所述客户端的原始代码中的运算函数;
    去除所述初始安装文件中除所述原始代码中的运算函数之外的运算函数,得到所述客户端的安装文件。
  7. 一种输入预测装置,其特征在于,所述装置包括:
    文本获取模块,用于获取输入的当前文本;
    参量获取模块,用于从缓存中获取第一文本的第一状态参量;其中,所述第一文本为所述当前文本的前一文本;所述第一状态参量为:预设的循环神经网络根据所述第一文本的前一文本的状态参量和所述第一文本确定;所 述循环神经网络为根据预设的词汇库训练完成;所述词汇库用于存储各个词汇;
    参量确定模块,用于将所述当前文本和所述第一状态参量均输入所述循环神经网络,由所述循环神经网络根据所述第一状态参量确定所述当前文本的状态参量;
    文本预测模块,用于根据当前文本的状态参量,从所述词汇库中确定所述当前文本的预测文本。
  8. 根据权利要求7所述的装置,其特征在于,所述装置还包括:
    参量缓存模块,用于在确定所述当前文本的状态参量之后,将所述当前文本的状态参量保存在缓存中。
  9. 根据权利要求7所述的装置,其特征在于,所述文本预测模块,包括:
    第一确定子模块,用于根据所述当前文本的状态参量,确定所述词汇库中各个词汇的词汇评分;
    选择子模块,用于根据各个词汇评分,从所述词汇库的各个词汇中选择目标词汇;
    第二确定子模块,用于根据各个目标词汇,确定所述当前文本的预测文本。
  10. 根据权利要求9所述的装置,其特征在于,所述第二确定子模块,具体用于:
    将所述当前文本分别与预设的字典库中的语素进行匹配,将匹配成功的所述字典库中的语素作为与所述当前文本相近的待选语素;所述字典库用于存储多个语素;
    获取对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇评分;
    从对所述第一文本进行输入预测时确定的所述词汇库中各个词汇的词汇 评分中,确定各个待选语素的评分;
    根据各个目标词汇的词汇评分以及各个待选语素的评分,从各个目标词汇以及各个待选语素中选择所述当前文本的预测文本。
  11. 根据权利要求7所述的装置,其特征在于,所述循环神经网络,根据所述第一状态参量确定所述当前文本的状态参量时,包括:
    根据所述循环神经网络作业时的网络参数以及所述第一状态参量,确定所述当前文本的状态参量;
    其中,所述循环神经网络作业时的网络参数采用以下操作得到:
    获取所述循环神经网络训练完成时的网络参数;
    对所述训练完成时的网络参数中的小数型参数进行整数近似处理,将得到的处理后的网络参数作为所述循环神经网络作业时的网络参数。
  12. 根据权利要求7所述的装置,其特征在于,所述装置应用于客户端,所述客户端的安装文件采用以下操作得到:
    获取根据所述客户端的原始代码生成的初始安装文件,获取所述客户端的原始代码中的运算函数;
    去除所述初始安装文件中除所述原始代码中的运算函数之外的运算函数,得到所述客户端的安装文件。
  13. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;
    存储器,用于存放计算机程序;
    处理器,用于执行存储器上所存放的程序时,实现权利要求1-6任一所述的方法步骤。
  14. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-6任一所述的方法步骤。
  15. 一种应用程序,其特征在于,所述应用程序用于在运行时执行权利要求1-6任一项所述的方法步骤。
PCT/CN2019/091755 2018-06-28 2019-06-18 一种输入预测方法及装置 WO2020001329A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/761,216 US11409374B2 (en) 2018-06-28 2019-06-18 Method and device for input prediction

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810691065.3 2018-06-28
CN201810691065.3A CN109002186B (zh) 2018-06-28 2018-06-28 一种输入预测方法及装置

Publications (1)

Publication Number Publication Date
WO2020001329A1 true WO2020001329A1 (zh) 2020-01-02

Family

ID=64601806

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/091755 WO2020001329A1 (zh) 2018-06-28 2019-06-18 一种输入预测方法及装置

Country Status (3)

Country Link
US (1) US11409374B2 (zh)
CN (1) CN109002186B (zh)
WO (1) WO2020001329A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109002186B (zh) 2018-06-28 2020-12-25 北京金山安全软件有限公司 一种输入预测方法及装置
CN109858004B (zh) * 2019-02-12 2023-08-01 四川无声信息技术有限公司 文本改写方法、装置及电子设备
US11554322B2 (en) * 2019-04-26 2023-01-17 Sony Interactive Entertainment LLC Game controller with touchpad input
CN110187780B (zh) * 2019-06-10 2023-07-21 北京百度网讯科技有限公司 长文本预测方法、装置、设备和存储介质
WO2021112491A1 (en) * 2019-12-04 2021-06-10 Samsung Electronics Co., Ltd. Methods and systems for predicting keystrokes using a unified neural network
US20230289524A1 (en) * 2022-03-09 2023-09-14 Talent Unlimited Online Services Private Limited Articial intelligence based system and method for smart sentence completion in mobile devices

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20170081887A (ko) * 2016-01-05 2017-07-13 한국전자통신연구원 인공 신경망에서 컨벌루션을 이용한 최종 정답 결정 방법
CN107578106A (zh) * 2017-09-18 2018-01-12 中国科学技术大学 一种融合单词语义知识的神经网络自然语言推理方法
CN107621891A (zh) * 2017-09-28 2018-01-23 北京新美互通科技有限公司 一种文本输入方法、装置及电子设备
CN109002186A (zh) * 2018-06-28 2018-12-14 北京金山安全软件有限公司 一种输入预测方法及装置

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080126092A1 (en) * 2005-02-28 2008-05-29 Pioneer Corporation Dictionary Data Generation Apparatus And Electronic Apparatus
CN104331437B (zh) * 2014-10-24 2017-11-17 百度在线网络技术(北京)有限公司 生成图片描述信息的方法和装置
CN107850939A (zh) * 2015-03-10 2018-03-27 艾弗里协助通信有限公司 用于通过眼睛反馈实现通信的系统和方法
US10268671B2 (en) * 2015-12-31 2019-04-23 Google Llc Generating parse trees of text segments using neural networks
CN109074517B (zh) * 2016-03-18 2021-11-30 谷歌有限责任公司 全局归一化神经网络
CN107704482A (zh) * 2016-08-09 2018-02-16 松下知识产权经营株式会社 方法、装置以及程序
US11069335B2 (en) * 2016-10-04 2021-07-20 Cerence Operating Company Speech synthesis using one or more recurrent neural networks
US20180174576A1 (en) * 2016-12-21 2018-06-21 Google Llc Acoustic-to-word neural network speech recognizer
WO2018195459A1 (en) * 2017-04-20 2018-10-25 Google Llc Processing sequential data using recurrent neural networks
US10380236B1 (en) * 2017-09-22 2019-08-13 Amazon Technologies, Inc. Machine learning system for annotating unstructured text
CN107705784B (zh) * 2017-09-28 2020-09-29 百度在线网络技术(北京)有限公司 文本正则化模型训练方法和装置、文本正则化方法和装置
CN107704102B (zh) * 2017-10-09 2021-08-03 北京新美互通科技有限公司 一种文本输入方法及装置
CN108062388B (zh) * 2017-12-15 2021-09-17 北京百度网讯科技有限公司 人机对话的回复生成方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20170081887A (ko) * 2016-01-05 2017-07-13 한국전자통신연구원 인공 신경망에서 컨벌루션을 이용한 최종 정답 결정 방법
CN107578106A (zh) * 2017-09-18 2018-01-12 中国科学技术大学 一种融合单词语义知识的神经网络自然语言推理方法
CN107621891A (zh) * 2017-09-28 2018-01-23 北京新美互通科技有限公司 一种文本输入方法、装置及电子设备
CN109002186A (zh) * 2018-06-28 2018-12-14 北京金山安全软件有限公司 一种输入预测方法及装置

Also Published As

Publication number Publication date
CN109002186A (zh) 2018-12-14
US11409374B2 (en) 2022-08-09
US20210405765A1 (en) 2021-12-30
CN109002186B (zh) 2020-12-25

Similar Documents

Publication Publication Date Title
WO2020001329A1 (zh) 一种输入预测方法及装置
CN107836000B (zh) 用于语言建模和预测的改进的人工神经网络方法、电子设备
CN108846077B (zh) 问答文本的语义匹配方法、装置、介质及电子设备
US11693894B2 (en) Conversation oriented machine-user interaction
Fowler et al. Effects of language modeling and its personalization on touchscreen typing performance
WO2020147428A1 (zh) 交互内容生成方法、装置、计算机设备及存储介质
CN107506047B (zh) 用于向电子设备输入文本的文本预测引擎、系统及方法
WO2020233380A1 (zh) 缺失语义补全方法及装置
CN112100354B (zh) 人机对话方法、装置、设备及存储介质
CN110019732B (zh) 一种智能问答方法以及相关装置
CN110717034A (zh) 一种本体构建方法及装置
CN111951805A (zh) 一种文本数据处理方法及装置
CN108763535B (zh) 信息获取方法及装置
CN110532354B (zh) 内容的检索方法及装置
US11238050B2 (en) Method and apparatus for determining response for user input data, and medium
CN109710732B (zh) 信息查询方法、装置、存储介质和电子设备
CN108345612B (zh) 一种问题处理方法和装置、一种用于问题处理的装置
CN112560452B (zh) 一种自动生成纠错语料的方法和系统
WO2021129411A1 (zh) 文本处理方法及装置
CN112699686A (zh) 基于任务型对话系统的语义理解方法、装置、设备及介质
EP3992814A2 (en) Method and apparatus for generating user interest profile, electronic device and storage medium
CN114144774A (zh) 问答系统
CN110750967B (zh) 一种发音的标注方法、装置、计算机设备和存储介质
CN113705207A (zh) 语法错误识别方法及装置
CN108845682B (zh) 一种输入预测方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19825113

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19825113

Country of ref document: EP

Kind code of ref document: A1