Input prediction method and device and computer program product
By using a large predictive model for pinyin and number annotation in the input method and deploying the computation on the device side, the problems of long texts and network dependence in existing input methods are solved, achieving highly accurate and flexible input prediction and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- IFLYTEK CO LTD
- Filing Date
- 2026-02-04
- Publication Date
- 2026-05-12
AI Technical Summary
Existing input method prediction methods are ineffective in predicting long contexts and new words, and their reliance on network connectivity leads to unstable user experience.
A large-scale prediction model is used to annotate pinyin and numbers, construct the correspondence between candidate context information, and deploy it on the device side to achieve local computation, thus solving the problems of long context prediction and network dependency.
It improves the accuracy and flexibility of input prediction, ensuring a high level of intelligent prediction even in environments without or with weak network coverage, thus enhancing the user input experience.
Smart Images

Figure CN122021648A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to an input prediction method, device, and computer program product. Background Technology
[0002] With the rapid development of information technologies such as artificial intelligence and the Internet of Things, the application scenarios of human-computer interaction are becoming increasingly widespread. As the most important text entry point for human-computer interaction, the level of intelligence of input methods directly determines the communication efficiency and experience of users.
[0003] Currently, existing input methods can typically only predict the following text a user might type based on short preceding contexts. The predictions are often inaccurate and may increase the user's input effort. Specifically, existing input method systems generally employ three methods to predict user input: The first relies on statistical language models. By analyzing a large corpus, the conditional probability of a word or phrase immediately following the preceding word is calculated, creating a probability file reflecting language habits. Users only need to input the first Chinese character or word to predict subsequent candidate words or phrases based on the probability file. However, this method cannot predict long preceding contexts or generate new words that are semantically logical but not present in the corpus. The second method predicts user input by matching it to a text database. However, this method can only predict content already in the database. It cannot effectively predict new words, expressions, or personalized terms not found in the database. The third method uses cloud servers for cloud input method calculations and pinyin prediction. However, this method is highly dependent on network connectivity. If the network is unstable or interrupted, functions such as whole-sentence prediction will be unavailable or performance will significantly degrade, potentially reverting to basic local input, thus affecting user input efficiency and experience. It is evident that none of the three existing methods for predicting user input can achieve the desired results, thus reducing the user's input experience. Summary of the Invention
[0004] The main objective of this application is to provide an input prediction method, device, and computer program product that can improve the prediction efficiency and accuracy of user input, and can still provide a high level of intelligent prediction in environments without or with weak network coverage, thereby achieving ideal prediction results and improving the user's input experience.
[0005] This application provides an input prediction method, including:
[0006] Obtain the target context information input by the target user; and use the target context information to generate a first prediction instruction to input into a large language model (LLM) for inference, thereby obtaining N candidate context information corresponding to the target context information; where N is a positive integer greater than 0.
[0007] Construct the pinyin annotation result and numerical annotation result for each of the N candidate context messages; and store the correspondence between each candidate context message and its pinyin annotation result and numerical annotation result;
[0008] Obtain partial context information input by the target user; and match the partial context information with the stored pinyin annotation results and number annotation results;
[0009] Based on the matching results, the target context information corresponding to the target context information is determined.
[0010] In one possible implementation, the large prediction model is constructed as follows:
[0011] Obtain sample information and perform data cleaning on the sample information to obtain cleaned sample information; the sample information includes the context information of the sample and the context information of the sample.
[0012] Using the cleaned sample information, the initial prediction model is trained for inference to obtain the first layer of trained prediction model, which enables the model to have inference capabilities.
[0013] Construct sensitive sample information; and use the sensitive sample information to fine-tune the first-layer trained prediction model for sensitive content recognition to obtain the second-layer trained prediction model, so that the model has the ability to identify and reject the generation of sensitive content.
[0014] Obtain user evaluation results for the predicted context information output by the second-layer trained prediction model; and train a reward model based on the evaluation results.
[0015] Based on the Proximal Policy Optimization (PPO) method, the score values of the reward model are used to iteratively train the large prediction model after the second layer training, resulting in a large prediction model trained with three layers.
[0016] In one possible implementation, constructing the pinyin annotation result and numeric annotation result corresponding to each of the N candidate context messages includes:
[0017] From the decoding resources of the Finite State Transformer (FST) structure, the optimal phonetic transcription corresponding to each of the N candidate context messages is obtained as the pinyin annotation result; and according to the correspondence of the nine-key keyboard, the numerical annotation result corresponding to the pinyin annotation result is matched.
[0018] In one possible implementation, storing the context information for each candidate text and the correspondence between its pinyin annotation results and its numerical annotation results includes:
[0019] Create node identifiers for each candidate context information and its mapping relationship between pinyin annotation results and numerical annotation results;
[0020] According to the output order of the prediction model, store the candidate context information corresponding to each node identifier and the mapping relationship between its pinyin annotation results and its numeric annotation results.
[0021] In one possible implementation, the partial context information is pinyin information or numeric information; the step of matching the partial context information with the stored pinyin annotation results and numeric annotation results includes:
[0022] When the following information is Pinyin information, the Pinyin information is matched with the stored Pinyin annotation results to determine whether the Pinyin information and the prefix substring in the stored Pinyin annotation results are consistent. If they are, the match is successful; otherwise, the match fails.
[0023] Alternatively, when the following information is numerical, the numerical information is matched with the stored numerical annotation results to determine whether the prefix substring in the numerical information matches the stored numerical annotation results. If yes, the match is successful; otherwise, the match fails.
[0024] In one possible implementation, determining the target context information corresponding to the target context information based on the obtained matching result includes:
[0025] If the matching result is successful, the candidate context information corresponding to the successfully matched pinyin annotation result or number annotation result will be used as the target context information corresponding to the target context information.
[0026] If the matching result is a failure, then the target context information corresponding to the target context information is generated using the decoding result corresponding to the partial context information.
[0027] In one possible implementation, generating target context information corresponding to the target context information using the decoding result corresponding to the partial context information includes:
[0028] Determine whether the decoding result corresponding to the partial context information is consistent with the prefix string in the stored candidate context information;
[0029] If so, the candidate context information with the same prefix string is taken as the target context information corresponding to the target context information;
[0030] If not, the decoding result corresponding to the aforementioned context information is used to generate a second prediction instruction, which is then input into the prediction model for inference, to predict the target context information corresponding to the target context information.
[0031] In one possible implementation, the step of using the decoding result corresponding to the partial context information to generate a second prediction instruction and inputting it into the prediction model for inference, to predict the target context information corresponding to the target context information, includes:
[0032] Using the target context information, a prompt instruction is generated and input into the prediction model for inference in the prefill stage, to obtain the original prediction score corresponding to each decoding result;
[0033] The decoding result with the highest original prediction score is selected, and combined with the target context information, a second prediction instruction is generated and input into the prediction model for inference to obtain M candidate context information corresponding to the target context information; then, the pinyin annotation result and number annotation result corresponding to each of the M candidate context information are constructed and subsequent steps are performed until the target context information corresponding to the target context information is obtained; M is a positive integer greater than 0.
[0034] In one possible implementation, the method further includes:
[0035] The target context information corresponding to the target context information is displayed in the upper right corner of the input method interface.
[0036] In one possible implementation, the large prediction model is deployed on the edge.
[0037] This application also provides an input prediction device, including: a processor, a memory, and a system bus;
[0038] The processor and the memory are connected via the system bus;
[0039] The memory is used to store one or more programs, the one or more programs including instructions that, when executed by the processor, cause the processor to perform any of the above-described implementations of the input prediction method.
[0040] This application also provides a computer program product, which, when run on a terminal device, causes the terminal device to execute any of the above-described input prediction methods.
[0041] This application provides an input prediction method, device, and computer program product. First, it acquires target context information input by a target user. Then, using this context information, it generates a first prediction instruction input prediction model for inference, obtaining N candidate context information corresponding to the target context information, where N is a positive integer greater than 0. Next, it constructs the pinyin annotation result and numerical annotation result corresponding to each of the N candidate context information, and stores the correspondence between each candidate context information and its pinyin and numerical annotation results. Then, it acquires partial context information input by the target user and matches this partial context information with the stored pinyin and numerical annotation results to ultimately determine the target context information corresponding to the target context information based on the matching results.
[0042] As can be seen, when predicting the target user input, this application uses multiple (i.e., N) candidate contextual information corresponding to the target user input predicted by a large prediction model to perform pinyin and numerical annotation, obtains and stores the pinyin and numerical annotation results corresponding to each candidate contextual information, thereby eliminating the influence of polyphonic characters. This not only solves the problem that existing solutions (such as prediction using N-gram models) cannot handle long contextual prediction, but also, this generative prediction method using a large prediction model can create sentences or expressions that fit the context but have never appeared in the training data as target contextual information, making the prediction results more creative and flexible, thus achieving ideal prediction results and improving the input experience of the target user.
[0043] In addition, this generative prediction model can be deployed on the edge, so that all calculations in the prediction process can be performed locally, and therefore it is not limited by the network environment, and can still provide a high level of intelligent prediction even in environments without network or with weak network. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 A flowchart illustrating an input prediction method provided in an embodiment of this application;
[0046] Figure 2 Example diagram provided in this application embodiment for generating N candidate context information corresponding to target context information using a large prediction model;
[0047] Figure 3 An example diagram illustrating the construction process of the pinyin annotation results provided in the embodiments of this application;
[0048] Figure 4 An example diagram illustrating the mapping relationship between node identifiers and candidate context information, as well as their pinyin and numeric annotation results, provided in embodiments of this application;
[0049] Figure 5 An example diagram is provided for this application embodiment to generate target context information corresponding to target context information by utilizing the decoding result corresponding to partial context information;
[0050] Figure 6 This is a schematic diagram of the structure of an input prediction device provided in an embodiment of this application. Detailed Implementation
[0051] In today's mobile internet era, input methods, as the most important text entry point for human-computer interaction, directly determine the communication efficiency and experience of users. Traditional input methods mainly rely on algorithms such as dictionary matching and statistical probability-based language models (N-gram language models). Although these technologies are very mature, they still have significant limitations. Limited by the size of the language model, traditional input methods can only predict the following text that the user might type based on a short preceding context, and cannot effectively utilize the semantics of longer contexts. The predicted results often fail to meet the user's expectations, which to some extent increases the user's input cost.
[0052] Specifically, existing input method systems typically employ three methods to predict user input: The first relies on statistical language models. By analyzing a large corpus, the conditional probability of a word or phrase immediately following the preceding word is calculated, creating a probability file reflecting language habits. In this way, when a user inputs, they only need to input the first Chinese character or word, and the probability file predicts subsequent possible candidate words or phrases. The second method predicts user input by matching it to a text database. This involves using a pre-stored text database and querying it based on certain prediction criteria to obtain prediction results. The third method utilizes cloud servers for cloud input method calculations and pinyin prediction. The cloud server receives the letters input by the user through the terminal, performs the prediction, and then sends the prediction result set to the terminal for caching.
[0053] However, all three existing methods for predicting user input have significant problems and fail to achieve the desired results, impacting the user's input experience. Specifically, these problems manifest in the following three ways:
[0054] (1) For prediction schemes that rely on statistical language models, the size of the language model cannot be made too large due to the limitations of the product application scenario. Such schemes can only handle word-level predictions and cannot capture long-distance dependencies. Therefore, they usually perform poorly when dealing with predictions of long texts of five characters or more. In addition, such schemes are essentially based on probability-based "retrieval" or "combination", and it is difficult to generate novel words that conform to semantic logic but do not appear in the corpus.
[0055] (2) For schemes that predict user input by matching text databases, since the content in the database is limited, such schemes can only predict content that already exists in the database. They cannot effectively predict new words, new expressions, or personalized terms that do not exist in the database.
[0056] (3) For cloud input method calculation and pinyin prediction through cloud server, although the model size limitation can be overcome, such schemes are very dependent on network connection. Once the network is unstable or interrupted, functions such as whole sentence prediction will not be available or the performance will drop significantly, and may degenerate into basic local input, which will affect the user's input efficiency and experience.
[0057] To address the aforementioned shortcomings, this application provides an input prediction method. First, it acquires the target context information input by the target user. Then, using this context information, it generates a first prediction instruction and inputs it into a large-scale prediction model for inference, obtaining N candidate context information corresponding to the target context information. Next, it constructs the pinyin and numeric annotation results for each of the N candidate context information and stores the correspondence between each candidate context information and its pinyin and numeric annotation results. Then, it acquires a portion of the context information input by the target user and matches this portion with the stored pinyin and numeric annotation results. Based on the matching results, it ultimately determines the target context information corresponding to the target context information.
[0058] As can be seen, when predicting the input of the target user, this application uses multiple (i.e., N) candidate contextual information corresponding to the target user's input contextual information predicted by a large prediction model to perform pinyin and numerical annotation, obtains and stores the pinyin and numerical annotation results corresponding to each candidate contextual information, thereby eliminating the influence of polyphonic characters. This not only solves the problem that existing solutions (such as prediction using N-gram models) cannot handle long contextual prediction, but also, this generative prediction method using a large prediction model can create sentences or expressions that fit the context but have never appeared in the training data as target contextual information corresponding to the target contextual information, making the prediction results more creative and flexible, thereby achieving ideal prediction results and improving the input experience of the target user.
[0059] In addition, this generative prediction model can be deployed on the edge, so that all calculations in the prediction process can be performed locally, and therefore it is not limited by the network environment, and can still provide a high level of intelligent prediction even in environments without network or with weak network.
[0060] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, 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, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0061] See Figure 1 This is a flowchart illustrating an input prediction method provided in this embodiment. The method includes the following steps:
[0062] S101: Obtain the target context information input by the target user; and use the target context information to generate a first prediction instruction to input into the prediction model for reasoning, and obtain N candidate context information corresponding to the target context information; where N is a positive integer greater than 0.
[0063] In this embodiment, any user who predicts input content using the input prediction method provided in this application is defined as the target user. It is understood that only by obtaining sufficient contextual information can the desired contextual information be predicted more accurately. Therefore, to improve the prediction effect for the target user's input, it is first necessary to obtain the contextual information input by the target user (here defined as the target's preceding contextual information). Then, the content contained in the target contextual information is incorporated into a prompt word to generate a first prediction instruction. This first prediction instruction is then input into a pre-built prediction model (the specific composition and training method are not limited; a base model can be selected based on actual conditions and experience, and adaptive training can be performed) for inference. This predicts N (the specific value is not limited and can be any positive integer greater than 0) candidate contextual information corresponding to the target contextual information, which are then used to execute the subsequent step S102. Simultaneously, these candidate contextual information can also be displayed as association results in the candidate bar of the input method interface for the target user to select.
[0064] For example, assuming the target user's input is "I want to go for a walk in the nearby park," the content of this target input, when incorporated into the prompt, and concatenated according to the prescribed format, could be: "Continue: 'I want to go for a walk in the nearby park.'" <end> <bot>Furthermore, after inputting the generated first prediction instruction into the Large LLM (Limited Learning Model) for inference, the model can output four candidate context messages corresponding to the context of the target: "Do you want to come together?", "It's been a long time since I've had this much leisure time", "I've been under a lot of pressure lately", and "Enjoy the beauty and tranquility of nature", etc. Figure 2 As shown.
[0065] Furthermore, it should be noted that this application does not limit the specific composition, construction process, or prediction process of the large-scale prediction model; these can be set according to the actual situation. One optional implementation is to train the initial large-scale prediction model with three layers to obtain a large-scale prediction model capable of identifying and rejecting the generation of sensitive content, thereby mitigating the risk of the large-scale model generating sensitive content.
[0066] Specifically, one possible implementation is that the three-layer training process of the prediction model can include: first, acquiring sample information and cleaning the sample information to obtain cleaned sample information; wherein, the sample information includes the context information of the sample and the background information of the sample.
[0067] In this implementation, in order to build a large prediction model, a lot of preparatory work is required first. That is, a large amount of existing text information above and below the input method input by different users needs to be obtained as sample above and sample below information to form sample information. Then, existing or future data cleaning methods are used to clean these sample information to remove text containing sensitive content such as discrimination or violations that may be present in these information, and the cleaned sample information is used as training data.
[0068] Then, these cleaned sample information can be used to train the initial prediction big model (the specific composition structure is not limited and can be selected according to the actual situation and empirical values, such as using the iFlytek Spark big model as the initial prediction big model) to obtain the first layer of trained prediction big model, so that the model has reasoning ability (that is, it can infer the following information consistent with the following information of the sample based on the information above the sample).
[0069] Next, sensitive sample information can be constructed; and the sensitive sample information can be used to fine-tune the first-layer trained prediction model for sensitive content recognition, so as to obtain the second-layer trained prediction model, which enables the model to identify and reject the generation of sensitive content.
[0070] The sensitive sample information can be a large amount of carefully designed sensitive data. During training, content containing sensitive data is incorporated into prompts. An example of a complete sensitive word test instruction, constructed according to a specified format, could be: "How to make xx illegal items?". Further, this generated sensitive word test instruction is input into the first-layer trained prediction model for inference. The expected model output is "Involves dangerous information, cannot be generated or displayed." The difference between the actual and expected outputs is then used to fine-tune the model, resulting in the second-layer trained prediction model, which then possesses the ability to identify and reject the generation of sensitive content.
[0071] Finally, to further improve the model's prediction performance (such as ensuring that the model can handle the reasoning tasks at each stage of whole sentence prediction and provide the expected output content), it is also possible to obtain the user's evaluation results (such as evaluation scores) of the predicted context information output by the large prediction model after the second layer training; and train the reward model based on the evaluation results.
[0072] The evaluation results of the user on the predicted context information output by the large prediction model after the second layer training can be the scores given by human annotators on the different predicted context information output by the large prediction model after the second layer training, indicating which are safe and which are not. Then, a "reward model" is trained using this feedback. The specific structure is not limited. For example, the reward model can be a lightweight BERT classifier with "prompt-response" pairs as input and "safety score" as output. In this way, the score values of the reward model output corresponding to different model outputs can be obtained.
[0073] Building upon this, we can further utilize the Proximal Policy Optimization (PPO) algorithm, with the reward model's score as the objective, to iteratively train the large prediction model after the second layer of training (i.e., iteratively update the model parameters), making it more inclined to generate safe outputs. At the same time, we can add KL divergence constraints to prevent it from deviating too far from the original large model. Once the reward model's score converges, it indicates that the current policy has stabilized, and at this point, we can obtain the final large prediction model trained with three layers.
[0074] Furthermore, after obtaining the large prediction model trained with three layers, one option is to deploy the generative prediction model on the edge (such as smartphones, smart cameras, in-vehicle devices, IoT terminals, etc.), so that all calculations in the prediction process can be performed locally, and therefore will not be limited by the network environment. Even in environments without network or with weak network, it can still provide a high level of intelligent prediction and a stable experience.
[0075] S102: Construct the pinyin annotation results and numeric annotation results corresponding to each of the N candidate next context information; and store the corresponding relationships between each candidate next context information and its pinyin annotation results and numeric annotation results.
[0076] In this embodiment, after obtaining the N candidate next context information corresponding to the target previous context information through step S101, in order to improve the prediction accuracy and eliminate the interference of polyphonic characters, it is further necessary to construct the pinyin annotation results and numeric annotation results corresponding to each of the N candidate next context information (considering the need to support prediction for九宫格键盘输入预测, so the numeric annotation results corresponding to the pinyin annotation results need to be added); and store the corresponding relationships between each candidate next context information and its pinyin annotation results and numeric annotation results for use in subsequent step S103.
[0077] Specifically, an optional implementation method is that for each of the N candidate next context information, the optimal pronunciation of each of the N candidate next context information can be obtained from the decoding resources of the Finite State Transducer (FST) structure as the pinyin annotation result. Then, according to the corresponding relationship of the九宫格键盘, the numeric annotation result corresponding to each pinyin annotation result is matched.
[0078] In this implementation method, for each of the N candidate next context information, separate pronunciation is required for preparing the matching of pinyin strings in subsequent steps. In order to eliminate the interference of polyphonic characters and ensure the accuracy of pronunciation in this application, the method of decoding from resources is adopted to obtain the optimal pronunciation of each candidate next context information. The structure of the decoding resources is the FST structure, which is divided into arcs and nodes. For nodes, there are incoming arcs and outgoing arcs. The incoming arc indicates that this node can be reached through this arc, and the outgoing arc indicates which arcs this node can traverse. The characters and their pronunciations are stored on the arcs, and the node types are stored on the nodes, such as the root node, decode node, and final node.
[0079] Illustrate with an example: Based on the above example, take the candidate next context information "你要不要一起” as an example. As Figure 3 shown, first expand all possible arcs based on the character "你", then starting from the nodes reached by these arcs, continue to expand all possible arcs based on the character "要", and so on, until the expansion reaches the last character.
[0080] Meanwhile, to ensure the performance of phonetic annotation, when this application performs arc expansion at each step, all expanded arcs will be sorted, and the number of arcs will be trimmed based on an upper limit value (the specific value is not limited and can be determined according to the actual situation and experiments), setting a balance point between the phonetic annotation accuracy and performance. For example, the upper limit value can be set to 6, that is, at most 6 arcs are retained for each step of expansion. After the arc expansion is completed, the optimal decoding path is selected, the characters and pronunciations recorded on each arc are obtained, and the pinyin strings are concatenated to obtain the pinyin annotation result. For example, in the above example, the pinyin annotation result corresponding to the candidate following text information "你要不要一起” is "niyaobuyaoyiqi”. And to support the input prediction of the nine-grid keyboard, an additional digital string corresponding to the pinyin annotation result will be matched as the digital annotation result. For example, in the above example, the digital annotation result corresponding to the candidate following text information "你要不要一起” is "64926289269474”.
[0081] On this basis, after all candidate following text information is phonetically annotated, further, a node identifier can be created for the mapping relationship of each candidate following text information, its pinyin annotation result, and its digital annotation result (the specific content is not limited, but it must be unique, that is, the relationship between the candidate following text information and the node representation is one-to-one). Store the mapping relationship of the candidate following text information (i.e., text), its pinyin annotation result (i.e., pinyin string), and its digital annotation result (i.e., digital string) corresponding to each node identifier in the output order of the prediction large model, as Figure 4 shown, to prepare for the whole-sentence prediction of the target following text information in subsequent steps.
[0082] It should be noted that the reason this application stores in the output order of the prediction large model is that the model usually outputs according to the prediction probability, that is, the candidate following text information output first has the greatest possibility of being the target following text information. Therefore, in subsequent steps, matching can be performed sequentially according to the storage order of the node identifiers to improve the final prediction efficiency.
[0083] S103: Obtain the partial following text information input by the target user; and match the partial following text information with the stored pinyin annotation result and digital annotation result.
[0084] In this embodiment, after storing the correspondence between each candidate subsequent text information, its pinyin annotation result, and its numeric annotation result through step S102, it is further possible to continue to obtain partial subsequent text information input by the target user, including but not limited to partial pinyin information or partial numeric information input by the target user, and then match this partial subsequent text information with the stored pinyin annotation result and numeric annotation result. Specifically, when the partial subsequent text information input by the target user is pinyin information, the pinyin information can be matched with the stored pinyin annotation result to determine whether the pinyin information is consistent with the prefix substring in the stored pinyin annotation result. If so, it indicates a successful match; if not, the match fails. Alternatively, when the partial subsequent text information input by the target user is numeric information, the numeric information can be matched with the stored numeric annotation result to determine whether the numeric information is consistent with the prefix substring in the stored numeric annotation result. If so, it indicates a successful match; if not, the match fails.
[0085] S104: Determine the target subsequent text information corresponding to the target previous text information according to the obtained matching result.
[0086] In this embodiment, if the matching result obtained through step S103 is that the partial subsequent text information is successfully matched with the stored pinyin annotation result and numeric annotation result, that is, if the pinyin information input by the target user is consistent with the prefix substring in the stored pinyin annotation result, or if the numeric information input by the target user is consistent with the prefix substring in the stored numeric annotation result, then further, the candidate subsequent text information corresponding to the successfully matched pinyin annotation result or numeric annotation result can be used as the target subsequent text information corresponding to the target previous text information. At the same time, the target subsequent text information can also be displayed in the upper right corner of the input method interface (only as an example, it can also be displayed in other positions) for the target user to select.
[0087] Illustrative example: Based on the above example, assume that the partial subsequent text information input by the target user obtained through step S103 is the pinyin information "niyao" input from the full keyboard or the numeric information "64926" input from the 9-keyboard. Then, further, first, the mapping relationship between each node identifier corresponding to the candidate subsequent text information, its pinyin annotation result, and its numeric annotation result stored previously can be traversed in sequence to determine whether "niyao" or "64926" is the prefix substring of the pinyin string or numeric string corresponding to the current mapped node identifier. For example, if "niyao" is the prefix substring of the pinyin string "niyaobuyaoyiqi" of the candidate subsequent text information "你要不要一起", it indicates a successful match between the two. Thus, the candidate subsequent text information "你要不要一起" corresponding to the node identifier can be stored as the target subsequent text information (i.e., the final whole sentence prediction result) corresponding to the target previous text information "我想去附近的公园散散步".
[0088] Alternatively, if the matching result obtained through step S103 is that some of the subsequent text information fails to match the stored pinyin annotation results and numeric annotation results, that is, if the pinyin information input by the target user is inconsistent with the prefix substring in the stored pinyin annotation results, or if the numeric information input by the target user is inconsistent with the prefix substring in the stored numeric annotation results, then further, existing or future text decoding methods can be used to decode some of the subsequent text information. For example, the N-gram model can be used to decode some of the subsequent text information to obtain the decoding result corresponding to the subsequent text information, and then this decoding result can be used to generate the target subsequent text information corresponding to the target previous text information. At the same time, the target subsequent text information can still be displayed in the upper right corner of the input method interface (for example only, it can also be displayed in other positions) for the target user to select.
[0089] Specifically, an optional implementation method is that, in order to implement the whole sentence prediction for the input of the target user in input scenarios such as simple pinyin, error correction, and fuzzy pronunciation, after using the N-gram model to decode some of the subsequent text information input by the target user to obtain the corresponding decoding result, further, the prefix substring matching can be performed one by one with the candidate subsequent text information (i.e., text) corresponding to each previously stored node identifier, so as to determine whether the decoding result corresponding to some of the subsequent text information is consistent with the prefix substring in a certain candidate subsequent text information (i.e., text) stored previously. If so, the candidate subsequent text information with the consistent prefix substring can be used as the target subsequent text information corresponding to the target previous text information. Otherwise, if not, the decoding result corresponding to some of the subsequent text information can be used to generate a second prediction instruction and input it into the prediction large model for inference to predict the target subsequent text information corresponding to the target previous text information.
[0090] Illustrate with an example: Based on the above example, assume that some of the subsequent text information input by the target user obtained through step S103 is the pinyin information "niyao" input from the full keyboard, and the N-gram model is used to decode some of the subsequent text information input by the target user, and the corresponding decoding results obtained include: "你要", "你邀", "你咬", "你腰". At this time, these decoding results can be used to perform the prefix substring matching with the candidate subsequent text information (i.e., text) corresponding to each previously stored node identifier one by one until the candidate subsequent text information with the consistent prefix substring is found. For example, if "你要" is found to be the prefix substring of the candidate subsequent text information "你要不要一起", then the candidate subsequent text information "你要不要一起" can be used as the target subsequent text information (i.e., the final whole sentence prediction result) corresponding to the target previous text information "我想去附近的公园散散步" and displayed in the upper right corner of the input method interface, thereby utilizing the traditional pinyin decoding ability to cover the whole sentence prediction in more input scenarios.
[0091] It should be noted that if no candidate subsequent information that can be used as the target subsequent information corresponding to the target previous information is matched from the previously stored N candidate subsequent information. For example, for the target previous information "I want to take a walk in the nearby park", assume that the partial subsequent information input by the target user obtained through step S103 is the pinyin information "shunbian" input from the full keyboard. At this time, through the above matching logic, no text that can be used as the target subsequent information can be matched from the 4 candidate subsequent information "Do you want to come with me?", "It's been a long time since I've been this leisurely", "I've been under a bit of pressure recently", and "Enjoy the beauty and tranquility of nature". In this regard, an optional prediction method adopted by this application is: using the decoding result corresponding to the partial subsequent information, generating a second prediction instruction to input into the prediction large model for reasoning, and predicting the target subsequent information corresponding to the target previous information.
[0092] In this prediction method, first, a prompt instruction is generated using the target previous information and input into the prediction large model for reasoning in the prefill stage to obtain the original prediction scores corresponding to each decoding result. Then, the decoding result with the highest original prediction score is selected, combined with the target previous information, to generate a second prediction instruction and input into the prediction large model for reasoning to obtain M candidate subsequent information corresponding to the target previous information; then, the pinyin annotation results and digital annotation results corresponding to each candidate subsequent information in the M candidate subsequent information are constructed and their subsequent steps (i.e., the above steps S102 - S104) are executed until the target subsequent information corresponding to the target previous information is obtained.
[0093] Specifically, in order to achieve generative prediction of the target subsequent information, after decoding the partial subsequent information input by the target user using the N - gram model to obtain the corresponding decoding results, for example, after obtaining the decoding results "by the way", "as a matter of course", and "sudden change" for the partial subsequent information (pinyin information) "shunbian" input by the target user, since the N - gram model is a statistical language model, the earlier the result, the higher the probability of the decoding result appearing under the current pinyin information input.
[0094] Furthermore, the content included in the target previous information (such as "I want to take a walk in the nearby park") can be incorporated into the prompt to generate a prompt instruction (such as "Continue writing: 'I want to take a walk in the nearby park'") <end> <bot>The generated prompt instruction is input into a pre-built large prediction model (the specific structure and training method are not limited, see the corresponding description in step S101 above) for inference in the prefill stage. The output of this stage is the prediction distribution of the next token corresponding to the last token of the input sequence, which is used to sample the first output token in the decoding stage. When the inference reaches the decoding stage, instead of selecting the next token by sampling or greedily, each decoding result is selected based on the N-gram decoding results as the original prediction score (i.e., logits value) in the following text. The logits (or logits values) refer to the raw, unnormalized scores output by the large model before the final softmax activation. These scores are not probabilities themselves, but they determine the relative likelihood of each possible token being selected. A higher logits value means the large model believes that the current token is more likely to be the next token in the current context. Therefore, by comparing the raw prediction scores (logits values) of each decoding result, the decoding result with the highest logits value can be selected as the optimal decoding result. For example, the decoding result with the highest logits value could be "incidentally" selected as the optimal decoding result.
[0095] Based on this, the decoding result with the highest original prediction score (i.e., the optimal decoding result) and the content contained in the target context information can be integrated into the prompt word to generate a second prediction instruction. This second prediction instruction is then input into a pre-built prediction model (the specific composition and training method are not limited, see the corresponding description in step S101 above) for inference. This model predicts M (the specific value is not limited, it can be any positive integer greater than 0) candidate context information corresponding to the target context information, which are used to replace the N candidate context information mentioned in step S102 above. The process of constructing the pinyin annotation result and the number annotation result corresponding to each of the M candidate context information and the subsequent steps (i.e., repeating steps S102-S104 above) is repeated until the target context information corresponding to the target context information is obtained. The specific implementation process will not be elaborated here.
[0096] For example: Based on the above example, still assuming the target context is "I want to go for a walk in the nearby park," and the decoded result with the highest original prediction score (i.e., logits value) (i.e., the optimal decoded result) is "by the way," then the optimal decoded result and the content contained in the target context are incorporated into the prompt. An example of concatenating this optimal decoded result and the prompt word according to the prescribed format to produce a complete second prediction instruction could be: "Complete: "I want to go for a walk in the nearby park, by the way." <end> <bot>". Further, after inputting the generated second prediction instruction into the large language model (LLM) for reasoning, the model can output the candidate next context information corresponding to the target previous context information, including but not limited to: "Take the dog for a walk by the way", "Breathe some fresh air by the way", etc., as Figure 5 shown, to replace the N candidate next context information mentioned in the above step S102, and repeat the execution of constructing the pinyin annotation results and digital annotation results corresponding to each candidate next context information in the M candidate next context information and its subsequent steps (i.e., repeat the above steps S102 - S104) until the target next context information corresponding to the target previous context information can be "Take the dog for a walk by the way". And it can be displayed in the upper right corner of the input method interface or other preset positions.
[0097] It can be understood that if the reasoning performance of the large language model is excellent enough, the whole sentence prediction result can be displayed before the target user presses the next key. Or, if the whole sentence prediction result cannot be returned in time, it can still be cached for the prediction of the next input.
[0098] In addition, it should be noted that since the entire reasoning process of the generative prediction of the target next context information consumes the CPU resources on the input device (such as a mobile phone and other terminals) used by the target user, if the target user frequently triggers this generative prediction reasoning process during the input process, it will inevitably significantly accelerate the power consumption speed of the input device (such as a mobile phone, etc.). As a lightweight application, if the input method brings too much power consumption, it is obviously unacceptable to users. Therefore, this application provides a suitable triggering strategy, which can both bring users an efficient input experience and maintain a low power consumption.
[0099] Specifically, in this triggering strategy, regarding the second prediction instruction of the large model input during the generative prediction inference process of the aforementioned target context information, this second prediction instruction is obtained by concatenating the decoding results of the N-gram model. The N-gram model is a statistical Markov hypothesis-based language model that estimates the conditional probabilities between words in a language by statistically analyzing the probability of "word sequences" occurring in a large corpus. After a series of calculations, a model score is obtained for each decoding result, and the quality of the decoding result can be judged by the model score. On the one hand, if the decoding results under the current input are generally of poor quality, concatenation inference can be omitted, i.e., the generative prediction inference of the aforementioned target context information can be omitted. This is because if all decoding results are generally of poor quality, even if secondary inference is performed using the large prediction model, it will not generate reasonable results, and there is no need to waste the resources of the input device. On the other hand, the length of the decoding result can be limited in advance. For example, if the user has only entered one character and the intention is not obvious, directly concatenating a single character to generate a second prediction instruction input to the prediction model for inference will not accurately predict the user's expected result. Therefore, it can be set in advance that the user has entered two or more characters (that is, the length of the decoding result is set to be no less than two characters) before the generative prediction inference process of the target context information is triggered.
[0100] In summary, the input prediction method provided in this embodiment first obtains the target context information input by the target user; then, using the target context information, a first prediction instruction is generated and input into a large prediction model for inference, resulting in N candidate context information corresponding to the target context information; next, the pinyin annotation result and numerical annotation result corresponding to each of the N candidate context information are constructed; and the correspondence between each candidate context information and its pinyin annotation result and numerical annotation result is stored. Then, partial context information input by the target user is obtained; and this partial context information is matched with the stored pinyin annotation result and numerical annotation result to finally determine the target context information corresponding to the target context information based on the obtained matching result.
[0101] As can be seen, when predicting the target user input, this application uses multiple (i.e., N) candidate contextual information corresponding to the target user input predicted by a large prediction model to perform pinyin and numerical annotation, obtains and stores the pinyin and numerical annotation results corresponding to each candidate contextual information, thereby eliminating the influence of polyphonic characters. This not only solves the problem that existing solutions (such as prediction using N-gram models) cannot handle long contextual prediction, but also, this generative prediction method using a large prediction model can create sentences or expressions that fit the context but have never appeared in the training data as target contextual information, making the prediction results more creative and flexible, thus achieving ideal prediction results and improving the input experience of the target user.
[0102] In addition, this generative prediction model can be deployed on the edge, so that all calculations in the prediction process can be performed locally. Therefore, it is not limited by the network environment and can still provide a high level of intelligent prediction and stable experience even in environments without network or with weak network.
[0103] Furthermore, embodiments of this application also provide an input prediction device, including: a processor, a memory, and a system bus;
[0104] The processor and the memory are connected via the system bus;
[0105] The memory is used to store one or more programs, the one or more programs including instructions that, when executed by the processor, cause the processor to perform any of the above-described implementations of the input prediction method.
[0106] refer to Figure 6 The diagram illustrates a suitable structural schematic for implementing the input prediction device in the embodiments of this application. The input prediction device in the embodiments of this application may include, but is not limited to, terminals equipped with large prediction models, cloud platforms, servers, and server clusters. Figure 6 The input prediction device shown is merely an example of an electronic device and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0107] like Figure 6 As shown, the input prediction device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. When the input prediction device is powered on, RAM 603 also stores various programs and data required for device operation. The processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0108] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 608 including, for example, memory card, hard disk, etc.; and communication devices 609. Communication device 609 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An input prediction device with various means is shown; however, it should be understood that implementation or possession of all the means shown is not required. More or fewer means may be implemented alternatively.
[0109] Furthermore, embodiments of this application also provide a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform any of the above-described implementations of the input prediction method.
[0110] Furthermore, this application embodiment also provides a computer program product, which, when run on a terminal device, causes the terminal device to execute any of the above-described implementation methods of the input prediction method.
[0111] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0112] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0113] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0114] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.< / bot> < / end> < / bot> < / end> < / bot> < / end>
Claims
1. An input prediction method, characterized in that, include: Obtain the target context information input by the target user; Using the target context information, a first prediction instruction is generated and input into the prediction model for inference, resulting in N candidate context information corresponding to the target context information; where N is a positive integer greater than 0. Construct the pinyin annotation result and the numeric annotation result for each of the N candidate context messages; It also stores the context information for each candidate text, along with the correspondence between its pinyin and numeric annotation results; Obtain partial context information input by the target user; The aforementioned text information is then matched with the stored pinyin and numeric annotation results; Based on the matching results, the target context information corresponding to the target context information is determined.
2. The method according to claim 1, characterized in that, The large-scale prediction model is constructed as follows: Obtain sample information and perform data cleaning on the sample information to obtain cleaned sample information; the sample information includes the context information of the sample and the context information of the sample. Using the cleaned sample information, the initial prediction model is trained for inference to obtain the first layer of trained prediction model, which enables the model to have inference capabilities. Construct sensitive sample information; and use the sensitive sample information to fine-tune the first-layer trained prediction model for sensitive content recognition to obtain the second-layer trained prediction model, so that the model has the ability to identify and reject the generation of sensitive content. Obtain user evaluation results for the predicted context information output by the second-layer trained prediction model; and train a reward model based on the evaluation results. Based on the Proximal Policy Optimization (PPO) method, the score values of the reward model are used to iteratively train the large prediction model after the second layer training, resulting in a large prediction model trained with three layers.
3. The method according to claim 1, characterized in that, The construction of the pinyin annotation result and number annotation result corresponding to each of the N candidate context messages includes: From the decoding resources of the Finite State Transformer (FST) structure, the optimal phonetic transcription corresponding to each of the N candidate context messages is obtained as the pinyin annotation result; and according to the correspondence of the nine-key keyboard, the numerical annotation result corresponding to the pinyin annotation result is matched.
4. The method according to claim 1, characterized in that, The storage of the context information for each candidate text and the correspondence between its pinyin annotation results and its numerical annotation results includes: Create node identifiers for each candidate context information and its mapping relationship between pinyin annotation results and numerical annotation results; According to the output order of the prediction model, store the candidate context information corresponding to each node identifier and the mapping relationship between its pinyin annotation results and its numeric annotation results.
5. The method according to claim 1, characterized in that, The aforementioned context information is either pinyin information or numerical information; the matching of the aforementioned context information with the stored pinyin annotation results and numerical annotation results includes: When the following information is Pinyin information, the Pinyin information is matched with the stored Pinyin annotation results to determine whether the Pinyin information and the prefix substring in the stored Pinyin annotation results are consistent. If they are, the match is successful; otherwise, the match fails. Alternatively, when the following information is numerical, the numerical information is matched with the stored numerical annotation results to determine whether the prefix substring in the numerical information matches the stored numerical annotation results. If yes, the match is successful; otherwise, the match fails.
6. The method according to claim 1, characterized in that, The step of determining the target context information corresponding to the target context information based on the obtained matching results includes: If the matching result is successful, the candidate context information corresponding to the successfully matched pinyin annotation result or number annotation result will be used as the target context information corresponding to the target context information. If the matching result is a failure, then the target context information corresponding to the target context information is generated using the decoding result corresponding to the partial context information.
7. The method according to claim 6, characterized in that, The step of generating target context information corresponding to the target preceding context information using the decoding result corresponding to the partial context information includes: Determine whether the decoding result corresponding to the partial context information is consistent with the prefix string in the stored candidate context information; If so, the candidate context information with the same prefix string is taken as the target context information corresponding to the target context information; If not, the decoding result corresponding to the aforementioned context information is used to generate a second prediction instruction, which is then input into the prediction model for inference, to predict the target context information corresponding to the target context information.
8. The method according to claim 7, characterized in that, The step of using the decoding result corresponding to the partial context information to generate a second prediction instruction and inputting it into the prediction model for inference, and predicting the target context information corresponding to the target context information, includes: Using the target context information, a prompt instruction is generated and input into the prediction model for inference in the prefill stage, to obtain the original prediction score corresponding to each decoding result; The decoding result with the highest original prediction score is selected, and combined with the target context information, a second prediction instruction is generated and input into the prediction model for inference to obtain M candidate context information corresponding to the target context information; then, the pinyin annotation result and number annotation result corresponding to each of the M candidate context information are constructed and subsequent steps are performed until the target context information corresponding to the target context information is obtained; M is a positive integer greater than 0.
9. The method according to any one of claims 1-8, characterized in that, The method further includes: The target context information corresponding to the target context information is displayed in the upper right corner of the input method interface.
10. The method according to any one of claims 1-8, characterized in that, The large-scale prediction model is deployed on the edge.
11. An input prediction device, characterized in that, include: Processor, memory, system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, the one or more programs including instructions that, when executed by the processor, cause the processor to perform the method according to any one of claims 1-10.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform the method described in any one of claims 1-10.
13. A computer program product, characterized in that, The program product includes a computer program that, when executed by an electronic product, can implement the method described in any one of claims 1-10.