Input method character sorting method, device and equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING QIHOOD TECHNOLOGY CO LTD
- Filing Date
- 2026-05-27
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]本申请的主要目的在于提供一种输入法文字排序方法、装置、设备及存储介质,旨在解决目前输入法上文字排序的准确性较低的技术问题
Smart Images

Figure CN122526435A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of input method technology, and in particular to input method text sorting methods, apparatus, devices and storage media. Background Technology
[0002] Pinyin input method is the most widely used Chinese text input method on mobile devices. After the user inputs a Pinyin sequence, the input method's P2C engine converts it into multiple candidate Chinese character sequences, which are then presented to the user for selection in order. The accuracy of the candidate sorting directly affects the user's first-choice hit rate and input efficiency.
[0003] Current input methods sort characters by using an N-gram language model (usually a binary or trigram model) and word frequency statistics to rank each Chinese character as a candidate, allowing users to select from the ranked characters. However, the accuracy of this sorting method is relatively low. Summary of the Invention
[0004] The main objective of this application is to provide an input method text sorting method, apparatus, device, and storage medium, aiming to solve the technical problem of low accuracy in text sorting in current input methods.
[0005] To achieve the above objectives, this application proposes an input method text sorting method, which includes: A candidate Chinese character sequence is determined based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; Obtain the context text of a preset area on the terminal interface; The target score for each candidate Chinese character is determined based on the pinyin sequence, the context text, and the candidate Chinese character sequence. The candidate Chinese character sequence is rearranged based on the target score to obtain the rearranged candidate Chinese character sequence.
[0006] In one embodiment, the step of determining the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence includes: The semantic score of each candidate Chinese character is determined based on the context text and the candidate Chinese character sequence. The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
[0007] In one embodiment, the step of determining the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence includes: The context text and the candidate Chinese character sequence are concatenated according to a preset format to construct a scoring input text containing context identifiers and candidate identifiers; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; The semantic scores of each candidate Chinese character are obtained based on the reasoning results.
[0008] In one embodiment, before the step of obtaining the pre-stored target key-value cache corresponding to the context text, the method further includes: Retrieve historical input text from a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
[0009] In one embodiment, the step of obtaining the semantic score of each candidate Chinese character based on the reasoning result includes: Based on the reasoning results, the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model is obtained; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
[0010] In one embodiment, the step of determining the pinyin matching score of each candidate Chinese character based on the pinyin sequence and the candidate Chinese character sequence includes: Convert the candidate Chinese character sequence into the corresponding standard Pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
[0011] In one embodiment, the step of determining the pinyin matching score of each candidate Chinese character based on the comparison result includes: When the standard pinyin sequence matches the pinyin sequence, the pinyin matching score of the candidate Chinese character is determined to be a first preset score; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
[0012] In one embodiment, the step of determining the target score for each candidate Chinese character based on the pinyin matching score and the semantic score includes: Obtain the preset weight coefficients corresponding to the pinyin matching score and the semantic score; The target score for each candidate Chinese character is calculated based on the preset weight coefficient, the pinyin matching score, and the semantic score.
[0013] In one embodiment, the step of obtaining the preset weight coefficients corresponding to the pinyin matching score and the semantic score includes: Determine the syllable length of the pinyin sequence; Based on the syllable length, preset weight coefficients are set for the pinyin matching score and the semantic score, respectively.
[0014] In one embodiment, the step of rearranging the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence includes: The candidate Chinese character sequences are sorted in descending order according to the target score from high to low to generate an initial rearrangement list; The rearranged candidate Chinese character sequence is obtained based on the initial rearrangement list.
[0015] In one embodiment, the method further includes: The rearranged candidate Chinese character sequence is sent to the candidate window of the input method for display; In response to the user's confirmation of the target Chinese character in the rearranged candidate Chinese character sequence, the target Chinese character is added to the context text; The target Chinese character is encoded to obtain encoded data, and the encoded data is added to the key-value cache corresponding to the context text to update the key-value cache.
[0016] Furthermore, to achieve the above objectives, this application also proposes an input method text sorting device, which includes: The determination module is used to determine a candidate Chinese character sequence based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; The acquisition module is used to acquire the context text of a preset area on the terminal interface. The determining module is further configured to determine the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence; The rearrangement module is used to rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence.
[0017] In one embodiment, the determining module is further configured to determine the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence; The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
[0018] In one embodiment, the determining module is further configured to concatenate the context text and the candidate Chinese character sequence according to a preset format to construct a scoring input text containing a context identifier and a candidate identifier; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; Based on the reasoning results, semantic scores for each candidate Chinese character are obtained. In one embodiment, the determining module is further configured to acquire historical input text in a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
[0019] In one embodiment, the determining module is further configured to obtain the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model based on the inference result; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
[0020] In one embodiment, the determining module is further configured to convert the candidate Chinese character sequence into a corresponding standard pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
[0021] In one embodiment, the determining module is further configured to determine the pinyin matching score of the candidate Chinese character as a first preset score when the standard pinyin sequence matches the pinyin sequence; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
[0022] In addition, to achieve the above objectives, this application also proposes an input method text sorting device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the input method text sorting method as described above.
[0023] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the input method text sorting method as described above.
[0024] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the input method text sorting method as described above.
[0025] The present application proposes one or more technical solutions to determine a candidate Chinese character sequence based on an input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low frequency of occurrence; obtain the context text of a preset area on the terminal interface; determine the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence; rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence; and comprehensively calculate the target score for each candidate Chinese character based on the context text, the pinyin sequence, and the candidate Chinese character sequence. This score combines the frequency of occurrence of the candidate Chinese character itself with the suitability of the current context. Compared with existing solutions that rely solely on pinyin matching frequency sorting, this approach is more in line with the user's current input scenario, improves the efficiency of the user in selecting the target Chinese character, and reduces the user's operational cost of flipping through pages to find the correct character. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0027] 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, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart illustrating an embodiment of the input method text sorting method of this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the input method text sorting method of this application; Figure 3 A simplified flowchart is provided for one embodiment of the input method text sorting method of this application; Figure 4 This is a schematic diagram of the module structure of the input method text sorting device according to an embodiment of this application; Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the input method text sorting method in the embodiments of this application.
[0029] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0030] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0031] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0032] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or input method text sorting device capable of the above functions. The following description uses an input method text sorting device as an example to illustrate this embodiment and the subsequent embodiments. All actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection regulations of the country where the application is located and with authorization from the owner of the corresponding device.
[0033] Based on this, this application provides an input method text sorting method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the input method text sorting method of this application.
[0034] In this embodiment, the input method text sorting method includes steps S10~S40: Step S10: Determine a candidate Chinese character sequence based on the input Pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence.
[0035] It should be noted that the input method text sorting device can be embedded in or installed in the terminal device. The input method text sorting device can be input method software, or other software capable of sorting input method text; this embodiment does not impose any restrictions on this. The terminal device can be an electronic device capable of input operations, such as a mobile phone, tablet, or computer; this embodiment does not impose any restrictions on this either.
[0036] It can be understood that in this application, a semantic re-rank layer is newly added after the P2C engine (pinyin-to-Chinese character conversion engine) in the input method candidate pipeline, forming a two-stage candidate sorting architecture of "coarse ranking + fine ranking". In the coarse ranking stage, that is, the P2C engine receives the pinyin sequence input by the user and outputs the top-K candidate Chinese character sequences based on the N-gram language model, word frequency statistics, and the user word library.
[0037] In a feasible implementation manner, the splicing input parser can parse the user's key sequence into a normalized pinyin syllable sequence, and process word segmentation, fuzzy sounds, etc., so as to obtain the pinyin sequence.
[0038] In a specific implementation, the terminal device receives the pinyin sequence input by the user through the keyboard, such as "xunhui". The P2C engine inside the terminal device analyzes and processes this pinyin sequence. The P2C engine is a traditional conversion engine based on the N-gram language model and statistical frequency. According to the pre-constructed word library and the user's historical input frequency, it outputs multiple candidate Chinese character sequences, such as "巡回", "巡回赛", "寻回", "训诲", etc. These candidate Chinese character sequences constitute the initial candidate list.
[0039] Specifically, the steps for determining the candidate Chinese character sequence based on the input pinyin sequence are: receiving the pinyin sequence input by the user, retrieving the word frequency statistics results and the user's personalized word library built in the input method, screening out the candidate Chinese characters that meet the conditions according to the pinyin matching relationship, and arranging the candidate Chinese characters in descending order of the occurrence frequency to obtain the candidate Chinese character sequence.
[0040] It should be understood that the initial sorting output by the P2C engine is only based on the statistical frequency, that is, the one with a higher occurrence frequency is ranked in the front. Although this sorting method is fast, it lacks a deep understanding of the context semantics and is prone to unreasonable sorting of homophonic words. This step, as the "coarse ranking" stage, provides the basic data source for the subsequent "fine ranking".
[0041] Step S20: Obtain the context text in the preset area of the terminal interface.
[0042] The context text is various text contents input by the user in the input area of the terminal. The preset area of the terminal interface usually refers to the text area that has been displayed on the screen before the current input cursor. For example, the input box of a chat application, the text editing area of a text message, etc. "Display on the screen" means that the text officially enters the "input box" from the "alternate area" of the input box. That is, after the user completes word selection or typing, the text is confirmed and displayed in the chat box or search bar. For example, the user clicks on the candidate item "Hello" with a finger, or presses the space bar / enter key, and these two characters instantly jump into the chat input box. This "action of jumping from the candidate bar to the input box" is called "display on the screen". For example, if the user has previously input and displayed on the screen the two characters "铭记", then "铭记" is the context text. The acquisition timing can be triggered when the user starts inputting a new pinyin sequence, or can be triggered after the P2C engine outputs the candidate sequence and before scoring.
[0043] The context text is the basis for semantic analysis, which determines which subsequent candidate word is more semantically smooth and more in line with the user's intention. In this embodiment, by reading the content of the preset area of the terminal interface, the perception of the user's current input context is achieved.
[0044] Step S30: Determine the target score of each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence.
[0045] In this step, multi-dimensional information can be comprehensively used to quantitatively evaluate each candidate Chinese character. The target score is the core basis for determining the rearrangement order. Specifically, the pinyin sequence, the context text, and the candidate Chinese character sequence can be used as input parameters and input into the scoring model. This scoring model can be a combination of a local large language model (LLM) and a pinyin matching model. The level of the target score reflects the overall pros and cons of the candidate Chinese character in the current context. For example, for the pinyin sequence "xunhui" and the context "铭记", the target score of the candidate word "训诲" may be higher than that of "巡回" because "铭记训诲" is more reasonable in semantic collocation than "铭记巡回". This step ensures that the scoring result conforms to semantic logic and does not deviate from the user's input intention by introducing the double constraints of the context text and the pinyin sequence.
[0046] In a feasible implementation manner, the pinyin matching score and the semantic score corresponding to the candidate Chinese character can be calculated separately, and then the two scores can be combined to obtain the comprehensive target score, so that the score can reflect both the accuracy of pinyin matching and the semantic adaptability in the current context.
[0047] Step S40: Rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence.
[0048] Specifically, the candidate character sequence originally sorted by frequency of occurrence can be adjusted according to the target score of each candidate character. Candidate characters that are more in line with the current context and have higher scores can be prioritized and placed at the front, thereby obtaining a rearranged candidate character sequence that better matches the user's input intent and completing the output of the candidate results.
[0049] In one feasible implementation, step S40 may include steps A11-A12: Step A11: Sort the candidate Chinese character sequences in descending order according to the target score from high to low to generate an initial rearrangement list; It should be noted that the rearrangement rule is usually to move candidate Chinese characters with high target scores to the front of the list and those with low target scores to the back, thus obtaining the initial rearranged list.
[0050] Step A12: Obtain the rearranged candidate Chinese character sequence based on the initial rearrangement list.
[0051] Assuming the initial candidate sequence output by the P2C engine is ["Circuit", "Circuit Competition", "Retrieve", "Instruction"], after weighted calculation of semantic score and pinyin matching score, the target scores obtained are 0.45, 0.38, 0.52, and 0.89, respectively. Sort them in descending order of score, generating an initial rearranged list of ["Instruction", "Retrieve", "Circuit", "Circuit Competition"]. This list serves as the final rearranged result, replacing the original P2C engine sort. This process achieves a shift from "frequency-first" to "priority based on both semantic and pinyin constraints," ensuring that in the context of "remembering", the semantically most reasonable "instruction" ranks first, thereby increasing the user's first-choice hit rate.
[0052] This embodiment provides an input method for sorting characters. It determines a candidate Chinese character sequence based on the input pinyin sequence, where each candidate character is sorted from highest to lowest frequency of occurrence. The method then obtains context text from a preset area on the terminal interface. A target score for each candidate character is determined based on the pinyin sequence, context text, and candidate character sequence. The candidate character sequence is then rearranged based on the target score to obtain a rearranged candidate character sequence. Finally, the target score for each candidate character is calculated comprehensively based on the context text, pinyin sequence, and candidate character sequence. This score combines the frequency of occurrence of the candidate character with its suitability to the current context. Compared to existing methods that rely solely on pinyin frequency matching for sorting, this method better matches the user's current input scenario, improves the efficiency of selecting target characters, and reduces the user's page-turning search operation cost.
[0053] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , step S30 includes steps S301 to S303: Step S301: Determine the semantic scores of each candidate Chinese character according to the context text and the candidate Chinese character sequence.
[0054] It can be understood that for each candidate Chinese character, semantic understanding can be combined with the context text that has been displayed on the screen to obtain the semantic scores of each candidate Chinese character. The semantic score is the semantic rationality score of each candidate Chinese character. The higher the score, the more natural the semantic collocation of the candidate Chinese character with the existing context and the more in line with the user's current expression intention. For example, if the context text is "铭记", the semantic score of "巡回" in the candidate Chinese characters is lower than that of "训诲".
[0055] In specific implementation, the context text can be concatenated with the current candidate Chinese character and then input into a pre-trained semantic model. The model outputs the smoothness probability or score of the complete text, and this probability or score is used as the semantic score of the current candidate Chinese character.
[0056] In a feasible implementation manner, step S301 can include steps B11 to B14: Step B11: Concatenate the context text and the candidate Chinese character sequence in a preset format to construct a scoring input text containing context identifiers and candidate identifiers; Specifically, after obtaining the context text (such as "铭记") and the candidate Chinese character sequence output by the P2C engine (such as "巡回", "寻回", "训诲"), instead of directly inputting them into the model, formatting construction is first performed. The preset format usually uses special markers to divide the boundaries. For example, it is constructed as: [上文]铭记 [候选1] 巡回 [候选2]巡回赛[候选3] 寻回 [候选4]训诲. Here, "[上文]" and "[候选N]" are the context identifier and the candidate identifier. This construction method can clearly inform the end-side large language model which part is the known context and which part is the candidate to be evaluated, so as to guide the model to accurately calculate the semantic rationality of the candidate text following the above context. It should be understood that the specific symbol form of the identifier is not limited to the above example, and any special character or Token sequence that can play a differentiating role is within the protection scope of this application.
[0057] Step B12: Obtain the target key-value cache corresponding to the pre-stored context text from a preset position; <00001The preset position is the memory position of the terminal device. This embodiment involves a reuse mechanism of KV-Cache (key-value cache), which is the key to reducing inference latency. In the input method scenario, the user input is a continuous process, and the context text does not often change significantly and frequently. If the complete context text is encoded for each scoring, it will bring huge computational overhead and latency. Therefore, this application pre-caches the calculation result of the context text to the preset position. Therefore, when the scoring calculation is required, the target key-value cache corresponding to the cached context text can be obtained from the preset position.
[0058] In a feasible implementation manner, before step B12, it further includes: obtaining the historical input text of a preset area of the terminal interface; inputting the historical input text into the large language model on the terminal side for forward inference to generate the key-value cache corresponding to the historical text; pre-storing the key-value cache to the preset position.
[0059] It should be noted that at the initial stage of construction, the text input by the user can be used as the historical input text, and the large language model on the terminal side is used to perform a complete forward inference on the historical input text, so as to generate the key-value cache of the historical input text, and store this key-value cache in the memory. Each time the user newly inputs pinyin and obtains the top-K candidate Chinese characters of the P2C engine, the cached KV-Cache is reused, and only the newly added K candidate sequences are incrementally forward-inferred to obtain semantic scores.
[0060] The LLM inference is completely completed on the device side, and the user's input content and context are not uploaded to the server. The KV-Cache is also retained in the local memory of the device, so as to protect user privacy.
[0061] For example, when the user completes the input of the two characters "铭记", a forward inference is automatically triggered in the background, calculates the Key and Value tensors corresponding to "铭记", and stores them in the preset position of the memory. When the user continues to input "xunhui" and triggers rearrangement, the system directly reads the cache from the preset position without re-encoding "铭记", thus greatly saving computational resources.
[0062] It can be understood that the memory occupancy of the KV-Cache is proportional to the model parameter scale and the context length. Taking the terminal-side LLM with 1B parameters and a context of 200 tokens as an example, the KV-Cache occupies about 2 to 8MB, which is much lower than the loading overhead of the model itself and has no significant impact on the memory of mobile devices.
[0063] In a feasible implementation manner, in order to ensure the real-time performance of the input method during continuous input, after step S40, it further includes: Sending the rearranged candidate Chinese character sequence to the candidate window of the input method for display; In response to the user's confirmation operation on the target Chinese character in the rearranged candidate Chinese character sequence, add the target Chinese character to the context text; Encode the target Chinese character to obtain encoded data, and add the encoded data to the key-value cache corresponding to the context text to update the key-value cache.
[0064] It should be noted that the candidate Chinese character sequence after joint scoring and rearrangement is pushed to the candidate bar on the UI layer through the standard interface of the input method framework for display. Specifically, the sorted candidate list is passed to the candidate bar output interface, which is responsible for rendering each candidate Chinese character in the list to the candidate window on the input method keyboard interface in the rearranged order. The rendering process includes passing parameters such as the text content, arrangement position, and display style of each candidate Chinese character to the rendering engine on the interface layer, and the rendering engine completes the final visual presentation. The candidate order seen by the user in the candidate window is no longer the original frequency sorting of the P2C engine, but the sorting result jointly optimized by the semantic scoring of the end-side large language model and the pinyin matching scoring.
[0065] The confirmation operation can include multiple triggering methods. The user can select and confirm by clicking on the target Chinese character in the candidate window, or directly input the candidate ranked first on the screen by pressing the space bar, or quickly select the candidate corresponding to the serial number by pressing the numeric key. When any of the above confirmation operations is captured, the confirmed target Chinese character becomes the final input result. For example, after seeing the rearranged candidate sequence, the user clicks to select "instruction" or inputs "instruction" ranked first on the screen by pressing the space bar, and resolves this confirmation event as an input operation for "instruction". Subsequently, append "instruction" to the end of the context text in the preset area of the terminal interface, and the context text is updated from the original "bear in mind" to "bear in mind instruction".
[0066] >When the user continues to input the next pinyin sequence, the end-side large language model will perform semantic scoring based on the updated context "bear in mind instruction", rather than just based on "bear in mind", so that the semantic understanding ability accumulates and deepens as the input progresses, further improving the accuracy of subsequent candidate sorting. It should be understood that the update of the context text is executed by the input text context manager, which maintains the complete sequence of the input text and automatically appends the newly input Chinese character after each confirmation operation, ensuring that the context text always remains synchronized with the actual display content in the preset area of the terminal interface.
[0067] This embodiment uses an "append" rather than a "rebuild" strategy to update the KV-Cache. Specifically, only the target Chinese character "instruction" newly confirmed to be displayed on the screen is token-encoded and forward-inferred, and the corresponding Key and Value tensors for this part are calculated and directly appended to the end of the original KV-Cache. The KV-Cache data corresponding to the original "remember" remains unchanged and is reused continuously, making the KV-Cache keep in sync with the text already displayed on the screen.
[0068] Through the above update process, it avoids re-encoding and calculating the entire context "remember instruction" every time an input is made. If the rebuild strategy is adopted, as the length of the user input increases and the context becomes longer and longer, the computational amount and latency of each encoding will increase linearly, eventually resulting in input method lag. However, with the append strategy, no matter how long the context is, the computational amount of updating the KV-Cache each time only depends on a few newly displayed Chinese characters, and the computational overhead is constant and extremely low. This enables the large language model on the terminal side to always maintain a response speed in milliseconds in the continuous input scenario, ensuring a smooth experience throughout the input method process.
[0069] Step B13: Input the target key-value cache and the scored input text into the large language model on the terminal side for incremental forward inference to obtain an inference result; It can be understood that incremental forward inference means that based on the existing context KV-Cache, only the newly input candidate Chinese character sequence part is encoded and attention calculated, and combined with the cached context information, an inference result for the candidate part is output. Compared with full inference where all contexts need to be re-encoded each time, the latency is about 50ms and users can perceive lag. This embodiment adopts incremental inference, only needs to encode a short candidate sequence, and the latency is less than 10ms, fully meeting the real-time requirement of the millisecond-level response of the input method. That is, the self-attention mechanism of the Transformer architecture allows the Key and Value tensors of historical calculations to be directly reused, avoiding repeated calculations.
[0070] Step B14: Obtain the semantic scores of each candidate Chinese character based on the inference result.
[0071] It can be understood that various specific calculation methods can be adopted to quantify semantic rationality.
[0072] As an implementation, step B14 may include: obtaining the conditional probability of each candidate Chinese character based on the inference result, and using the conditional probability as the semantic score of each candidate Chinese character.
[0073] It should be noted that the perplexity scoring method can be adopted, that is, calculate the conditional probability of each candidate Chinese character generated by the large language model under the given context, which is the reciprocal of the conditional perplexity. The conditional probability reflects the probability that the model generates the candidate text under the given previous context. The higher the probability, the smoother the candidate is semantically and the more in line with the context logic. For example, under the previous context of "铭记", the conditional probability that the model generates "训诲" may be higher than that of "巡回".
[0074] As another implementation, step B14 may include: obtaining the output value of the classification head output by the end-side large language model based on the inference result, and using the output value of the classification head as the semantic score of each candidate Chinese character.
[0075] This method requires adding an additional lightweight binary classification head to the output layer of the end-side large language model, which directly outputs a score value between 0 and 1, indicating the matching degree of the candidate text with the previous context. This method omits the calculation of probability normalization and improves the inference speed of the model.
[0076] Step S302: Determine the pinyin matching score of each candidate Chinese character according to the pinyin sequence and the candidate Chinese character sequence.
[0077] It should be noted that a pinyin matching score is calculated for each candidate Chinese character to measure the matching degree between the pinyin of the candidate Chinese character and the pinyin sequence actually input by the user.
[0078] The pinyin matching score is an important part of the "pinyin-semantic joint constraint" scoring mechanism constructed in this application. Relying solely on semantic scores for rearrangement may cause the end-side large language model to overly pursue semantic smoothness and recommend candidates with unmatched pinyin. For example, when the pinyin "xunhui" is input under the context of "铭记", the semantic model may consider "教诲" to be semantically smooth as well, but the pinyin of "教诲" is "jiaohui", which does not match the "xunhui" actually input by the user. Therefore, the introduction of the pinyin matching score sets a "deviation prevention" constraint for the rearrangement result, ensuring that the sorting result does not deviate from the user's pinyin input intention.
[0079] The pinyin matching score can be determined according to the matching degree between the pinyin of each candidate Chinese character in the candidate Chinese character sequence and the pinyin sequence input by the user.
[0080] In a feasible implementation, step S302 may include steps B21 to B23: Step B21: Convert the candidate Chinese character sequence into a corresponding standard pinyin sequence; It should be noted that a mapping table from Chinese characters to pinyin is pre - installed inside the terminal device. For each candidate Chinese character sequence output by the P2C engine, it is converted into a standard pinyin sequence by looking up the table. For example, the candidate "训诲" is converted to "xunhui", "巡回" is converted to "xunhui", and "教诲" is converted to "jiaohui".
[0081] Step B22: Compare the standard pinyin sequence with the pinyin sequence to obtain a comparison result; In a specific implementation, the standard pinyin sequence and the pinyin sequence can be compared one by one to obtain a comparison result on whether they are consistent.
[0082] In a feasible implementation manner, the comparison process not only includes exact matching, but also includes various situations such as fuzzy matching and initial consonant matching to adapt to the user's input habits, such as fuzzy sound settings.
[0083] Step B23: Determine the pinyin matching scores of each candidate Chinese character according to the comparison result.
[0084] Based on the comparison result, corresponding scores can be assigned according to a preset scoring rule to obtain the pinyin matching scores of each candidate Chinese character.
[0085] In a feasible implementation manner, step B23 may include: when the standard pinyin sequence is consistent with the pinyin sequence, determining that the pinyin matching score of the candidate Chinese character is the first preset score; when the standard pinyin sequence is consistent with the pinyin sequence within the error tolerance range of the preset sound, determining that the pinyin matching score of the candidate Chinese character is the second preset score; when the standard pinyin sequence and the pinyin sequence are only consistent in initial consonants, determining that the pinyin matching score of the candidate Chinese character is the third preset score, where the first preset score, the second preset score, and the third preset score decrease in sequence.
[0086] For example, when the user inputs "xunhui", the standard pinyin of the candidate "训诲" is also "xunhui", and the two are exactly the same. At this time, the pinyin matching score is recorded as 1.0, that is, the first preset score, indicating that the candidate exactly matches the user's input intention.
[0087] The error tolerance range of the preset sound usually refers to common fuzzy sound settings in the input method, such as front - back nasal sounds, flat - tongue and rolled - tongue sounds, etc. For example, when the user inputs "xunhui", the standard pinyin of the candidate "寻回" is also "xunhui", and the score is 1.0; if there is a candidate "xunhui", assumed to be a dialect variant, and the system enables the front - back nasal sound fuzzy, it may be determined to be consistent within the error tolerance range. At this time, the score is recorded as 0.7. This setting allows a relatively reasonable candidate to be given even when the user's input is not precise enough, but its priority is lower than exact matching.
[0088] It is understandable that if the standard pinyin sequence and the pinyin sequence only match in initials, that is, only the initials are the same in the simple pinyin mode, the pinyin matching score is set to the third preset score. For example, when the user inputs the simple pinyin "xh", the initials of the candidate "训诲" are "x" and "h", which are the same as the input. At this time, the score is recorded as 0.3. This setting supports the simple pinyin input scenario, but has the lowest priority. The score setting only needs to meet the principle that the full match score is the highest, the fuzzy match score is the second, and the initial match score is the lowest.
[0089] If the standard pinyin sequence and the pinyin sequence do not match at all, the pinyin matching score is 0.
[0090] Step S303: Determine the target score of each candidate Chinese character based on the pinyin matching score and the semantic score.
[0091] It should be noted that the final score of each candidate Chinese character can be calculated by weighted fusion of the pinyin matching score and the semantic score.
[0092] In a feasible implementation manner, the weight coefficients of the pinyin matching score and the semantic score can be set respectively, and then the final target score can be obtained according to the weight coefficients for calculation.
[0093] Specifically, step S303 may include steps B31 to B32: Step B31: Obtain the preset weight coefficients corresponding to the pinyin matching score and the semantic score; It should be noted that the preset weight coefficients can be fixed weight coefficients α and β. For example, α = 0.4 and β = 0.6 are set in advance, and other values can also be set, as long as α + β = 1.
[0094] In a feasible implementation manner, the preset weight coefficients can also be dynamically adjusted according to the length of the pinyin sequence currently input by the user. Therefore, the setting of the preset weight coefficients can include: determining the syllable length of the pinyin sequence; respectively setting the preset weight coefficients corresponding to the pinyin matching score and the semantic score according to the syllable length.
[0095] It should be noted that the syllable length refers to the number of syllables included in the pinyin sequence input by the user. For inputs of different lengths, the importance of semantics and pinyin is different. Specifically: When the syllable length is short (such as 1 to 2 syllables), there are fewer homophonic candidates and the context semantic discrimination is limited. At this time, accurate pinyin matching is more important. Therefore, α = 0.3 and β = 0.7 are set, that is, the pinyin weight is high and the semantic weight is low.
[0096] When the syllable length is medium (such as 3 syllables), the importance of semantics and pinyin is relatively balanced. Therefore, α = 0.5 and β = 0.5 are set.
[0097] When the syllable length is long (such as 4 syllables or more), the semantic difference of the candidate sequence significantly increases, and the context semantics plays a decisive role in differentiating candidates. For example, when the input is "jintiantianqi" (today's weather), the semantic model can accurately judge that "today's weather" is more reasonable than "today's apocalypse". Therefore, set α = 0.7 and β = 0.3, that is, the semantic weight is high and the pinyin weight is low.
[0098] Through this dynamic adjustment, the system can ensure the accuracy of pinyin input when short words are input, and give full play to the semantic understanding advantage of the edge large language model when long sentences are input, so as to achieve the optimal sorting effect in various input scenarios.
[0099] Step B32: Calculate the target score of each candidate Chinese character according to the preset weight coefficient, the pinyin matching score, and the semantic score.
[0100] In a specific implementation, the target score of each candidate Chinese character can be calculated according to the preset weight coefficient, the pinyin matching score, and the semantic score, and the calculation is as follows:
[0101] In the above formula, is the target score, is the semantic score of the i-th candidate Chinese character, is the pinyin matching score of the i-th candidate Chinese character.
[0102] In this embodiment, the semantic score of each candidate Chinese character is determined according to the context text and the candidate Chinese character sequence; the pinyin matching score of each candidate Chinese character is determined according to the pinyin sequence and the candidate Chinese character sequence; the target score of each candidate Chinese character is determined based on the pinyin matching score and the semantic score. Through the pinyin-semantic joint scoring, semantic drift is effectively prevented. The introduction of the pinyin matching score ensures that the rearrangement result does not deviate from the user's pinyin input intention, and avoids the edge large language model from recommending candidates with unmatched pinyin just because of semantic smoothness.
[0103] Exemplarily, in order to help understand the implementation process of the input method text sorting method obtained by combining the above Embodiment 1 in this embodiment, please refer to Figure 3 , Figure 3A simplified flowchart of an input method text sorting method is provided, including steps S1 to S8, specifically: S1: The user inputs a pinyin sequence, which is parsed by a pinyin parser, and then proceeds to S2: The P2C engine outputs multiple candidate Chinese characters, sorted from highest to lowest frequency of occurrence; S3: The context text and K candidate Chinese characters are concatenated to form the scoring input for the edge-side large language model, and the target key-value cache is input into the model; S4: The edge-side large language model uses the key-value cache (KV-Cache) for incremental inference to obtain the semantic score of each candidate Chinese character; S5: The pinyin matching score of each candidate Chinese character is calculated using a pinyin matching scorer; S6: A joint score is obtained by combining preset weight coefficients, pinyin matching scores, and semantic scores, with the weight coefficients adjusted according to the input length of the pinyin sequence; S7: The candidate column is rearranged in descending order according to the target score and output to the user; S8: After the user selects and confirms the text, new words can be added to the key-value cache, awaiting the next input.
[0104] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the text sorting method of the input method of this application. Any simple transformations based on this technical concept are within the protection scope of this application.
[0105] This application also provides an input method text sorting device, please refer to... Figure 4 The input method text sorting device includes: The determining module 10 is used to determine a candidate Chinese character sequence based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence.
[0106] The acquisition module 20 is used to acquire the context text of a preset area of the terminal interface.
[0107] The determining module 10 is further configured to determine the target score of each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence.
[0108] The rearrangement module 30 is used to rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence.
[0109] The input method text sorting device provided in this application employs the input method text sorting method in the above embodiments, which can solve the technical problem of low accuracy in text sorting in current input methods. Compared with the prior art, the beneficial effects of the input method text sorting device provided in this application are the same as those of the input method text sorting method provided in the above embodiments, and other technical features in the input method text sorting device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0110] The determining module is further configured to determine the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence; The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
[0111] In one embodiment, the determining module 10 is further configured to concatenate the context text and the candidate Chinese character sequence according to a preset format to construct a scoring input text containing a context identifier and a candidate identifier; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; Based on the reasoning results, semantic scores for each candidate Chinese character are obtained. In one embodiment, the determining module 10 is further configured to acquire historical input text in a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
[0112] In one embodiment, the determining module 10 is further configured to obtain the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model based on the reasoning result; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
[0113] In one embodiment, the determining module 10 is further configured to convert the candidate Chinese character sequence into a corresponding standard pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
[0114] In one embodiment, the determining module 10 is further configured to determine the pinyin matching score of the candidate Chinese character as a first preset score when the standard pinyin sequence is consistent with the pinyin sequence; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
[0115] In one embodiment, the determining module 10 is further configured to obtain preset weight coefficients corresponding to the pinyin matching score and the semantic score; The target score for each candidate Chinese character is calculated based on the preset weight coefficient, the pinyin matching score, and the semantic score.
[0116] In one embodiment, the determining module 10 is further configured to determine the syllable length of the pinyin sequence; Based on the syllable length, preset weight coefficients are set for the pinyin matching score and the semantic score, respectively.
[0117] In one embodiment, the rearrangement module 30 is further configured to sort the candidate Chinese character sequences in descending order according to the target score from high to low, and generate an initial rearrangement list; The rearranged candidate Chinese character sequence is obtained based on the initial rearrangement list.
[0118] In one embodiment, the device further includes an update module, which is used to send the rearranged candidate Chinese character sequence to the candidate window of the input method for display. In response to the user's confirmation of the target Chinese character in the rearranged candidate Chinese character sequence, the target Chinese character is added to the context text; The target Chinese character is encoded to obtain encoded data, and the encoded data is added to the key-value cache corresponding to the context text to update the key-value cache.
[0119] This application provides an input method text sorting device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the input method text sorting method in the above embodiment 1.
[0120] The following is for reference. Figure 5This document illustrates a structural schematic diagram of an input method text sorting device suitable for implementing embodiments of this application. The input method text sorting device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The input method text sorting device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0121] like Figure 5 As shown, the input method text sorting device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the input method text sorting device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the input method text sorting device to communicate wirelessly or wiredly with other devices to exchange data. Although input method text sorting devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0122] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0123] The input method text sorting device provided in this application, employing the input method text sorting method in the above embodiments, can solve the technical problem of low accuracy in text sorting in current input methods. Compared with the prior art, the beneficial effects of the input method text sorting device provided in this application are the same as those of the input method text sorting method provided in the above embodiments, and other technical features in this input method text sorting device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0124] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0125] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0126] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the input method text sorting method in the above embodiments.
[0127] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0128] The aforementioned computer-readable storage medium may be included in the input method text sorting device; or it may exist independently and not be assembled into the input method text sorting device.
[0129] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an input method text sorting device, cause the input method text sorting device to: determine a candidate Chinese character sequence based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; obtain context text of a preset area of the terminal interface; determine a target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence; and rearrange the candidate Chinese character sequence based on the target score to obtain a rearranged candidate Chinese character sequence.
[0130] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0131] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0132] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0133] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described input method text sorting method, which can solve the technical problem of low accuracy in text sorting in current input methods. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the input method text sorting method provided in the above embodiments, and will not be repeated here.
[0134] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the input method text sorting method described above.
[0135] The computer program product provided in this application can solve the technical problem of low accuracy in text sorting in current input methods. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the text sorting method for input methods provided in the above embodiments, and will not be repeated here.
[0136] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
[0137] This application discloses A1. A method for sorting characters in an input method, the method comprising: A candidate Chinese character sequence is determined based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; Obtain the context text of a preset area on the terminal interface; The target score for each candidate Chinese character is determined based on the pinyin sequence, the context text, and the candidate Chinese character sequence. The candidate Chinese character sequence is rearranged based on the target score to obtain the rearranged candidate Chinese character sequence.
[0138] A2. As described in A1, the step of determining the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence includes: The semantic score of each candidate Chinese character is determined based on the context text and the candidate Chinese character sequence. The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
[0139] A3. As described in A2, the step of determining the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence includes: The context text and the candidate Chinese character sequence are concatenated according to a preset format to construct a scoring input text containing context identifiers and candidate identifiers; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; The semantic scores of each candidate Chinese character are obtained based on the reasoning results.
[0140] A4. As described in A3, before the step of obtaining the pre-stored target key-value cache corresponding to the context text, the method further includes: Retrieve historical input text from a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
[0141] A5. As described in A3, the step of obtaining the semantic score of each candidate Chinese character based on the reasoning result includes: Based on the reasoning results, the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model is obtained; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
[0142] A6. As described in A2, the step of determining the pinyin matching score of each candidate Chinese character based on the pinyin sequence and the candidate Chinese character sequence includes: Convert the candidate Chinese character sequence into the corresponding standard Pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
[0143] A7. As described in A6, the step of determining the pinyin matching score of each candidate Chinese character based on the comparison result includes: When the standard pinyin sequence matches the pinyin sequence, the pinyin matching score of the candidate Chinese character is determined to be a first preset score; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
[0144] A8. As described in A2, the step of determining the target score for each candidate Chinese character based on the pinyin matching score and the semantic score includes: Obtain the preset weight coefficients corresponding to the pinyin matching score and the semantic score; The target score for each candidate Chinese character is calculated based on the preset weight coefficient, the pinyin matching score, and the semantic score.
[0145] A9. As described in A8, the step of obtaining the preset weight coefficients corresponding to the pinyin matching score and the semantic score includes: Determine the syllable length of the pinyin sequence; Based on the syllable length, preset weight coefficients are set for the pinyin matching score and the semantic score, respectively.
[0146] A10. The method as described in any one of A1 to A9, wherein the step of rearranging the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence includes: The candidate Chinese character sequences are sorted in descending order according to the target score from high to low to generate an initial rearrangement list; The rearranged candidate Chinese character sequence is obtained based on the initial rearrangement list.
[0147] A11. The method as described in any one of A1 to A9, wherein the method further comprises: The rearranged candidate Chinese character sequence is sent to the candidate window of the input method for display; In response to the user's confirmation of the target Chinese character in the rearranged candidate Chinese character sequence, the target Chinese character is added to the context text; The target Chinese character is encoded to obtain encoded data, and the encoded data is added to the key-value cache corresponding to the context text to update the key-value cache.
[0148] This application also discloses B12. An input method text sorting device, the device comprising: The determination module is used to determine a candidate Chinese character sequence based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; The acquisition module is used to acquire the context text of a preset area on the terminal interface. The determining module is further configured to determine the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence; The rearrangement module is used to rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence.
[0149] B13. The apparatus as described in B12, wherein the determining module is further configured to determine the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence; The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
[0150] B14. The apparatus as described in B13, wherein the determining module is further configured to concatenate the context text and the candidate Chinese character sequence according to a preset format to construct a scoring input text containing a context identifier and a candidate identifier; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; Based on the reasoning results, semantic scores for each candidate Chinese character are obtained. B15. The apparatus as described in B14, wherein the determining module is further configured to acquire historical input text in a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
[0151] B16. The apparatus as described in B14, wherein the determining module is further configured to obtain the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model based on the reasoning result; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
[0152] B17. The apparatus as described in B13, wherein the determining module is further configured to convert the candidate Chinese character sequence into a corresponding standard pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
[0153] B18. The apparatus as described in B17, wherein the determining module is further configured to determine the pinyin matching score of the candidate Chinese character as a first preset score when the standard pinyin sequence is consistent with the pinyin sequence; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
[0154] This application also discloses C19. An input method text sorting device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the input method text sorting method as described above.
[0155] This application also discloses D20. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the input method text sorting method as described above.
Claims
1. A text sorting method for an input method, characterized in that, The input method text sorting method includes: A candidate Chinese character sequence is determined based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; Obtain the context text of a preset area on the terminal interface; The target score for each candidate Chinese character is determined based on the pinyin sequence, the context text, and the candidate Chinese character sequence. The candidate Chinese character sequence is rearranged based on the target score to obtain the rearranged candidate Chinese character sequence.
2. The method as described in claim 1, characterized in that, The step of determining the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence includes: The semantic score of each candidate Chinese character is determined based on the context text and the candidate Chinese character sequence. The pinyin matching score of each candidate Chinese character is determined based on the pinyin sequence and the candidate Chinese character sequence. The target score for each candidate Chinese character is determined based on the pinyin matching score and the semantic score.
3. The method as described in claim 2, characterized in that, The step of determining the semantic score of each candidate Chinese character based on the context text and the candidate Chinese character sequence includes: The context text and the candidate Chinese character sequence are concatenated according to a preset format to construct a scoring input text containing context identifiers and candidate identifiers; Retrieve the target key-value cache corresponding to the pre-stored context text from the preset location; Incremental forward inference is performed on the target key-value cache and the large language model on the input side of the score input text to obtain the inference result; The semantic scores of each candidate Chinese character are obtained based on the reasoning results.
4. The method as described in claim 3, characterized in that, Before the step of obtaining the target key-value cache corresponding to the pre-stored context text, the method further includes: Retrieve historical input text from a preset area of the terminal interface; The historical input text input terminal side large language model is used for forward reasoning to generate the key-value cache corresponding to the historical text; The key-value cache is pre-stored in a preset location.
5. The method as described in claim 3, characterized in that, The step of obtaining the semantic score of each candidate Chinese character based on the reasoning result includes: Based on the reasoning results, the conditional probability of each candidate Chinese character or the classification head output value of the end-side large language model is obtained; The conditional probability or classification head output value is used as the semantic score for each candidate Chinese character.
6. The method as described in claim 2, characterized in that, The step of determining the pinyin matching score of each candidate Chinese character based on the pinyin sequence and the candidate Chinese character sequence includes: Convert the candidate Chinese character sequence into the corresponding standard Pinyin sequence; The standard pinyin sequence is compared with the pinyin sequence to obtain the comparison result; The pinyin matching score of each candidate Chinese character is determined based on the comparison results.
7. The method as described in claim 6, characterized in that, The step of determining the pinyin matching score of each candidate Chinese character based on the comparison results includes: When the standard pinyin sequence matches the pinyin sequence, the pinyin matching score of the candidate Chinese character is determined to be a first preset score; When the standard pinyin sequence and the pinyin sequence are consistent within the preset error tolerance range, the pinyin matching score of the candidate Chinese character is determined to be the second preset score; When the standard pinyin sequence and the pinyin sequence only have the same initial consonant, the pinyin matching score of the candidate Chinese character is determined to be a third preset score, wherein the first preset score, the second preset score and the third preset score decrease sequentially.
8. A text sorting device for an input method, characterized in that, The device includes: The determination module is used to determine a candidate Chinese character sequence based on the input pinyin sequence, wherein each candidate Chinese character in the candidate Chinese character sequence is sorted from high to low according to its frequency of occurrence; The acquisition module is used to acquire the context text of a preset area on the terminal interface. The determining module is further configured to determine the target score for each candidate Chinese character based on the pinyin sequence, the context text, and the candidate Chinese character sequence; The rearrangement module is used to rearrange the candidate Chinese character sequence based on the target score to obtain the rearranged candidate Chinese character sequence.
9. An input method text sorting device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the input method text sorting method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the input method text sorting method as described in any one of claims 1 to 7.