Hostname: page-component-74656f9884-kv2lp Total loading time: 0 Render date: 2026-11-06T00:01:31.320Z Has data issue: false hasContentIssue false

A fast and flexible architecture for very large word n-gram datasets

Published online by Cambridge University Press:  10 January 2012

MICHAEL FLOR*
Affiliation:
NLP and Speech Group, Educational Testing Service, Princeton, NJ 08541, USA e-mail: mflor@ets.org
Rights & Permissions [Opens in a new window]

Abstract

This paper presents TrendStream, a versatile architecture for very large word n-gram datasets. Designed for speed, flexibility, and portability, TrendStream uses a novel trie-based architecture, features lossless compression, and provides optimization for both speed and memory use. In addition to literal queries, it also supports fast pattern matching searches (with wildcards or regular expressions), on the same data structure, without any additional indexing. Language models are updateable directly in the compiled binary format, allowing rapid encoding of existing tabulated collections, incremental generation of n-gram models from streaming text, and merging of encoded compiled files. This architecture offers flexible choices for loading and memory utilization: fast memory-mapping of a multi-gigabyte model, or on-demand partial data loading with very modest memory requirements. The implemented system runs successfully on several different platforms, under different operating systems, even when the n-gram model file is much larger than available memory. Experimental evaluation results are presented with the Google Web1T collection and the Gigaword corpus.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 2012
Figure 0

Fig. 1. Generic data structure for a trie, with word-level granularity and words on level i+1 grouped into blocks by shared prefix on level i.

Figure 1

Fig. 2. (a) Schematic character-level trie for a set of words (with fictional counts). (b) Same trie as a linked-list data structure (with: syntagmatic → and ‘alternative’ ↓ links). End-of-word nodes are shaded for illustration.

Figure 2

Fig. 3. Schematic outline for word n-gram trie, with character-level granularity. Shaded triangles represent sub-trees.

Figure 3

Table 1. Fields for a mutable hybrid TST node

Figure 4

Table 2. Serialized record structure for a TST node

Figure 5

Table 3. Original and filtered Google Web1T n-grams (unique n-gram types)

Figure 6

Table 4. Statistics for n-grams collection generated from the Gigaword 2003 corpus

Figure 7

Table 5. TrendStream retrieval performance for 2- and 5-grams, with two different models on several different platforms

Figure 8

Table 6. TrendStream retrieval performance for 2- and 5-grams with all Google Web1T data on a high-end Linux server

Figure 9

Table 7. TrendStream retrieval performance for 2- and 5-grams, for one test file with two different models on several different platforms

Figure 10

Table 8. TrendStream retrieval performance for some wildcard and regex queries with Web1T.f database

Figure 11

Table 9. Rough comparison of various n-gram storage systems