Trie-Based Wordpiece Tokenization Without Backtracking
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing natural language processing (NLP) techniques for word or wordpiece tokenization are inefficient, particularly in identifying the longest matching tokens, leading to excessive computational time and resource utilization due to the need for backtracking and additional post-processing steps.
Innovation Solution
A left-to-right greedy process using a trie structure with precomputed tokens and fail links allows for a single-pass tokenization, identifying only the longest matching prefix and suffix wordpieces without the need for backtracking, thereby optimizing the tokenization process.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If traditional tokenization methods are used with backtracking and post-processing, then complete wordpiece identification is achieved, but computational time and resource utilization increase excessively
Solution Approach 1:
The patent precomputes and stores longest matching prefix and suffix wordpieces at each node of the trie structure during vocabulary construction. This preliminary computation eliminates the need for backtracking and post-processing during actual tokenization, achieving both complete wordpiece identification and linear time complexity O(n) by having all necessary information ready in advance.
Solution Approach 2:
The patent segments the tokenization process into two independent phases: a precomputation phase where longest matching wordpieces are calculated and stored at each trie node, and an execution phase where these precomputed values are simply retrieved during tokenization. This segmentation separates the computationally intensive part from the execution part, enabling efficient single-pass processing without backtracking.
2Measurement precision
If backtracking and post-processing steps are included in tokenization, then all matching tokens are identified, but device complexity and processing steps increase
Solution Approach 1:
The patent performs all complex matching computations in advance during vocabulary construction, storing the results in the trie structure. During actual tokenization, the process simply follows precomputed paths and retrieves stored wordpiece information, reducing the execution phase to simple linear scanning without any backtracking or post-processing logic.
Solution Approach 2:
The patent extracts the complex computational logic from the tokenization execution phase and relocates it to the precomputation phase. By taking out the heavy lifting work and performing it beforehand, the actual tokenization process becomes a simple single-pass traversal that only retrieves precomputed information, significantly reducing processing steps.
3Productivity
If a trie structure with precomputed tokens is used, then single-pass tokenization is achieved, but vocabulary structure and memory requirements change
Solution Approach 1:
The patent precomputes and stores longest matching prefix and suffix wordpieces at each node of the trie structure during vocabulary construction. This preliminary computation enables single-pass tokenization by having all necessary matching information readily available in the trie, achieving linear time complexity O(n) without requiring complex backtracking logic during execution.
Solution Approach 2:
The patent embeds multiple levels of information within the trie structure: the trie nodes store both the current character path and precomputed longest matching wordpieces. This nested organization of data allows the system to maintain a compact vocabulary structure while storing comprehensive matching information, balancing memory requirements with processing efficiency.
Data Source
AI summary
Systems and methods for performing inference for word or wordpiece tokenization are disclosed using a left-to-right longest-match-first greedy process. In some examples, the vocabulary may be organized into a trie structure in which each node includes a precomputed token or token_ID and a fail link, so that the tokenizer can parse the trie in a single pass to generate a list of only those tokens or token_IDs that correspond to the longest matching vocabulary entries in the sample string, without the need for backtracking. In some examples, the vocabulary may be organized into a trie in which each node has a fail link, and any node that would share token(s) or token_ID(s) of a preceding node is instead given a prev_match link that points back to a chain of nodes with those token(s) or token_ID(s).


