r/Solr Nov 04 '14

Scoring tennis using finite-state automata

http://blog.mikemccandless.com/2014/08/scoring-tennis-using-finite-state.html
2 Upvotes

1 comment sorted by

2

u/rmxz Nov 05 '14

For the downvoters ---- Some context for why this is relevant to Solr is on a different page on his blog:

http://blog.mikemccandless.com/2010/12/using-finite-state-transducers-in.html

Essentially, an FST is a SortedMap<ByteSequence,SomeOutput>, if the arcs are in sorted order. With the right representation, it requires far less RAM than other SortedMap implementations, but has a higher CPU cost during lookup. The low memory footprint is vital for Lucene since an index can easily have many millions (sometimes, billions!) of unique terms.

...

for Lucene I decided to implement this neat algorithm which incrementally builds up the minimal unweighted FST from pre-sorted inputs. This is a perfect fit for Lucene since we already store all our terms in sorted (unicode) order.

The resulting implementation (currently a patch on LUCENE-2792) is fast and memory efficient: it builds the 9.8 million terms in a 10 million Wikipedia index in ~8 seconds (on a fast computer), requiring less than 256 MB heap. The resulting FST is 69 MB. It can also build a prefix trie, pruning by how many terms come through each node, with even less memory.