Text prediction method and device, electronic equipment and storage medium

By using prefix tree matching and parallel verification techniques in generative orientation scenarios, the problem that the prefix tree constraint model does not bring performance advantages in generating token range in existing technologies is solved, and efficient and accurate text prediction generation is achieved.

CN121581200APending Publication Date: 2026-02-27BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511657808.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-12
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In generative orientation scenarios, while using prefix trees to constrain the range of tokens generated by the model reduces the candidate range, it does not bring performance advantages, resulting in limited efficiency and accuracy of the generated results.

Method used

By encoding and decoding the input information, the target prefix tree is determined using prefix tree matching. When the parallel verification trigger condition is met, the subsequent paths of the candidate token sequence are verified in parallel to obtain the verification result of the full token sequence, and finally the target predicted text of the input information is determined.

Benefits of technology

It improves the efficiency and accuracy of text prediction, ensuring the validity and integrity of the generated results while improving performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121581200A_ABST
    Figure CN121581200A_ABST
Patent Text Reader

Abstract

The invention provides a text prediction method and device, electronic equipment and a storage medium, and relates to the technical field of data processing, in particular to the technical field of artificial intelligence and large models. According to the specific implementation scheme, the method comprises the following steps: encoding and decoding input information to predict a candidate token sequence; performing prefix tree matching based on the candidate token sequence, and determining a corresponding target prefix tree; and in response to the condition that the candidate token sequence meets a parallel verification triggering condition, performing parallel verification on a plurality of candidate paths after the candidate token sequence based on the target prefix tree to obtain a verification result of a full token sequence, and determining a target prediction text of the input information according to the verification result of the full token sequence, and the prediction efficiency is improved while the prediction accuracy is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, specifically to the field of artificial intelligence and large model technology, and particularly to a text prediction method, apparatus, electronic device and storage medium. Background Technology

[0002] In generative orientation scenarios, prefix trees are needed to constrain the range of tokens generated by the model. The candidate range of the model's generated results is greatly reduced compared to ordinary autoregressive decoding without prefix trees, but it does not bring any performance advantage. Summary of the Invention

[0003] This disclosure provides a text prediction method, apparatus, electronic device, and storage medium.

[0004] According to one aspect of this disclosure, a text prediction method is provided, comprising: The input information is encoded and decoded to predict candidate token sequences; Based on the candidate token sequence, perform prefix tree matching to determine the corresponding target prefix tree; In response to the candidate token sequence satisfying the parallel verification triggering condition, multiple candidate paths following the candidate token sequence are verified in parallel based on the target prefix tree to obtain the verification result of the full token sequence, wherein the candidate path includes at least one ordered token, and the full token sequence includes the candidate token sequence and the at least one ordered token. Based on the verification results of the full token sequence, the target predicted text of the input information is determined.

[0005] According to another aspect of this disclosure, a text prediction apparatus is provided, comprising: The prediction module is used to encode and decode the input information to predict the candidate token sequence; The matching module is used to perform prefix tree matching based on the candidate token sequence to determine the corresponding target prefix tree; A verification module is configured to, in response to the candidate token sequence satisfying the parallel verification trigger condition, perform parallel verification on multiple candidate paths following the candidate token sequence based on the target prefix tree to obtain the verification result of the full token sequence, wherein the candidate path includes at least one ordered token, and the full token sequence includes the candidate token sequence and the at least one ordered token. The acquisition module is used to determine the target predicted text of the input information based on the verification result of the full token sequence.

[0006] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.

[0007] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described in any one of the first aspects.

[0008] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the steps of the method described in any of the first aspects.

[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is a schematic diagram of a text prediction method provided in an embodiment of this disclosure; Figure 2 This is a schematic diagram of a prefix tree structure provided in an embodiment of this disclosure; Figure 3 This is a schematic diagram of another text prediction method provided in an embodiment of this disclosure; Figure 4 This is an exemplary distribution curve of time consumption difference provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of another text prediction method provided in an embodiment of this disclosure; Figure 6 This is a logic diagram of a text prediction method provided in an embodiment of this disclosure; Figure 7 This is a schematic diagram of the structure of a text prediction device provided in an embodiment of this disclosure; Figure 8 A schematic block diagram of an electronic device used to implement embodiments of the present disclosure is shown. Detailed Implementation

[0011] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0012] Data processing is the collection, storage, retrieval, processing, transformation, and transmission of data. Its basic purpose is to extract and derive valuable and meaningful data from large amounts of potentially messy and difficult-to-understand data.

[0013] Artificial intelligence (AI) is a new technological science that studies and develops theories, methods, technologies, and application systems to simulate, extend, and expand human intelligence. It attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence.

[0014] A large model is a machine learning model with a large number of parameters and a complex structure. Its purpose is to improve the model's expressive power and predictive performance, enabling it to process massive amounts of data and complete various complex tasks, such as natural language processing, computer vision, and speech recognition.

[0015] Figure 1 This is a schematic diagram of a text prediction method provided in an embodiment of this disclosure. Figure 1 As shown, the method includes: S101, the input information is encoded and decoded to predict the candidate token sequence.

[0016] Optionally, the input information can be raw information such as text or images. The input information is encoded to extract its feature information and converted into a semantic vector or feature representation that the model can understand.

[0017] The feature information obtained after encoding the input information is input into the decoder for decoding processing, thereby predicting one or more candidate token sequences. In this embodiment, the candidate tokens can be characters or words.

[0018] S102, perform prefix tree matching based on candidate token sequences to determine the corresponding target prefix tree.

[0019] A prefix tree is a multi-way tree structure used for efficient storage and retrieval of string collections. It reduces space waste by sharing a common prefix. Each node represents a character, and the path from the root node to a leaf node constitutes the string. Strings sharing a prefix share the same path, saving space. Figure 2 The diagram shows a prefix tree structure.

[0020] Optionally, the target prefix tree can be obtained by querying the prefix tree library based on the domain to which the current candidate token sequence belongs. The prefix tree library may include prefix trees constructed from dictionaries of different domains.

[0021] Optionally, a query can be performed from the prefix tree library based on the current candidate token sequence to obtain a prefix tree containing the candidate token sequence as the target prefix tree.

[0022] S103, in response to the candidate token sequence satisfying the parallel verification trigger condition, based on the target prefix tree, perform parallel verification on multiple candidate paths following the candidate token sequence to obtain the verification result of the full token sequence.

[0023] Optionally, the last token in the candidate token sequence is taken as the current token node, and it is determined whether the current token node has a performance benefit. In this embodiment, the existence of a performance benefit for the current token node is determined when the candidate token sequence meets the parallel verification trigger condition. The existence of a performance benefit can mean that the duration of parallel verification is less than the duration of decoding verification one by one. The duration of parallel verification can be determined according to the number of tokens to be verified in parallel, and the duration of decoding verification can be determined according to the total number of tokens on the path.

[0024] Furthermore, when the candidate token sequence meets the parallel verification triggering condition, multiple candidate paths following the candidate token sequence are verified in parallel. It can be understood that parallel verification means performing verification analysis on all candidate paths at the same time, obtaining all verification results through a single decoding process, reducing the decoding call coefficient and improving performance benefits.

[0025] In some embodiments, the multiple candidate paths following the candidate token sequence are different branch paths corresponding to the candidate token sequence in the target prefix tree. That is, each child node branch corresponding to the last token of the candidate token sequence in the target prefix tree is a candidate path. The candidate path includes at least one ordered token. The order of the tokens refers to their order in the target prefix tree. The order of the corresponding tokens is determined based on the vertical connection relationship between nodes. In this embodiment, the token is a character or a word.

[0026] Optionally, all candidate paths can be validated in parallel based on a large model to obtain a complete and valid full token sequence. The full token sequence includes candidate token sequences and at least one ordered token. That is, the full token sequence consists of candidate token sequences and all ordered tokens in the candidate paths. The large model outputs the validation result of each full token sequence. In this embodiment, the validation result can be the result of whether the full token sequence is valid, such as the probability that the full token sequence is valid.

[0027] S104, Based on the verification results of the full token sequence, determine the target predicted text of the input information.

[0028] Optionally, the probability of each full token sequence being valid can be determined based on the verification results, and the full token sequence with the highest probability can be used as the target predicted text of the input information.

[0029] In this embodiment, candidate token sequences are obtained and matched with the corresponding target prefix trees. It is determined whether the candidate token sequences meet the parallel verification trigger conditions, that is, whether there is a performance improvement when parallel verification is enabled at the current token position. When the conditions are met, the candidate paths are verified in parallel according to the target prefix tree. While ensuring performance benefits, the verification efficiency of the candidate paths is improved. The accurate verification results of each full token sequence are obtained by combining the large model. Based on the verification results, the final target prediction text is determined, which ensures prediction accuracy while improving prediction efficiency.

[0030] Figure 3 This is a schematic diagram of another text prediction method provided in an embodiment of this disclosure. For example... Figure 3 As shown, the method includes: S301 encodes and decodes the input information to predict the candidate token sequence.

[0031] In this embodiment of the disclosure, the method for implementing step S301 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0032] S302, perform prefix tree matching based on candidate token sequences to determine the corresponding target prefix tree.

[0033] In some embodiments, a predictive prefix tree can be constructed based on the candidate token sequence, which is built using the prefix information of the predicted candidate token sequence.

[0034] Furthermore, structural matching is performed on the predicted prefix tree and the candidate prefix trees to obtain structural similarity; based on the structural similarity, the target prefix tree is determined from the candidate prefix trees.

[0035] In some embodiments, the candidate prefix tree can be a pre-built prefix tree, such as a prefix tree from the historical generation process or a prefix tree corresponding to each domain dictionary.

[0036] Optionally, the structural matching between the predicted prefix tree and the candidate prefix tree can be based on the matching of parameters such as the number of nodes, branch depth, and prefix coverage. For example, the structural similarity can be determined by calculating the cosine similarity between each parameter, and the candidate prefix tree with the highest structural similarity to the predicted prefix tree can be selected as the target prefix tree to improve the accuracy of the target prefix tree acquisition.

[0037] In this application embodiment, the implementation method of step S302 can be implemented in any of the various embodiments of this disclosure, and no limitation is made here, nor will it be described in detail.

[0038] S303, determine the first node in the target prefix tree corresponding to the last token in the candidate token sequence.

[0039] For example, assuming the candidate token sequence is "I love", including candidate tokens "I" and "love", where the last token is "love", then the node of the last token "love" in the target prefix tree is determined as the first node.

[0040] S304. Based on the first node, determine the verification trigger parameters corresponding to the candidate token sequence.

[0041] Based on the target prefix tree and the first node, determine the nodes located on the candidate paths. The candidate path is the path from the first node to different leaf nodes. Each character on the candidate path is a node. For example, if the first node is "love", the candidate paths can include three paths: "Tiananmen", "Forbidden City" and "Temple of Earth". For the candidate path "Tiananmen", the nodes on the candidate path include "tian", "an", and "men".

[0042] In some embodiments, the verification trigger parameters corresponding to the candidate token sequence can be determined based on the nodes on the candidate path. More appropriate verification trigger parameters can be adaptively obtained based on real-time node information. In this embodiment, the verification trigger parameters are used to determine whether the parallel verification trigger conditions are met, thereby improving the accuracy of the analysis.

[0043] Optionally, the verification trigger parameters may include parallel verification time and decoding call time. In this embodiment, the parallel verification time of the first node can be determined based on the nodes on the candidate path; the decoding call time of the first node can be determined based on the nodes on the candidate path.

[0044] In some embodiments, the number of first tokens for a candidate path can be determined based on the nodes of the candidate path. In this embodiment, the number of first tokens is the same as the number of nodes. For example, if the candidate path is "Tiananmen", then the number of first tokens is 3.

[0045] The maximum number of tokens is determined from the number of tokens in the candidate paths corresponding to the first node. Based on the maximum number of tokens, the parallel verification time of the first node is determined. The parallel verification time can be understood as the number of tokens to be verified, which more accurately reflects the parallel verification overhead. For example, when the candidate paths are "Tiananmen", "Forbidden City" and "Ditan", the maximum number of tokens is the number of tokens in the first path corresponding to "Tiananmen", which is 3. In this embodiment, the number of tokens is used as the parallel verification time. Therefore, when the maximum number of tokens is 3, the parallel verification time of the first node is 3.

[0046] In some embodiments, the number of second tokens in the candidate token sequence can be determined, and the number of decoding calls for each candidate path corresponding to the first node can be determined based on the number of second tokens and the number of first tokens. For example, if the candidate token sequence is "I love", then the number of second tokens is 2, and the number of decoding calls can be the sum of the number of first tokens and the number of second tokens. For example, if the candidate path is "Tiananmen", then the number of first tokens is 3, and the number of decoding calls is 5; if the candidate path is "Forbidden City", then the number of first tokens is 2, and the number of decoding calls is 4.

[0047] The decoding call time of the first node is determined based on the maximum number of decoding calls in each path. In this embodiment, the maximum number of decoding calls in all paths is used as the decoding call time of the first node. Performance benefit analysis based on decoding call time is more accurate. For example, if the maximum number of decoding calls is for the path "I love Tiananmen", then the decoding call time of the first node is 5.

[0048] Optionally, the verification trigger parameter can also be the first time difference of the first node. In this embodiment, the first time difference is the difference between the decoding call time of the node itself and the parallel verification time.

[0049] In some embodiments, the labeling information of the first node can be determined from the node labeling information of the target prefix tree. The node labeling information includes at least the decoding call time and parallel verification time calculated in advance based on the target prefix tree. Therefore, the first time difference of the first node can be obtained from the labeling information of the first node. That is, the decoding call time and parallel verification time of the first node are obtained based on the labeling information of the first node, and the difference between the decoding call time and parallel verification time of the first node is calculated as the first time difference of the first node.

[0050] S305, based on the verification trigger parameters, determine whether the candidate token sequence meets the parallel verification trigger conditions.

[0051] Optionally, if the verification trigger parameters are the parallel verification time and the decoding call time, then if the parallel verification time is less than the decoding call time, the candidate token sequence is determined to meet the parallel verification trigger condition, and each node is promptly determined to meet the parallel verification trigger condition, thus improving the efficiency of starting parallel verification.

[0052] Optionally, if the verification trigger parameter is the first time difference of the first node, then when the first time difference is at its peak, it is determined that the candidate token sequence meets the parallel verification trigger condition, and parallel verification is started at the point of maximum performance gain, resulting in higher verification efficiency.

[0053] In some embodiments, the parent and child nodes of the first node can be determined based on the target prefix tree, and the second time difference of the parent node and the third time difference of the child node can be determined. It is understood that the second time difference of the parent node and the third time difference of the child node are both obtained based on the difference between the decoding call time and the parallel verification time of their own nodes.

[0054] If the first time difference is greater than the second time difference and also greater than the third time difference, the first time difference is determined to be the peak value. Figure 4 The example distribution curve of the time consumption difference is shown.

[0055] S306, in response to the candidate token sequence satisfying the parallel verification trigger condition, based on the target prefix tree, perform parallel verification on multiple candidate paths following the candidate token sequence to obtain the verification result of the full token sequence.

[0056] In this embodiment of the disclosure, the method for implementing step S306 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0057] S307, Based on the verification results of the full token sequence, determine the target predicted text of the input information.

[0058] In this embodiment of the disclosure, the method for implementing step S307 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0059] In this embodiment, a corresponding prediction prefix tree is constructed based on the candidate token sequence. Then, a matching is performed based on the pre-constructed check prefix tree following the prediction prefix tree to obtain the corresponding target prefix tree. Based on the first node corresponding to the last token in the current candidate token sequence in the target prefix tree, the corresponding verification trigger parameter is determined. The verification trigger parameter is used to accurately evaluate whether the current candidate token sequence meets the parallel verification trigger condition to ensure that there is a significant performance gain during parallel verification. When the parallel verification trigger condition is met, multiple candidate paths are verified in parallel based on the target prefix tree to obtain the verification result of the entire token sequence. Based on the verification result, the target predicted text of the input information is obtained, ensuring prediction accuracy while improving prediction efficiency.

[0060] Figure 5 This is a schematic diagram of another text prediction method provided in an embodiment of this disclosure. For example... Figure 5 As shown, the method includes: S501 encodes and decodes the input information to predict the candidate token sequence.

[0061] In this embodiment of the disclosure, the method for implementing step S501 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0062] S502, perform prefix tree matching based on candidate token sequences to determine the corresponding target prefix tree.

[0063] In this embodiment of the disclosure, the method for implementing step S502 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0064] S503, determine the first node in the target prefix tree corresponding to the last token in the candidate token sequence.

[0065] In this embodiment of the disclosure, the method for implementing step S503 can be implemented in any of the various embodiments of the disclosure, and no limitation is made here, nor will it be described in detail.

[0066] S504, based on the verification trigger parameters, determines whether the candidate token sequence meets the parallel verification trigger conditions.

[0067] In this embodiment of the disclosure, the method for implementing step S504 can be implemented in any of the various embodiments of this disclosure, and no limitation is made here, nor will it be described in detail.

[0068] S505, if there are multiple candidate token sequences, in response to the fact that the verification trigger parameters of multiple candidate token sequences all meet the parallel verification trigger condition, based on the target prefix tree, multiple candidate paths following the candidate token sequence are verified in parallel to obtain the verification result of the full token sequence.

[0069] It is understandable that when there are multiple candidate token sequences, each candidate token sequence needs to be analyzed. Parallel verification is triggered when the verification trigger parameters of all candidate token sequences meet the parallel verification trigger conditions.

[0070] In this embodiment of the disclosure, the method for implementing step S505 can be implemented in any of the various embodiments of this disclosure, and no limitation is made here, nor will it be described in detail.

[0071] S506, For any candidate token sequence, compare the verification results of the full token sequence associated with the candidate token sequence.

[0072] For example, assuming any candidate token sequence is "I love", its corresponding associated full token sequences include "I love Tiananmen", "I love the Forbidden City" and "I love the Temple of Heaven", the verification results of all full token sequences are compared. In this embodiment, the verification results include at least the corresponding predicted probabilities.

[0073] S507, From the associated full token sequences, determine the full token sequence with the highest predicted probability, and use it as the target full token sequence for the candidate token sequence.

[0074] S508: Based on the target full token sequence of the candidate token sequence, obtain the target predicted text.

[0075] Optionally, the target full token sequence corresponding to the candidate token sequence can be used as the target predicted text to ensure the validity and completeness of the generated target predicted text.

[0076] In this embodiment, candidate token sequences are acquired and matched with corresponding target prefix trees. Based on the first node corresponding to the last token in the current candidate token sequence in the target prefix tree, the corresponding verification trigger parameters are determined. The current candidate token sequence is accurately evaluated based on the verification trigger parameters to ensure that there is a significant performance gain during parallel verification. When the parallel verification trigger conditions are met, the candidate paths are verified in parallel according to the target prefix tree, which improves the verification efficiency of candidate paths while ensuring performance gains. When there are multiple candidate token sequences, parallel verification is performed when all candidate token sequences meet the parallel verification trigger conditions. The accurate verification results of the full token sequences associated with each candidate token sequence are obtained by combining the large model. The target full token sequence with the highest prediction probability is selected from the full token sequences associated with the candidate token sequences. All remaining tokens are obtained through a single decoding, reducing the number of decoding calls and improving performance gains, thereby obtaining the final target predicted text. This ensures the validity and completeness of the target predicted text, guaranteeing prediction accuracy while improving prediction efficiency.

[0077] Figure 6 This is a logic diagram of a text prediction method provided in this embodiment. It encodes and decodes user input information and performs beamsearch to obtain one or more prediction candidate token sequences. The number of tokens retained when generating the candidate token sequence is related to the beam size. It determines whether the condition for adaptive triggering of prefix tree parallel verification is met based on the last token of the candidate token sequence. When the parallel verification condition is met, all candidate paths are used as input for parallel verification to obtain the verification results of all full token sequences associated with each candidate token sequence. The decoding process is accelerated through parallel verification, thereby obtaining accurate and effective target predicted text.

[0078] Figure 7 This is a schematic diagram of the structure of a text prediction device provided in an embodiment of this disclosure. Figure 7 As shown, the text prediction device 700 includes: The prediction module 701 is used to encode and decode the input information to predict the candidate token sequence; Matching module 702 is used to perform prefix tree matching based on candidate token sequences to determine the corresponding target prefix tree; The verification module 703 is used to perform parallel verification on multiple candidate paths following the candidate token sequence based on the target prefix tree in response to the candidate token sequence meeting the parallel verification trigger condition, so as to obtain the verification result of the full token sequence, wherein the candidate path includes at least one ordered token, and the full token sequence includes the candidate token sequence and at least one ordered token. The acquisition module 704 is used to determine the target predicted text of the input information based on the verification result of the full token sequence.

[0079] In some embodiments, the verification module 703 is configured to: Determine the first node corresponding to the last token in the candidate token sequence in the target prefix tree; Based on the first node, determine the verification trigger parameters corresponding to the candidate token sequence; Based on the verification trigger parameters, determine whether the candidate token sequence meets the parallel verification trigger conditions.

[0080] In some embodiments, the verification module 703 is configured to: Based on the target prefix tree and the first node, determine the nodes located on the candidate path; Based on the nodes on the candidate path, determine the verification trigger parameters corresponding to the candidate token sequence.

[0081] In some embodiments, the verification module 703 is configured to: Determine the parallel verification time of the first node based on the nodes on the candidate path; Based on the nodes on the candidate path, determine the decoding call time of the first node, where the verification trigger parameters include the parallel verification time and the decoding call time; Based on the verification trigger parameters, determine whether the candidate token sequence meets the parallel verification trigger conditions, including: If the parallel verification time is less than the decoding call time, the candidate token sequence is determined to meet the parallel verification trigger condition.

[0082] In some embodiments, the verification module 703 is configured to: Determine the first token count for each candidate path based on its nodes; Determine the maximum number of tokens from the first number of tokens in the candidate paths corresponding to the first node; The parallel verification time of the first node is determined based on the maximum number of tokens.

[0083] In some embodiments, the verification module 703 is configured to: Determine the first token count for each candidate path based on its nodes; Determine the number of second tokens in the candidate token sequence; Based on the number of second tokens and the number of first tokens, determine the number of decoding calls for each candidate path corresponding to the first node; The decoding call time of the first node is determined based on the maximum number of decoding calls in each path.

[0084] In some embodiments, the verification module 703 is configured to: Determine the labeling information of the first node from the node labeling information of the target prefix tree; Obtain the first time difference of the first node from the tagging information of the first node; The first time difference of the first node is determined as the verification trigger parameter; Based on the verification trigger parameters, determine whether the candidate token sequence meets the parallel verification trigger conditions, including: When the first time difference reaches its peak, the candidate token sequence is determined to meet the parallel verification triggering condition.

[0085] In some embodiments, the verification module 703 is further configured to: Based on the target prefix tree, determine the parent and child nodes of the first node; Determine the second time difference of the parent node and the third time difference of the child node; In response to the first time difference being greater than the second time difference and also greater than the third time difference, the first time difference is determined to be the peak value; Each time difference is the difference between the decoding call time of its own node and the parallel verification time.

[0086] In some embodiments, there are multiple candidate token sequences, and the verification module 703 is further configured to: Parallel verification is triggered when the verification trigger parameters of each candidate token sequence meet the parallel verification trigger conditions.

[0087] In some embodiments, there are multiple candidate token sequences, and the acquisition module 704 is used for: For any candidate token sequence, compare the verification results of the full token sequence associated with the candidate token sequence; From the associated full token sequences, determine the full token sequence with the highest predicted probability, and use it as the target full token sequence for the candidate token sequence; The target predicted text is obtained from the target full token sequence based on the candidate token sequence.

[0088] In some embodiments, the matching module 702 is configured to: Construct a prediction prefix tree based on the candidate token sequence; Structural similarity is obtained by performing structural matching between the predicted prefix tree and the candidate prefix tree; Based on structural similarity, the target prefix tree is determined from the candidate prefix trees.

[0089] In this embodiment, candidate token sequences are obtained and matched with corresponding target prefix trees. Based on the first node corresponding to the last token in the current candidate token sequence in the target prefix tree, the corresponding verification trigger parameters are determined. The verification trigger parameters are used to accurately evaluate whether the current candidate token sequence meets the parallel verification trigger conditions to ensure that there is a significant performance gain during parallel verification. When the parallel verification trigger conditions are met, the candidate paths are verified in parallel according to the target prefix tree. This improves the verification efficiency of candidate paths while ensuring performance gains. When there are multiple candidate token sequences, parallel verification is performed when all candidate token sequences meet the parallel verification trigger conditions. The large model is used to obtain the accurate verification results of the full token sequences associated with each candidate token sequence. The target full token sequence with the highest prediction probability is selected from the full token sequences associated with the candidate token sequences to obtain the final target prediction text. This ensures the validity and completeness of the target prediction text and improves prediction efficiency while ensuring prediction accuracy.

[0090] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0091] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0092] Figure 8 A schematic block diagram of an electronic device for implementing embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0093] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

[0094] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0095] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as text prediction methods. For example, in some embodiments, the text prediction method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the text prediction method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the text prediction method by any other suitable means (e.g., by means of firmware).

[0096] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0097] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0098] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0099] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0100] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0101] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0102] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0103] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A text prediction method, wherein, The method includes: The input information is encoded and decoded to predict candidate token sequences; Based on the candidate token sequence, perform prefix tree matching to determine the corresponding target prefix tree; In response to the candidate token sequence satisfying the parallel verification triggering condition, multiple candidate paths following the candidate token sequence are verified in parallel based on the target prefix tree to obtain the verification result of the full token sequence, wherein the candidate path includes at least one ordered token, and the full token sequence includes the candidate token sequence and the at least one ordered token. Based on the verification results of the full token sequence, the target predicted text of the input information is determined.

2. The method according to claim 1, wherein, The process of determining whether the candidate token sequence satisfies the parallel verification triggering condition includes: Determine the first node in the target prefix tree corresponding to the last token in the candidate token sequence; Based on the first node, determine the verification trigger parameters corresponding to the candidate token sequence; Based on the verification trigger parameters, determine whether the candidate token sequence satisfies the parallel verification trigger condition.

3. The method according to claim 2, wherein, The step of determining the verification trigger parameters corresponding to the candidate token sequence based on the first node includes: Based on the target prefix tree and the first node, determine the node located on the candidate path; Based on the nodes on the candidate path, determine the verification trigger parameters corresponding to the candidate token sequence.

4. The method according to claim 3, wherein, The step of determining the verification trigger parameters corresponding to the candidate token sequence based on the nodes on the candidate path includes: Based on the nodes on the candidate path, determine the parallel verification time of the first node; Based on the nodes on the candidate path, the decoding call time of the first node is determined, wherein the verification triggering parameter includes the parallel verification time and the decoding call time; Determining whether the candidate token sequence satisfies the parallel verification triggering condition based on the verification triggering parameters includes: In response to the fact that the parallel verification time is less than the decoding call time, the candidate token sequence is determined to meet the parallel verification triggering condition.

5. The method according to claim 4, wherein, The step of determining the parallel verification time of the first node based on the nodes on the candidate path includes: Based on the nodes of the candidate path, determine the first token count for the candidate path; Determine the maximum number of tokens from the first number of tokens for the candidate paths corresponding to the first node; The parallel verification time of the first node is determined based on the maximum number of tokens.

6. The method according to claim 4, wherein, The step of determining the decoding call time of the first node based on the nodes on the candidate path includes: Based on the nodes of the candidate path, determine the first token count for the candidate path; Determine the number of second tokens in the candidate token sequence; Based on the number of the second token and the number of the first token, determine the number of decoding calls for each candidate path corresponding to the first node; The decoding call time of the first node is determined based on the maximum number of decoding calls in each path.

7. The method according to claim 2, wherein, The step of determining the verification trigger parameters corresponding to the candidate token sequence based on the first node includes: The tagging information of the first node is determined from the node tagging information of the target prefix tree; Obtain the first time difference of the first node from the marking information of the first node; The first time difference of the first node is determined as the verification trigger parameter; Based on the verification triggering parameters, determining whether the candidate token sequence satisfies the parallel verification triggering condition includes: In response to the first time difference being at its peak, the candidate token sequence is determined to meet the parallel verification triggering condition.

8. The method according to claim 7, wherein, The method further includes: Based on the target prefix tree, determine the parent node and child node of the first node; Determine the second time difference of the parent node and the third time difference of the child node; In response to the first time consumption difference being greater than the second time consumption difference and also greater than the third time consumption difference, the first time consumption difference is determined to be the peak value; Each time difference is the difference between the decoding call time of its own node and the parallel verification time.

9. The method according to any one of claims 2-8, wherein, The candidate token sequence is multiple, and the method further includes: The parallel verification is triggered when the verification trigger parameters of each candidate token sequence all meet the parallel verification trigger condition.

10. The method according to any one of claims 1-8, wherein, The candidate token sequences are multiple, and the step of determining the target predicted text of the input information based on the verification results of the full token sequences includes: For any of the candidate token sequences, the verification results of the full token sequences associated with the candidate token sequence are compared; From the associated full token sequences, determine the full token sequence with the highest predicted probability, and use it as the target full token sequence of the candidate token sequences; The target predicted text is obtained from the target full token sequence of the candidate token sequence.

11. The method according to any one of claims 1-8, wherein, The step of performing prefix tree matching based on the candidate token sequence to determine the corresponding target prefix tree includes: Based on the candidate token sequence, construct a prediction prefix tree; Structural matching is performed on the predicted prefix tree and the candidate prefix tree to obtain structural similarity; Based on the structural similarity, the target prefix tree is determined from the candidate prefix trees.

12. A text prediction device, comprising: The prediction module is used to encode and decode the input information to predict the candidate token sequence; The matching module is used to perform prefix tree matching based on the candidate token sequence to determine the corresponding target prefix tree; A verification module is configured to, in response to the candidate token sequence satisfying the parallel verification trigger condition, perform parallel verification on multiple candidate paths following the candidate token sequence based on the target prefix tree to obtain the verification result of the full token sequence, wherein the candidate path includes at least one ordered token, and the full token sequence includes the candidate token sequence and the at least one ordered token. The acquisition module is used to determine the target predicted text of the input information based on the verification result of the full token sequence.

13. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-11.

15. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-11.