An input recommendation method, apparatus, electronic device, and storage medium
By using a combination of a preset dictionary and a syllable segmentation network in the input method application, the problem of inaccurate long sentence recommendations in the input method application is solved, and efficient and accurate input recommendations are achieved on low-resource devices.
Patent Information
- Application Number
- CN202211247166.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-12
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-10-12
AI Technical Summary
Existing input method applications are not very accurate in recommending long sentences, requiring users to make multiple modifications to obtain the desired recommended words, which affects input efficiency.
By obtaining the pinyin string, word grouping and syllable segmentation are performed using a preset dictionary and syllable segmentation network. Recommended entries are generated by combining the word prediction network and a lightweight convolutional module is used to extract features to improve accuracy.
It improves the accuracy and efficiency of input recommendations without increasing computing resource consumption, and is suitable for low-resource devices such as smartphones.
Smart Images

Figure CN117009495B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to an input recommendation method, apparatus, electronic device, and storage medium. Background Art
[0002] With the development of computer technology, users can conveniently input information through the input method application program running on the mobile terminal. Usually, the input method application program can give corresponding recommended entries based on the pinyin string input by the user.
[0003] In the related art, the accuracy of the input method application program in long sentence recommendation is poor. For example, when the user inputs "kaorouchuanzenmeyan" in the input method application program of the mobile terminal, the expected recommended entry is "How to marinate grilled meat skewers", but the results given in the related art are as Figure 1 shown. To obtain the expected result, the user needs to directly select "How to perform grilled meat skewers" on the screen and then modify the Chinese character "perform" to "marinate", which greatly affects the input efficiency. Summary of the Invention
[0004] To solve the problems of the prior art, embodiments of this application provide an input recommendation method, apparatus, electronic device, and storage medium. The technical solutions are as follows:
[0005] On the one hand, an input recommendation method is provided. The method includes:
[0006] Obtain the input pinyin string, and determine the number of preset words in the preset word library that the pinyin string hits;
[0007] In the case where the number of the preset words that hit does not exceed the preset quantity threshold, perform word formation processing on the pinyin string based on the preset word library to obtain a candidate entry set;
[0008] Input the pinyin string into a syllable segmentation network for syllable segmentation processing to obtain a predicted syllable sequence corresponding to the pinyin string; the syllable segmentation network extracts features for syllable segmentation processing from the pinyin string based on a lightweight convolution module;
[0009] Input the predicted syllable sequence into an entry prediction network for entry prediction to obtain a predicted entry set;
[0010] Based on the candidate entry set and the predicted entry set, output a recommended entry.
[0011] On the other hand, an input recommendation apparatus is provided. The apparatus includes:
[0012] The Pinyin acquisition module is used to acquire the input Pinyin string and determine the number of preset words that the Pinyin string matches in the preset word library;
[0013] The word grouping module is used to perform word grouping on the pinyin string based on the preset word library when the number of hit preset words does not exceed the preset number threshold, so as to obtain a set of candidate words.
[0014] The syllable segmentation module is used to input the pinyin string into the syllable segmentation network for syllable segmentation processing to obtain the predicted syllable sequence corresponding to the pinyin string; the syllable segmentation network extracts features for syllable segmentation processing from the pinyin string based on a lightweight convolutional module;
[0015] The term prediction module is used to input the predicted syllable sequence into the term prediction network to predict terms and obtain a set of predicted terms.
[0016] The recommended term output module is used to output recommended terms based on the candidate term set and the predicted term set.
[0017] In one exemplary embodiment, the syllable segmentation module includes:
[0018] A pinyin preprocessing module is used to convert the pinyin string into a letter sequence;
[0019] The feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network for feature extraction to obtain the target feature vector; the target feature vector represents the feature vector at the corresponding position of each letter in the letter sequence;
[0020] The syllable probability distribution determination module is used to obtain the syllable probability distribution at the corresponding position of each letter in the letter sequence based on the product of the target feature vector and the preset syllable table; the preset syllable table includes vector representations of multiple preset syllables;
[0021] The predicted syllable information determination module is used to predict the predicted syllable information at the corresponding positions of each letter in the letter sequence based on the syllable probability distribution at each position of each letter in the letter sequence;
[0022] The syllable segmentation module is used to segment syllables based on the predicted syllable information at the corresponding positions of each letter in the letter sequence, and obtain a predicted syllable sequence.
[0023] In one exemplary embodiment, the feature extraction module includes:
[0024] An effective feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network, and perform effective feature extraction based on the gated linear units of the lightweight convolutional module to obtain effective feature information;
[0025] The convolution module is used to perform channel-wise convolution on the effective feature information based on the lightweight convolution unit of the lightweight convolution module, and to perform point-wise convolution on the convolution result of the channel-wise convolution to obtain the target feature vector.
[0026] In one exemplary implementation, the term prediction module includes:
[0027] The encoding module is used to input the predicted syllable sequence into the encoding unit of the word prediction network for encoding processing to obtain the encoding vector;
[0028] The term length prediction module is used to predict the term length based on the encoding vector using the term length prediction unit of the term prediction network to obtain the predicted term length.
[0029] The decoding module is used to perform decoding processing based on the predicted term length and the encoding vector using the decoding unit of the term prediction network to obtain a decoding result; the decoding result indicates at least one predicted term and the prediction score corresponding to each predicted term.
[0030] In one exemplary embodiment, the recommended term output module includes:
[0031] The scoring module is used to obtain the word path score of each candidate word in the candidate word set in the word grouping process, and the prediction score of each predicted word in the predicted word set in the word prediction process.
[0032] The candidate recommended term set determination module is used to merge the candidate term set and the predicted term set and perform deduplication to obtain the candidate recommended term set;
[0033] The comprehensive score determination module is used to determine the comprehensive score of each candidate recommended term in the candidate recommended term set based on the word grouping path score and prediction score corresponding to the candidate recommended term.
[0034] The recommended term output submodule is used to output recommended terms based on the comprehensive score of each candidate recommended term in the candidate recommended term set.
[0035] In one exemplary implementation, the comprehensive score determination module includes:
[0036] The attribution set information determination module is used to determine the attribution set information of the candidate recommended terms;
[0037] The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended word based on the word grouping path score and prediction score corresponding to the candidate recommended word when the attribution set information indicates that it belongs to the candidate word set and the predicted word set.
[0038] The simulated score determination module is used to determine the statistical value of the corresponding score of each word in the non-attributed set as the simulated score of the candidate recommended word in the non-attributed set when the attribution set information indicates that it belongs to the candidate word set or the predicted word set;
[0039] The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended term based on the score corresponding to the candidate term in the home set and the simulated score corresponding to the candidate term in the non-home set.
[0040] In one exemplary embodiment, the word grouping processing module includes:
[0041] The candidate word determination module is used to determine, for at least one pinyin string corresponding to the pinyin string, a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string;
[0042] The vocabulary network construction module is used to construct a vocabulary network based on a set of candidate words corresponding to each syllable in the at least one pinyin string;
[0043] The candidate word determination module is used to determine the word formation path score of each combined word in the vocabulary network based on a preset statistical language algorithm, and to determine at least one candidate word from the combined words in the vocabulary network based on the word formation path score, thereby obtaining the candidate word set.
[0044] On the other hand, an electronic device is provided, including a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the input recommendation method of any of the above aspects.
[0045] On the other hand, a computer-readable storage medium is provided that stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the input recommendation method as described above.
[0046] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the input recommendation method described in either of the above aspects.
[0047] In this embodiment, when it is determined that the number of preset words matched by the input pinyin string in the preset word library does not exceed a preset threshold, the system performs word grouping processing on the pinyin string based on the preset word library to obtain a candidate word set. On the other hand, the pinyin string is input into a syllable segmentation network for syllable segmentation processing to obtain a predicted syllable sequence. The predicted syllable sequence is then input into a word prediction network for word prediction to obtain a predicted word set. Based on the candidate word set and the predicted word set, recommended words are output. Since the syllable segmentation network extracts features for syllable segmentation processing from the pinyin string based on a lightweight convolutional module, the above technical solution improves the accuracy of recommended words without consuming too much computing resources, ensuring accurate and efficient input recommendation. It is very suitable for input method recommendation on low-resource devices (such as smartphones). Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram illustrating the recommendation effect of input methods for long sentences in related technologies;
[0050] Figure 2 This is a flowchart illustrating an input recommendation method provided in an embodiment of this application;
[0051] Figure 3 This is a specific example of the vocabulary network construction provided in the embodiments of this application;
[0052] Figure 4 This is a specific example of the word grouping process provided in the embodiments of this application;
[0053] Figure 5 This is a schematic diagram of the lightweight convolution module provided in an embodiment of this application;
[0054] Figure 6 This is a schematic diagram of syllable segmentation based on a syllable segmentation network provided in an embodiment of this application;
[0055] Figure 7 This is an example of a term prediction network provided in the embodiments of this application;
[0056] Figure 8 This is a specific process example provided in the embodiments of this application for transforming an input pinyin string into a predicted word set;
[0057] Figure 9 This is a schematic diagram of a process for outputting recommended terms based on a candidate term set and the aforementioned predicted term set, provided in an embodiment of this application.
[0058] Figure 10 This is a schematic diagram of another process for outputting recommended terms based on the candidate term set and the above-mentioned predicted term set, provided by an embodiment of this application;
[0059] Figure 11 This is a schematic diagram of a system architecture for implementing an input recommendation method provided in an embodiment of this application;
[0060] Figure 12 This is an example of recommended terms output by the input recommendation method based on the embodiments of this application;
[0061] Figure 13 This is a structural block diagram of an input recommendation device provided in an embodiment of this application;
[0062] Figure 14 This is a hardware structure block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0063] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0064] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0065] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0066] The terminology used in the embodiments of this application will be explained below.
[0067] Long sentence input method: The number of characters in a word entered by the user at one time is greater than or equal to 5, or the word entered by the user is not in the system dictionary.
[0068] Intelligent word grouping: The input method intelligently generates words and sentences that do not exist in the current input method's dictionary through statistical language algorithms (such as N-Gram).
[0069] N-Gram: This algorithm is based on the assumption that the occurrence of the Nth word is only related to the preceding N-1 words and not to any other words. The probability of the entire sentence is the product of the probabilities of each word. These probabilities can be obtained by directly counting the number of times N words appear simultaneously in the corpus. Commonly used are the bigram (Bi-Gram) and the trigram (Tri-Gram).
[0070] The implementation environment of this application embodiment may include a terminal and a server, wherein the terminal and the server can communicate through a wired or wireless network connection.
[0071] Terminals include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, in-vehicle terminals, and aircraft. An input method application (App) runs on the terminal; this application can be a standalone application or a subroutine within an application.
[0072] The server can provide background services for input method applications in the terminal, such as providing a corresponding system dictionary. This system dictionary can include a system preset dictionary and a user dictionary. The user dictionary can store words used by the user within a preset time period. This preset time period can be set based on actual needs, such as the most recent week or the most recent month.
[0073] A server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0074] In one exemplary implementation, both the terminal and the server can be node devices in the blockchain system, capable of sharing acquired and generated information with other node devices in the blockchain system, thus enabling information sharing among multiple node devices. Multiple node devices in the blockchain system can be configured with the same blockchain, which consists of multiple blocks, and adjacent blocks are related, ensuring that any data tampering in any block can be detected by the next block. This prevents data tampering in the blockchain and guarantees the security and reliability of the data in the blockchain.
[0075] The embodiments of this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0076] Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that utilize digital computers or computers-controlled machines to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce new intelligent machines that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making capabilities.
[0077] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0078] Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0079] Please see Figure 2 The diagram illustrates a flowchart of an input recommendation method provided in this application, which can be applied to a terminal. It should be noted that this specification provides the operational steps of the method described in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many steps and does not represent the only execution order. In actual system or product execution, the method can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment) as shown in the embodiments or drawings. Specifically, as shown... Figure 2 As shown, the method may include:
[0080] S201, Obtain the input pinyin string and determine the number of preset words that the pinyin string matches in the preset word library.
[0081] The preset dictionary can include the system preset dictionary and the user dictionary corresponding to the current input method. The system preset dictionary stores the preset words that come with the input method system, and the user dictionary stores the words that the current user has used within a preset time period. The preset time period can be set according to actual needs, such as the most recent week or the most recent month.
[0082] In practice, when determining the number of preset words matched by a given pinyin string in the preset word library, the pinyin string can first be syllable-labeled to obtain the syllable-labeling results. Typically, a pinyin string corresponds to multiple syllable-labeling methods. For example, the pinyin string "xianta" can be labeled as "xi'an'ta" and "xian'ta". If the input method supports abbreviated pinyin, there are also corresponding abbreviated pinyin syllable-labeling methods, such as "pan" being labeled as "p'an". In other words, the above syllable-labeling results can include multiple syllable-labeling sub-results corresponding to multiple syllable-labeling methods.
[0083] Then, the syllables of the syllable annotation results are combined to generate different pinyin strings. Then, the preset words that each pinyin string matches are searched in the preset word library. In this way, the number of preset words that the input pinyin string matches in the preset word library can be obtained.
[0084] S203, determine whether the number of the preset words that were hit exceeds the preset number threshold.
[0085] Specifically, if the number of preset words matched by the input pinyin string in the preset word library does not exceed the preset number threshold, then steps S205 to S211 can be executed; conversely, if the number of preset words matched by the input pinyin string in the preset word library exceeds the preset number threshold, then step S213 can be executed.
[0086] The preset quantity threshold can be set based on practical experience. For example, the preset quantity threshold can be 2 or 5, etc. Taking a preset quantity threshold of 2 as an example, if the number of preset words matched by the input pinyin string in the preset word library does not exceed 2, steps S205 to S211 can be executed; otherwise, if it exceeds 2, step S213 can be executed.
[0087] S205, perform word grouping processing on the input pinyin string based on the preset dictionary to obtain a set of candidate words.
[0088] Specifically, if the number of preset words matched by the pinyin string does not exceed the preset threshold, proceed to step S205 for intelligent word grouping, that is, to process the pinyin string into a set of candidate words based on the preset word library.
[0089] In one exemplary embodiment, step S205 may include the following when implemented:
[0090] For at least one pinyin string corresponding to a pinyin string, determine a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library;
[0091] A vocabulary network is constructed based on a set of candidate words corresponding to each syllable in at least one pinyin string;
[0092] The word formation path score of each combined word in the above vocabulary network is determined based on the preset statistical language algorithm, and at least one candidate word is determined from the combined words in the vocabulary network based on the word formation path score, thus obtaining a set of candidate words.
[0093] Among them, at least one pinyin string corresponding to the pinyin string can be obtained by combining syllables based on the syllable annotation result of the concatenated string in the aforementioned step S201.
[0094] like Figure 3Shown is a specific example of constructing a lexical network. For the input pinyin string "dazhongguo", syllable annotation can obtain the syllable annotation result "da’zhong’guo". Syllable combination of this syllable annotation result can generate multiple pinyin strings such as dazhongguo, da’zhongguo, dazhong’guo, etc. Then, each pinyin string is mapped to a preset word library, that is, candidate words corresponding to each syllable in the pinyin string are searched in the preset word library. Usually, multiple candidate words can be found for one syllable in the preset word library. Especially, the number of words corresponding to a single syllable is the number of Chinese characters with this pronunciation. Even for a disyllable, there are often more than one corresponding word (for example, jiu’jiang can correspond to Jiujiang, former general, wine mash, etc.). For example Figure 3 For the pinyin string "dazhong’guo", the syllable "dazhong" can find a group of candidate words "dazhong" and "dazhong", so a lexical network can be constructed for the obtained multiple pinyin strings.
[0095] After constructing the lexical network, one or several paths from the starting point to the ending point can be found in the lexical network based on a preset statistical language algorithm, so that the quality of the long sentence corresponding to this one or several paths is the best. Among them, the preset statistical language algorithm can be N-Gram.
[0096] N-Gram is an algorithm based on a statistical language model. This model is based on such an assumption that the occurrence of the nth word is only related to the previous N - 1 words and has nothing to do with any other words. The probability of the whole sentence is the product of the occurrence probabilities of each word. These probabilities can be obtained by directly counting the number of times that N words appear simultaneously in the corpus. Commonly used are binary Bi-Gram and ternary Tri-Gram. Assuming the sentence S = w1w2w3…wi, the probability of this sentence appearing can be expressed as:
[0097] P(S) = p(w1)*p(w2|w1)*p(w3|w2)*…*p(w_i|w_i - 1)
[0098] Regarding the probability statistical method of word w, the sentence can be segmented first (the corpus is segmented at the word granularity according to a specific word list), and then the frequency is counted.
[0099] Taking the sentence "he|zai|heng'an" as an example, assume there is the following corpus:
[0100] Table 1 Frequency of occurrence of single words
[0101] he exist Hengan 300 1090 400
[0102] Table 2 Frequency of occurrence of word pairs
[0103] he exist Hengan he 10 100 20 exist 15 2 20 Hengan 5 7 0
[0104] In Table 1, the numbers represent the number of times the corresponding word appears in the corpus. For example, the word "he" appears 300 times in the corpus. Based on Table 1, the univariate probability can be calculated as follows: univariate probability PU(he) = uni_cnt(he) / uni_sum = 300 / 1790 = 16.76%, where uni_cnt(he) represents the number of times the word "he" appears in the corpus, i.e., 300, and uni_sum represents the total number of times all univariate words in the sentence appear, i.e., (300 + 1090 + 400).
[0105] In Table 2, the numbers represent the total number of times the word corresponding to the row and the word corresponding to the column appears in the corpus. For example, bi_cnt(he, in) means that the total number of times the word corresponding to the row and the word corresponding to the column appears in the corpus is 100. Based on Tables 1 and 2, the binary probability can be calculated, such as the binary probability PB(in, he) = bi_cnt(he, in) / uni_cnt(he) = 100 / 300 = 33.33%.
[0106] The probability of the sentence "He | is | Heng'an" is P(He, is, Heng'an) = p(He) * p(is | He) * p(Heng'an | is). In practical applications, univariate and binary probabilities can be transformed using Bayes' principle, and then the logarithmic probability value can be taken, converting the product of sentence probabilities into the sum of probabilities.
[0107] In specific implementation, when determining at least one candidate term based on the vocabulary network and N-Gram, a dynamic programming algorithm can be used to organize the nodes in the vocabulary network by columns. Each column of nodes can only be connected to nodes in adjacent columns and cannot be connected across columns. The value of a node is the unary probability calculated above. There are different distances between nodes, and the distance value is the binary probability calculated above. Then, the probability of each combined term is calculated, and a preset number of terms with the highest probabilities are selected as candidate terms. This preset number can be set according to actual needs, for example, the preset number can be 3.
[0108] by Figure 4 Taking the word grouping process shown as an example, we can obtain the word grouping path scores of the top 3 word combinations. Since the following example takes the logarithm of log0.985, the smaller the word grouping path score, the better. By reversing the order according to the word grouping path score, we can obtain the following 3 candidate words:
[0109] PL(He|in|Heng'an|Bar)=PU(He)+PB(He,in)+PU(in)+PB(in,Heng'an)+PU(Heng'an)+PB(Bar|Heng'an)+PU(Bar)=200+100+300+400+400+300+100=1800; Similarly, PL(She|in|Heng'an|Bar)=1900, PL(He|in|Hengan|Bar)=2500.
[0110] S207, The above pinyin string is input into the syllable segmentation network for syllable segmentation processing to obtain the predicted syllable sequence corresponding to the pinyin string.
[0111] The syllable segmentation network extracts features for syllable segmentation from the input pinyin string using lightweight convolutional modules.
[0112] The lightweight convolution module has a fixed context window. It uses a set of weights that remain constant over time to determine the importance of context elements. The number of parameters required scales linearly with the input length. The computational cost of the model is much less than that of the self-attention mechanism. It achieves similar results to the self-attention mechanism while ensuring low computational cost.
[0113] Figure 5 The diagram shows the structure of the lightweight convolution module, which consists of Linear, GLU, Linear, LConv, and Linear in sequence. Linear is a linear mapping layer used to map the input vector from dimension d to 2d. Then, Gated Linear Units (GLUs) are used to regulate the amount of information in the input, and a Linear linear mapping layer is connected to adjust the information dimension of the input to the subsequent lightweight convolution unit. After convolution processing by the Lightweight Convolution Unit (LConv), a Linear linear mapping layer is connected to map the dimension back to d. The Lightweight Convolution Unit (LConv) can be a depthwise separable convolution, that is, convolution is performed independently on each channel dimension.
[0114] Specifically, if the number of preset words matched by the pinyin string does not exceed the preset threshold, in addition to proceeding to step S205 for intelligent word grouping, steps S207 to S209 are also performed for word prediction.
[0115] In one exemplary embodiment, step S207 may include the following when implemented:
[0116] Convert a Pinyin string into a letter sequence;
[0117] The above letter sequence is input into the lightweight convolutional module of the syllable segmentation network for feature extraction to obtain the target feature vector; the target feature vector represents the feature vector at the corresponding position of each letter in the above letter sequence.
[0118] Based on the product of the target feature vector and the preset syllable table, the syllable probability distribution at the corresponding position of each letter in the above letter sequence is obtained; wherein, the preset syllable table includes vector representations of multiple preset syllables;
[0119] Based on the probability distribution of syllables at the corresponding positions of each letter in the letter sequence, predict the predicted syllable information at the corresponding positions of each letter in the letter sequence;
[0120] Syllable segmentation is performed based on the predicted syllable information at the corresponding positions of each letter in the letter sequence to obtain the predicted syllable sequence.
[0121] Specifically, the conversion process for a pinyin string can involve separating each letter in the pinyin string with a preset character, such as a space, to obtain a letter sequence. For example, if the input pinyin string is "wiqugao", the converted letter sequence will be "wiqugao".
[0122] Specifically, such as Figure 6 The diagram illustrates syllable segmentation based on a syllable segmentation network. This network can consist of multiple stacked lightweight convolutional modules. The output of one lightweight convolutional module serves as the input to the next, and the target feature vector is the output of the last module. The structure of each lightweight convolutional module can be found in [reference needed]. Figure 5 Based on this, in an exemplary embodiment, the process of inputting the letter sequence into the lightweight convolutional module of the syllable segmentation network for feature extraction to obtain the target feature vector may include:
[0123] The letter sequence is input into the lightweight convolutional module of the syllable segmentation network, and effective feature extraction is performed based on the gated linear units of the lightweight convolutional module to obtain effective feature information;
[0124] The lightweight convolutional unit based on the lightweight convolutional module performs channel-wise convolution on the effective feature information, and performs point-wise convolution on the convolution result of the channel-wise convolution to obtain the target feature vector.
[0125] Specifically, the syllable segmentation network processes the input letter sequence through an embedding layer to obtain the corresponding embedding vector representation. This embedding vector representation is then input into a lightweight convolutional module. The lightweight convolutional module first performs a dimensionality transformation on the embedding vector representation using a linear mapping layer. The transformed vector is then input into a gated linear unit to extract effective feature information. This effective feature information is then input into the lightweight convolutional unit for sequential channel-wise convolution and pointwise convolution to obtain the target feature vector. Channel-wise convolution means that one convolutional kernel is responsible for one channel, and each channel is convolved by only one convolutional kernel. Pointwise convolution means that the results of the channel-wise convolutions are fused using a 1*1 convolutional kernel.
[0126] Suppose the input vector to the gated linear unit (LLU) is X. The LLU performs two one-dimensional convolution operations on X with different parameters and the same width. Specifically, it can perform the following one-dimensional convolution on X based on convolution kernel 1 (parameter W1): conv1(X) = W1*X + B1, and perform the following one-dimensional convolution on X based on convolution kernel 2 (parameter W2): conv2(X) = W2*X + B2. Then, the output of one of the convolution kernels is normalized (e.g., using the Sigmoid function), and the normalized result is multiplied element-wise with the output of the other convolution kernel to obtain the effective feature information of the LLU output. For example, the output of the LLU = Sigmoid(conv1(X)) ⊙ conv2(X). The LLU can filter out redundant information in the input, thereby reducing the computational load and improving the accuracy of syllable segmentation.
[0127] In specific implementation, when predicting the predicted syllable information at each position of a letter in a letter sequence based on the syllable probability distribution at each position of the letter sequence, the maximum syllable probability can be found sequentially from the syllable probability distribution at each position according to the order of the letter sequence. Then, based on the syllables corresponding to the maximum syllable probability at each position, the predicted syllable information at each position is determined sequentially. When determining the predicted syllable information for each position based on the syllables corresponding to the maximum syllable probability at each position, we can first identify whether the letter at the current position is the first letter of a syllable of multiple preset syllables. If it is the first letter of a syllable, we determine the number of letters contained in the predicted syllable information corresponding to the previous position. If the number of letters contained in the predicted syllable information corresponding to the previous position is 1, then the syllable corresponding to the maximum syllable probability at the current position can be determined as the predicted syllable information for the current position. If the number of letters contained in the predicted syllable information corresponding to the previous position is more than 1, then a preset placeholder is determined as the predicted syllable information for the current position. If the letter at the current position is not the first letter of a syllable, then a preset placeholder is determined as the predicted syllable information for the current position.
[0128] by Figure 6 Taking the input letter sequence "wiqugao" as an example, assuming the probability distribution of the syllables corresponding to the letter w is P(wu) = 0.1, P(wa) = 0.02, P(wang) = 0.001, and P(wo) = 0.6, the maximum syllable probability can be determined as P(wo) = 0.6. Since the letter w is the first letter of the syllable and is located at the beginning of the sequence, the predicted syllable information corresponding to the letter w position can be determined as "wo". Since the letter i is not the first letter of the syllable, the predicted syllable information corresponding to the letter i position is the placeholder "O". And so on, the predicted syllable information at each letter position in the letter sequence is "wo O qu O gao OO". Then, the predicted syllable sequence obtained by syllable segmentation of the predicted syllable information at each letter position in the letter sequence is "wo'qu'gao".
[0129] The above implementation method can quickly and accurately obtain the predicted syllable sequence by performing syllable segmentation processing on the pinyin string through a syllable segmentation network.
[0130] S209, The above predicted syllable sequence is input into the word prediction network to predict words and obtain a set of predicted words.
[0131] Specifically, the word prediction network can generate all the words in a sentence independently at once, meaning that the words in the sentence are generated in parallel, which can greatly improve the efficiency of word prediction and is very suitable for implementation on low-resource devices (such as mobile terminals).
[0132] Therefore, in an exemplary embodiment, step S209 may include the following when implemented:
[0133] The predicted syllable sequence is input into the encoding unit of the word prediction network for encoding processing to obtain the encoding vector;
[0134] The term length prediction unit of the term prediction network is used to predict the term length based on the encoding vector, and the predicted term length is obtained.
[0135] The decoding unit of the term prediction network is used to perform decoding based on the predicted term length and the encoding vector to obtain the decoding result.
[0136] The decoding result indicates at least one predicted term and the prediction score corresponding to each predicted term.
[0137] Specifically, the predicted syllable sequence is input into the word prediction network. The word prediction network first determines the vector representation corresponding to the predicted syllable sequence through an embedding layer. The embedding layer can perform embedding processing on each predicted syllable to obtain the corresponding embedded syllable vector, and at the same time determine the position code of each predicted syllable in the predicted syllable sequence. The embedded syllable vector and position code of each predicted syllable are concatenated to obtain the syllable vector corresponding to each predicted syllable. Thus, the syllable vector sequence is the vector representation corresponding to the predicted syllable sequence.
[0138] Specifically, when using the decoding unit of the word prediction network to perform decoding processing based on the predicted word length and the encoding vector, the positional encoding sequence corresponding to the predicted syllable sequence can be adjusted based on the predicted word length so that the length of the adjusted positional encoding sequence is the length of the predicted word. Then, the adjusted positional encoding sequence and the aforementioned encoding vector are input into the decoder for decoding processing, so that the decoder can output the predicted words that are consistent with the length of the positional encoding sequence.
[0139] In practical applications, the decoder can output a preset number of predicted terms based on the prediction score, such as the top two predicted terms.
[0140] Figure 7The image shows an example of a word prediction network provided in this application embodiment. {e(x1),e(x2),e(x3)} represents the embedded syllable vector corresponding to each predicted syllable in the predicted syllable sequence {x1,x2,x3}, and {PE(1),PE(2),PE(3)} represents the positional encoding sequence corresponding to the predicted syllable sequence. The syllable vector at the corresponding position is obtained by concatenating the embedded syllable vector with the corresponding positional encoding. The syllable vector sequence is then input into the encoding unit 710 of the word prediction network 700 for encoding processing to obtain the encoding vector C. This encoding vector C is input into the decoding unit of the word prediction network 700. Unit 720, on the other hand, inputs to the word length prediction unit 730 of the word prediction network 700 to obtain a predicted word length of 4. This predicted word length is used to adjust the aforementioned positional encoding sequence {PE(1),PE(2),PE(3)} to obtain the positional encoding sequence {PE(1),PE(2),PE(3),PE(4)} of the predicted word length. This positional encoding sequence {PE(1),PE(2),PE(3),PE(4)} is further input to the decoding unit 730 and decoded in combination with the aforementioned encoding vector C to obtain the output predicted word {y1,y2,y3,y4}. It should be noted that the words in this predicted word are generated in parallel, that is, based on a non-autoregressive decoding mechanism. Compared with the autoregressive decoding mechanism, the non-autoregressive decoding mechanism abandons the constraint of a specific generation order and generates all the words in the sentence independently at one time, alleviating the problems existing in the autoregressive decoding mechanism and improving the decoding efficiency by several times or even more than ten times.
[0141] It should be noted that both the syllable segmentation network and the word prediction network in this embodiment can be pre-trained using deep learning on a preset neural network. The training data for the syllable segmentation network may include sample pinyin strings and the corresponding reference syllable sequences, and the loss function used for training can be the cross-entropy loss function. The training data for the word prediction network may include sample syllable sequences, reference word lengths, and reference words. The losses during training include word length prediction loss and word prediction loss, and the calculation of each loss can utilize the cross-entropy loss function. The specific training processes for the syllable segmentation network and the word prediction network can be found in the descriptions in related technologies based on the corresponding training data, and will not be repeated here.
[0142] To facilitate understanding of steps S207 to S209 above, the following will be combined with... Figure 8 The specific example illustrates the entire process from the input pinyin string to the predicted word set.
[0143] like Figure 8As shown, the pinyin string input based on the input method is "wiqugaob", which is converted into the letter sequence "wiqugaob" through data preprocessing. The letter sequence is input into the syllable segmentation network for processing to obtain the predicted syllable information "wo O qu O gao OO ba" at the corresponding positions of each letter. Then, syllable segmentation is performed on "wo O qu O gao OO ba" to obtain the predicted syllable sequence "wo’qu’gao’ba". This predicted syllable sequence "wo’qu’gao’ba" is used as the input of the entry prediction network, and the entry prediction network performs entry prediction based on the non-autoregressive decoding mechanism, predicting two entries "我去搞吧" and "我去告吧". Finally, the entry prediction network outputs the entry "我去搞吧" with the highest probability result.
[0144] In the above implementation, end-to-end entry prediction is achieved. Since the syllable segmentation network is a lightweight network and the entry prediction network is based on the non-autoregressive decoding mechanism, the computational complexity of end-to-end entry prediction is greatly reduced, which is beneficial to improving the input efficiency of long sentences on low-resource devices (such as smartphones) and enhancing the user experience.
[0145] S211, based on the above candidate entry set and the above predicted entry set, output recommended entries.
[0146] Among them, the number of output recommended entries can be set based on actual experience. For example, it can be set to no more than 4 or 5, etc.
[0147] In an exemplary implementation, in order to further improve the accuracy of the output recommended entries, step S211 can include the following steps when implemented Figure 9 as follows:
[0148] S901, obtain the word formation path scores of each candidate entry in the candidate entry set during word formation processing, and the prediction scores of each predicted entry in the predicted entry set during entry prediction processing.
[0149] S903, merge the candidate entry set and the predicted entry set and perform deduplication processing to obtain a candidate recommended entry set.
[0150] S905, for each candidate recommended entry in the candidate recommended entry set, determine the comprehensive score of the candidate recommended entry based on the word formation path score and the prediction score corresponding to the candidate recommended entry.
[0151] Specifically, corresponding weight coefficients can be assigned to the candidate entry set and the predicted entry set, and then the word formation path scores and prediction scores corresponding to each candidate recommended entry are weighted and summed in combination with the weight coefficients to obtain the comprehensive scores of each candidate recommended entry.
[0152] For example, if the weight coefficient corresponding to the candidate term set is a and the weight coefficient corresponding to the predicted term set is b (where a+b=1), and assuming that the word path score corresponding to the candidate recommended term is S1 and the prediction score is S2, then the comprehensive score of the candidate recommended term is S=a*S1+b*S2.
[0153] Considering that in practical applications, the candidate term set and the predicted term set are not the same, that is, a certain predicted term is not a candidate term, in order to improve the accuracy of the comprehensive score corresponding to each candidate recommended term and further improve the accuracy of the subsequent output recommended terms, in an exemplary embodiment, the above step S905, when determining the comprehensive score of the candidate recommended term based on the word path score and the prediction score corresponding to the candidate recommended term, may include Figure 10 The following steps are included:
[0154] S1001, determine the set information to which the candidate recommended term belongs.
[0155] The attribution set information for candidate recommended terms indicates whether the candidate recommended term exists in both the candidate term set and the predicted term set. If it does not exist in both sets simultaneously, it further indicates which set it belongs to. For example, the attribution set information can be "0" to indicate belonging to both the candidate term set and the predicted term set, "1" to indicate belonging to the candidate term set, and "2" to indicate belonging to the predicted term set.
[0156] Specifically, if the attribution set information indicates that it belongs to both the candidate word set and the predicted word set, then it means that the candidate recommended word has both a corresponding word grouping path score and a corresponding prediction score, and the following step S1003 can be executed; if the attribution set information indicates that it belongs to either the candidate word set or the predicted word set, then the following steps S1005 to S1007 can be executed.
[0157] S1003. Based on the word path score and prediction score corresponding to the candidate recommended words, determine the comprehensive score of the candidate recommended words.
[0158] Specifically, the comprehensive score can be calculated directly based on the word path score and prediction score corresponding to the candidate recommended words.
[0159] S1005, the statistical values of the corresponding scores of each term in the non-belonging set are determined as the simulated scores of the candidate recommended terms in the non-belonging set.
[0160] The non-attached set is the set mentioned above that does not contain the candidate recommended term. For example, if the attribution set information indicates that it belongs to the candidate term set, then the non-attached set is the predicted term set; conversely, if the attribution set information indicates that it belongs to the predicted term set, then the non-attached set is the candidate term set.
[0161] The statistical value can be the average score of each term in the non-attributed set. That is, when the non-attributed set is the predicted term set, the statistical value is the average predicted score of each term in the predicted term set; when the non-attributed set is the candidate term set, the statistical value is the average score of each term in the candidate term set.
[0162] Since the candidate recommended term does not exist in the non-attributed set, the calculated statistical value can be considered as the score of the candidate recommended term in that non-attributed set. For example, if the non-attributed set of the candidate recommended term is the predicted term set, the corresponding statistical value can be considered as the predicted score of the candidate recommended term; if the non-attributed set of the candidate recommended term is the candidate term set, the corresponding statistical value can be considered as the word formation path score of the candidate recommended term.
[0163] S1007. Based on the scores of the candidate recommended terms in the home set and the simulated scores in the non-home set, determine the comprehensive score of the candidate recommended terms.
[0164] For example, if the set to which a candidate recommended term belongs is the set of predicted terms, then the comprehensive score of the candidate recommended term can be calculated based on its corresponding predicted score and simulated score. Alternatively, the comprehensive score can be calculated based on the weight coefficients of the two sets and combined with the predicted score and simulated score.
[0165] S907: Based on the comprehensive score of each candidate recommended term in the candidate recommended term set, output recommended terms.
[0166] Specifically, candidate recommended terms whose comprehensive scores meet preset conditions can be selected as recommended terms for output. For example, if a lower comprehensive score is better, then the candidate recommended terms can be sorted in ascending order based on the comprehensive score, and then a preset number of the top-ranked terms can be selected as recommended terms for output; conversely, if a higher comprehensive score is better, then the candidate recommended terms can be sorted in descending order based on the comprehensive score, and then a preset number of the top-ranked terms can be selected as recommended terms for output. The preset number can be set based on practical experience. In practical applications, how to select recommended terms from the candidate recommended term set based on the comprehensive score can be based on the actual representation method of the comprehensive score, and this application embodiment does not specifically limit this.
[0167] To more clearly illustrate the process of determining recommended terms in step S211 above, a specific example is given below.
[0168] Assuming the input pinyin string is "kaorouchuanzenmeyan", the candidate word set obtained from the word grouping process in step S205 above, and the word grouping path score of each candidate word (the lower the score, the better), are as follows:
[0169] How to cook kebabs 2464; How to inspect kebabs 2553; How to marinate kebabs 2622.
[0170] The predicted term set and the prediction score (the lower the score, the better) obtained from steps S207 to S209 are as follows:
[0171] How to marinate meat skewers (1266); How to inspect meat skewers (1839).
[0172] Furthermore, the candidate recommended term set is {how to marinate kebabs, how to verify kebabs, how to perform kebabs}. Assuming the weight coefficients of the candidate term set and the predicted term set are 0.3 and 0.7 respectively, then a comprehensive score is calculated for each candidate recommended term in the candidate recommended term set {how to marinate kebabs, how to verify kebabs, how to perform kebabs}:
[0173] Regarding how to marinate kebabs: its overall score = 2622*0.3 + 1266*0.7 = 1672;
[0174] How to check the quality of barbecue skewers: The overall score = 2553 * 0.3 + 1839 * 0.7 = 2053;
[0175] For "How to perform kebabs": Since the term is not in the predicted term set, we need to calculate the simulated score of the predicted term set corresponding to "How to perform kebabs" = (1266+1839) / 2 = 1552, and then its comprehensive score = 2464*0.3+(1266+1839) / 2*0.7 = 1825.
[0176] Therefore, when outputting recommended terms, the best candidate term, "how to marinate kebabs," can be selected based on the overall score. Understandably, multiple candidate terms can also be output based on the overall score; for example, both "how to marinate kebabs" and "how to cook kebabs" can be output as recommended terms for the user to choose from.
[0177] S213, output the preset words that the Pinyin string matches in the preset word library.
[0178] As can be seen from the above technical solutions of the embodiments of this application, the embodiments of this application enhance the word generation capability by integrating a lightweight non-autoregressive end-to-end (lite-nat) word prediction path on the basis of word grouping processing (such as word grouping processing based on Ngram). While improving the accuracy of recommended words, it does not cause excessive consumption of computing resources, ensuring the accuracy and efficiency of input recommendation. It is very suitable for input method input recommendation on low-resource devices (such as smartphones).
[0179] Please see Figure 11 The diagram illustrates a system architecture for implementing an input recommendation method according to an embodiment of this application, including a syllable segmentation module, a candidate recall module, and a candidate display module. The syllable segmentation module comprises a traditional syllable segmentation module and a syllable segmentation network. The traditional syllable segmentation module segments the pinyin string according to syllables after annotation. The candidate recall module includes N-Gram-based word grouping processing and a word prediction network based on a non-autoregressive decoding mechanism. The candidate display module sorts the candidate word set obtained from word grouping processing and the word prediction set obtained from the word prediction network, and selects recommended words for output. The syllable segmentation network and the word prediction network form an end-to-end word prediction model, meaning that the task of feature extraction is delegated to the word prediction model. The original data or slightly preprocessed data is directly input, allowing the word prediction model to perform feature extraction and output the final result. For example, the above end-to-end solution can be a pipeline architecture (e.g., ...). Figure 11 As shown in the figure, the process is as follows: Pinyin input --> Pinyin syllable segmentation --> Syllable and word non-autoregressive decoding. This scheme greatly reduces the computational load of end-to-end generation by introducing a non-autoregressive decoding mechanism. By sorting and fusing the word grouping processing results and the end-to-end generation results, the recommended words can be output, which can significantly reduce the error rate of offline long sentence generation and improve the user's offline long sentence input experience.
[0180] Figure 12 This is an example of recommended terms output by the input recommendation method based on the embodiments of this application. It can be seen that the input recommendation method of this application can accurately recommend long sentences, even when the network signal is poor.
[0181] It should be noted that, in order to improve the efficiency of long sentence recommendation on low-resource devices in this application embodiment, the parameters of the syllable segmentation network and the word prediction network in the above system architecture can be quantized parameters to further reduce the computational resource consumption of the end-to-end word prediction model. Quantization can be achieved by compressing floating-point parameters to numerical values, for example, using Int8 compression. Int8 compression refers to compressing the model parameters from float32 (i.e., each parameter occupies 32 bits) to Int8 (i.e., each parameter occupies 8 bits). In specific implementations, int8 compression can employ a symmetric quantization algorithm. The conversion between the original floating-point precision data and the quantized INT8 data is as follows:
[0182] Int8=round(Float32 / scale); Float32=scale*int8;
[0183] Here, scale is the quantization scaling factor. The default value for scale is float32 floating-point number. In order to represent positive and negative numbers, int uses the signed int8 numeric type.
[0184] scale = (2max(X_min, X_max)) / (Q_min - Q_max), where X is the float32 value to be scaled, Q is the int8 quantized value, Q_min = -128, and Q_max = 127. Detailed compression processing steps can be found in relevant technical descriptions and will not be repeated here.
[0185] Corresponding to the input recommendation methods provided in the above embodiments, this application also provides an input recommendation device. Since the input recommendation device provided in this application corresponds to the input recommendation methods provided in the above embodiments, the implementation methods of the aforementioned input recommendation methods are also applicable to the input recommendation device provided in this embodiment, and will not be described in detail in this embodiment.
[0186] Please see Figure 13 The diagram shown is a structural schematic of an input recommendation device provided in an embodiment of this application. This device has the function of implementing the input recommendation device method in the above-described method embodiments. This function can be implemented in hardware or by hardware executing corresponding software. Figure 13 As shown, the input recommendation device 1300 may include:
[0187] The Pinyin acquisition module 1310 is used to acquire the input Pinyin string and determine the number of preset words matched by the Pinyin string in the preset word library;
[0188] The word grouping module 1320 is used to perform word grouping on the pinyin string based on the preset word library when the number of the hit preset words does not exceed the preset number threshold, so as to obtain a set of candidate words.
[0189] The syllable segmentation module 1330 is used to input the pinyin string into the syllable segmentation network for syllable segmentation processing to obtain the predicted syllable sequence corresponding to the pinyin string; the syllable segmentation network extracts features for syllable segmentation processing from the pinyin string based on a lightweight convolutional module;
[0190] The word prediction module 1340 is used to input the predicted syllable sequence into the word prediction network to predict words and obtain a set of predicted words.
[0191] The recommended term output module 1350 is used to output recommended terms based on the candidate term set and the predicted term set.
[0192] In one exemplary embodiment, the syllable segmentation module 1330 includes:
[0193] The Pinyin preprocessing module is used to convert the Pinyin string into a letter sequence;
[0194] The feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network for feature extraction, and obtain the target feature vector; the target feature vector represents the feature vector at the corresponding position of each letter in the letter sequence;
[0195] The syllable probability distribution determination module is used to obtain the syllable probability distribution at the corresponding position of each letter in the letter sequence based on the product of the target feature vector and the preset syllable table; the preset syllable table includes vector representations of multiple preset syllables;
[0196] The predicted syllable information determination module is used to predict the predicted syllable information at the corresponding positions of each letter in the letter sequence based on the syllable probability distribution at each position of each letter in the letter sequence.
[0197] The syllable segmentation module is used to segment syllables based on the predicted syllable information at the corresponding positions of each letter in the letter sequence, and obtain the predicted syllable sequence.
[0198] In one exemplary embodiment, the feature extraction module includes:
[0199] The effective feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network, and perform effective feature extraction based on the gated linear units of the lightweight convolutional module to obtain effective feature information;
[0200] The convolution module is used to perform channel-wise convolution on the effective feature information based on the lightweight convolution unit of the lightweight convolution module, and perform point-wise convolution on the convolution result of the channel-wise convolution to obtain the target feature vector.
[0201] In one exemplary embodiment, the term prediction module 1340 includes:
[0202] The encoding module is used to input the predicted syllable sequence into the encoding unit of the word prediction network for encoding processing to obtain the encoding vector;
[0203] The term length prediction module is used to predict the term length based on the encoding vector using the term length prediction unit of the term prediction network to obtain the predicted term length.
[0204] The decoding module is used to utilize the decoding unit of the term prediction network to perform decoding processing based on the predicted term length and the encoding vector to obtain a decoding result; the decoding result indicates at least one predicted term and the prediction score corresponding to each predicted term.
[0205] In one exemplary embodiment, the recommended term output module 1350 includes:
[0206] The scoring module is used to obtain the word path score of each candidate word in the candidate word set in the word grouping process, and the prediction score of each predicted word in the predicted word set in the word prediction process.
[0207] The candidate recommended term set determination module is used to merge the candidate term set and the predicted term set and perform deduplication to obtain the candidate recommended term set;
[0208] The comprehensive score determination module is used to determine the comprehensive score of each candidate recommended term in the candidate recommended term set based on the word grouping path score and prediction score corresponding to the candidate recommended term.
[0209] The recommended term output submodule is used to output recommended terms based on the comprehensive score of each candidate recommended term in the candidate recommended term set.
[0210] In one exemplary implementation, the comprehensive score determination module includes:
[0211] The attribution set information determination module is used to determine the attribution set information of the candidate recommended term;
[0212] The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended word based on the word path score and prediction score corresponding to the candidate recommended word when the attribution set information indicates that it belongs to the candidate word set and the predicted word set.
[0213] The simulated score determination module is used to determine the statistical value of the corresponding score of each word in the non-attached set as the simulated score of the candidate recommended word in the non-attached set when the attribution set information indicates that it belongs to the candidate word set or the predicted word set;
[0214] The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended term based on the score corresponding to the candidate term in the home set and the simulated score corresponding to the candidate term in the non-home set.
[0215] In one exemplary embodiment, the word grouping processing module 1320 includes:
[0216] The candidate word determination module is used to determine a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library for the at least one pinyin string; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string;
[0217] The vocabulary network construction module is used to construct a vocabulary network based on a set of candidate words corresponding to each syllable in the at least one pinyin string;
[0218] The candidate word determination module is used to determine the word formation path score of each combined word in the vocabulary network based on a preset statistical language algorithm, and to determine at least one candidate word from the combined words in the vocabulary network based on the word formation path score, thereby obtaining the candidate word set.
[0219] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0220] This application provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement any of the input recommendation methods provided in the above method embodiments.
[0221] Memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. Memory can primarily include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for the functions, etc.; the data storage area can store data created based on the use of the device, etc. Furthermore, memory can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory can also include a memory controller to provide the processor with access to the memory.
[0222] The methods and embodiments provided in this application can be executed in a computer terminal, server, or similar computing device; that is, the aforementioned electronic device may include a computer terminal, server, or similar computing device. Taking running on a terminal as an example... Figure 14 This is a hardware structure block diagram of a terminal running an input recommendation method provided in an embodiment of the present invention. Specifically:
[0223] The terminal may include an RF (Radio Frequency) circuit 1410, a memory 1420 including one or more computer-readable storage media, an input unit 1430, a display unit 1440, a sensor 1450, an audio circuit 1460, a WiFi (Wireless Fidelity) module 1470, a processor 1480 including one or more processing cores, and a power supply 1490, etc. Those skilled in the art will understand that... Figure 14 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0224] RF circuit 1410 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and hands it over to one or more processors 1480 for processing; additionally, it transmits uplink data to the base station. Typically, RF circuit 1410 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, etc. Furthermore, RF circuit 1410 can also communicate wirelessly with networks and other terminals. The wireless communication can use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), etc.
[0225] The memory 1420 can be used to store software programs and modules. The processor 1480 executes various functional applications and data processing by running the software programs and modules stored in the memory 1420. The memory 1420 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for the functions, etc.; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 1420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1420 may also include a memory controller to provide access to the memory 1420 for the processor 1480 and the input unit 1430.
[0226] Input unit 1430 can be used to receive input numerical or character information, and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. Specifically, input unit 1430 may include touch-sensitive surface 1431 and other input devices 1432. Touch-sensitive surface 1431, also known as a touch display screen or touchpad, can collect touch operations on or near the user (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch-sensitive surface 1431), and drive corresponding connection devices according to a pre-set program. Optionally, touch-sensitive surface 1431 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, sends it to processor 1480, and can receive and execute commands from processor 1480. In addition, the touch-sensitive surface 1431 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. Besides the touch-sensitive surface 1431, the input unit 1430 may also include other input devices 1432. Specifically, other input devices 1432 may include, but are not limited to, one or more of the following: a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, and a joystick.
[0227] Display unit 1440 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the terminal. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof. Display unit 1440 may include display panel 1441, which may optionally be configured as an LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), or similar display panel 1441. Further, touch-sensitive surface 1431 may cover display panel 1441. When touch-sensitive surface 1431 detects a touch operation on or near it, it transmits the information to processor 1480 to determine the type of touch event. Subsequently, processor 1480 provides corresponding visual output on display panel 1441 according to the type of touch event. Touch-sensitive surface 1431 and display panel 1441 can be two independent components to implement input and output functions. However, in some embodiments, touch-sensitive surface 1431 and display panel 1441 can be integrated to achieve input and output functions.
[0228] The terminal may also include at least one sensor 1450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1441 according to the ambient light level, and the proximity sensor can turn off the display panel 1441 and / or the backlight when the terminal is moved to the ear. As a type of motion sensor, a gravity acceleration sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that identify the terminal's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, tapping), etc. Other sensors that may be configured on the terminal, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0229] Audio circuitry 1460, speaker 1461, and microphone 1462 provide an audio interface between the user and the terminal. Audio circuitry 1460 converts received audio data into electrical signals, which are then transmitted to speaker 1461, where they are converted into sound signals for output. Conversely, microphone 1462 converts collected sound signals into electrical signals, which are received by audio circuitry 1460, converted back into audio data, processed by processor 1480, and then transmitted via RF circuitry 1410 to, for example, another terminal, or output to memory 1420 for further processing. Audio circuitry 1460 may also include an earphone jack to facilitate communication between a peripheral headset and the terminal.
[0230] WiFi is a short-range wireless transmission technology. The terminal, through the WiFi module 1470, can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 14 WiFi module 1470 is shown, but it is understood that it is not a necessary component of the terminal and can be omitted as needed without changing the nature of the invention.
[0231] The processor 1480 is the control center of the terminal, connecting various parts of the terminal via various interfaces and lines. It executes various functions and processes data by running or executing software programs and / or modules stored in the memory 1420 and calling data stored in the memory 1420. Optionally, the processor 1480 may include one or more processing cores; preferably, the processor 1480 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1480.
[0232] The terminal also includes a power supply 1490 (such as a battery) to power various components. Preferably, the power supply can be logically connected to the processor 1480 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 1490 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0233] Although not shown, the terminal may also include a camera, Bluetooth module, etc., which will not be described in detail here. Specifically, in this embodiment, the terminal also includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors. The aforementioned one or more programs contain instructions for performing the input recommendations provided in the above method embodiments.
[0234] Embodiments of this application also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing an input recommendation method, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement any of the input recommendation methods provided in the above-described method embodiments.
[0235] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0236] Embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to implement any of the input recommendation methods provided in the above-described method embodiments.
[0237] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0238] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0239] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0240] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An input recommendation method, characterized in that, The method includes: Obtain the input pinyin string and determine the number of preset words that the pinyin string matches in the preset word library; If the number of the preset words that are hit does not exceed the preset number threshold, the pinyin string is processed by word grouping based on the preset word library to obtain a set of candidate words. The pinyin string is input into a syllable segmentation network for syllable segmentation to obtain a predicted syllable sequence corresponding to the pinyin string; the syllable segmentation network extracts features for syllable segmentation from the pinyin string based on a lightweight convolutional module; The predicted syllable sequence is input into the word prediction network to predict words, resulting in a set of predicted words. Based on the candidate term set and the predicted term set, recommended terms are output; The step of inputting the pinyin string into a syllable segmentation network for syllable segmentation to obtain a predicted syllable sequence corresponding to the pinyin string includes: converting the pinyin string into a letter sequence; inputting the letter sequence into a lightweight convolutional module of the syllable segmentation network for feature extraction to obtain a target feature vector; the target feature vector representing the feature vector at the corresponding position of each letter in the letter sequence; obtaining the syllable probability distribution at the corresponding position of each letter in the letter sequence based on the product of the target feature vector and a preset syllable table; the preset syllable table including vector representations of multiple preset syllables; predicting the predicted syllable information at the corresponding position of each letter in the letter sequence based on the syllable probability distribution at the corresponding position of each letter in the letter sequence; and performing syllable segmentation based on the predicted syllable information at the corresponding position of each letter in the letter sequence to obtain a predicted syllable sequence.
2. The method according to claim 1, characterized in that, The step of inputting the letter sequence into the lightweight convolutional module of the syllable segmentation network for feature extraction to obtain the target feature vector includes: The letter sequence is input into the lightweight convolutional module of the syllable segmentation network, and effective feature extraction is performed based on the gated linear units of the lightweight convolutional module to obtain effective feature information; The lightweight convolutional unit based on the lightweight convolutional module performs channel-wise convolution on the effective feature information, and performs point-wise convolution on the convolution result of the channel-wise convolution to obtain the target feature vector.
3. The method according to claim 1, characterized in that, The step of inputting the predicted syllable sequence into a word prediction network to predict words and obtain a set of predicted words includes: The predicted syllable sequence is input into the encoding unit of the word prediction network for encoding processing to obtain the encoding vector; The term length prediction unit of the term prediction network is used to predict the term length based on the encoding vector to obtain the predicted term length. The decoding unit of the term prediction network is used to perform decoding processing based on the predicted term length and the encoding vector to obtain a decoding result; the decoding result indicates at least one predicted term and the prediction score corresponding to each predicted term.
4. The method according to any one of claims 1 to 3, characterized in that, The output of recommended terms based on the candidate term set and the predicted term set includes: Obtain the word path score of each candidate word in the candidate word set in the word grouping process, and the prediction score of each predicted word in the predicted word set in the word prediction process; The candidate term set and the predicted term set are merged and deduplicated to obtain the candidate recommended term set; For each candidate recommended term in the candidate recommended term set, a comprehensive score for the candidate recommended term is determined based on the word grouping path score and prediction score corresponding to the candidate recommended term. Based on the comprehensive score of each candidate recommended term in the candidate recommended term set, the recommended terms are output.
5. The method according to claim 4, characterized in that, The determination of the comprehensive score of the candidate recommended term based on the word path score and prediction score corresponding to the candidate recommended term includes: Determine the set information to which the candidate recommended terms belong; If the attribution set information indicates that it belongs to the candidate term set and the predicted term set, then the comprehensive score of the candidate recommended term is determined based on the word grouping path score and prediction score corresponding to the candidate recommended term. If the attribution set information indicates that the term belongs to the candidate term set or the predicted term set, then the statistical value of the corresponding score of each term in the non-attribution set is determined as the simulated score of the candidate recommended term in the non-attribution set. The comprehensive score of the candidate recommended term is determined based on the score corresponding to the belonging set and the simulated score corresponding to the non-belonging set.
6. The method according to any one of claims 1 to 3 or 5, characterized in that, The step of performing word grouping processing on the pinyin string based on the preset dictionary to obtain a candidate word set includes: For at least one pinyin string corresponding to the pinyin string, determine a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string; A vocabulary network is constructed based on a set of candidate words corresponding to each syllable in the at least one pinyin string; The word path score of each combined word in the vocabulary network is determined based on a preset statistical language algorithm, and at least one candidate word is determined from the combined words in the vocabulary network based on the word path score, thus obtaining the candidate word set.
7. The method according to claim 4, characterized in that, The step of performing word grouping processing on the pinyin string based on the preset dictionary to obtain a candidate word set includes: For at least one pinyin string corresponding to the pinyin string, determine a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string; A vocabulary network is constructed based on a set of candidate words corresponding to each syllable in the at least one pinyin string; The word path score of each combined word in the vocabulary network is determined based on a preset statistical language algorithm, and at least one candidate word is determined from the combined words in the vocabulary network based on the word path score, thus obtaining the candidate word set.
8. A Pinyin input device, characterized in that, The device includes: The Pinyin acquisition module is used to acquire the input Pinyin string and determine the number of preset words that the Pinyin string matches in the preset word library; The word grouping module is used to perform word grouping on the pinyin string based on the preset word library when the number of hit preset words does not exceed the preset number threshold, so as to obtain a set of candidate words. The syllable segmentation module is used to input the pinyin string into the syllable segmentation network for syllable segmentation processing to obtain the predicted syllable sequence corresponding to the pinyin string; the syllable segmentation network extracts features for syllable segmentation processing from the pinyin string based on a lightweight convolutional module; The term prediction module is used to input the predicted syllable sequence into the term prediction network to predict terms and obtain a set of predicted terms. The recommended term output module is used to output recommended terms based on the candidate term set and the predicted term set; The syllable segmentation module includes: A pinyin preprocessing module is used to convert the pinyin string into a letter sequence; The feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network for feature extraction to obtain the target feature vector; the target feature vector represents the feature vector at the corresponding position of each letter in the letter sequence; The syllable probability distribution determination module is used to obtain the syllable probability distribution at the corresponding position of each letter in the letter sequence based on the product of the target feature vector and the preset syllable table; the preset syllable table includes vector representations of multiple preset syllables; The predicted syllable information determination module is used to predict the predicted syllable information at the corresponding positions of each letter in the letter sequence based on the syllable probability distribution at each position of each letter in the letter sequence; The syllable segmentation module is used to segment syllables based on the predicted syllable information at the corresponding positions of each letter in the letter sequence, and obtain a predicted syllable sequence.
9. The apparatus according to claim 8, characterized in that, The feature extraction module includes: An effective feature extraction module is used to input the letter sequence into the lightweight convolutional module of the syllable segmentation network, and perform effective feature extraction based on the gated linear units of the lightweight convolutional module to obtain effective feature information; The convolution module is used to perform channel-wise convolution on the effective feature information based on the lightweight convolution unit of the lightweight convolution module, and to perform point-wise convolution on the convolution result of the channel-wise convolution to obtain the target feature vector.
10. The apparatus according to claim 8, characterized in that, The term prediction module includes: The encoding module is used to input the predicted syllable sequence into the encoding unit of the word prediction network for encoding processing to obtain the encoding vector; The term length prediction module is used to predict the term length based on the encoding vector using the term length prediction unit of the term prediction network to obtain the predicted term length. The decoding module is used to perform decoding processing based on the predicted term length and the encoding vector using the decoding unit of the term prediction network to obtain a decoding result; the decoding result indicates at least one predicted term and the prediction score corresponding to each predicted term.
11. The apparatus according to any one of claims 8 to 10, characterized in that, The recommended term output module includes: The scoring module is used to obtain the word path score of each candidate word in the candidate word set in the word grouping process, and the prediction score of each predicted word in the predicted word set in the word prediction process. The candidate recommended term set determination module is used to merge the candidate term set and the predicted term set and perform deduplication to obtain the candidate recommended term set; The comprehensive score determination module is used to determine the comprehensive score of each candidate recommended word in the candidate recommended word set based on the word grouping path score and prediction score corresponding to the candidate recommended word. The recommended term output submodule is used to output recommended terms based on the comprehensive score of each candidate recommended term in the candidate recommended term set.
12. The apparatus according to claim 11, characterized in that, The comprehensive score determination module includes: The attribution set information determination module is used to determine the attribution set information of the candidate recommended terms; The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended word based on the word grouping path score and prediction score corresponding to the candidate recommended word when the attribution set information indicates that it belongs to the candidate word set and the predicted word set. The simulated score determination module is used to determine the statistical value of the corresponding score of each word in the non-attributed set as the simulated score of the candidate recommended word in the non-attributed set when the attribution set information indicates that it belongs to the candidate word set or the predicted word set; The first comprehensive score determination module is used to determine the comprehensive score of the candidate recommended term based on the score corresponding to the candidate term in the home set and the simulated score corresponding to the candidate term in the non-home set.
13. The apparatus according to any one of claims 8 to 10 or 12, characterized in that, The word grouping module includes: The candidate word determination module is used to determine, for at least one pinyin string corresponding to the pinyin string, a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string; The vocabulary network construction module is used to construct a vocabulary network based on a set of candidate words corresponding to each syllable in the at least one pinyin string; The candidate word determination module is used to determine the word formation path score of each combined word in the vocabulary network based on a preset statistical language algorithm, and to determine at least one candidate word from the combined words in the vocabulary network based on the word formation path score, thereby obtaining the candidate word set.
14. The apparatus according to claim 11, characterized in that, The word grouping module includes: The candidate word determination module is used to determine, for at least one pinyin string corresponding to the pinyin string, a set of candidate words corresponding to each syllable in the at least one pinyin string in the preset word library; the at least one pinyin string is obtained based on the syllable annotation results of the pinyin string; The vocabulary network construction module is used to construct a vocabulary network based on a set of candidate words corresponding to each syllable in the at least one pinyin string; The candidate word determination module is used to determine the word formation path score of each combined word in the vocabulary network based on a preset statistical language algorithm, and to determine at least one candidate word from the combined words in the vocabulary network based on the word formation path score, thereby obtaining the candidate word set.
15. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the input recommendation method as described in any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the input recommendation method as described in any one of claims 1 to 7.
17. A computer program product, characterized in that, The invention includes a computer program, characterized in that, when the computer program is executed by a processor, it implements the input recommendation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Input method and device and device for input
CN110389668A