Question Details

No question body available.

Tags

javascript c# .net

Answers (4)

March 18, 2026 Score: 0 Rep: 39,346 Quality: Medium Completeness: 30%

What is the actual goal? Spellchecking? Save typing time? Provide writing guidance?

What are the constraints? Does it need to run locally? Are there any limitations on size or compute?

LLMs typically use a "temperature" parameter to control how deterministic it should be, and you can always use zero to make it fully deterministic. If size or runtime is a problem there are small language models that use the same transformer models, but with fewer parameters. There are also various kinds of older and simpler text prediction algorithms, like Markov Chains.

A dictionary based algorithm can also be perfectly feasible. But a fundamental problem is knowing what dictionary to use. This can become a problem when mixing languages, using some kind of markup, or when writing code.

If you are using a dictionary based approach it might be sufficient to just do a binary search in a sorted list, at least that is the option I would start with. I would also try to make this function run locally if possible, since it can be difficult to ensure sufficiently low latency when making remote calls.

March 18, 2026 Score: 0 Rep: 187 Quality: Low Completeness: 30%

I think that one start point could be using a prefix tree (aka Trie). Take a look at this post:

https://stackoverflow.com/a/79607234/30186697

March 18, 2026 Score: 0 Rep: 29,029 Quality: Low Completeness: 40%

You can use a relatively simple data structure called a ternary tree for this. Google ternary tree autocomplete. You can also use a trie, as Eddi suggests, but they tend to use a lot more memory.

March 18, 2026 Score: 0 Rep: 369 Quality: Low Completeness: 30%

There's the editor ... and there's the "incremental search"; as I see it. The user is presented with an ever decreasing list of words and phrases as they type. The trick is melding the two. I've used the pattern in call center address lookups, for example. That's the "text" option. In other cases, the "prefixes" and words appear as sets of buttons that change content which each "level". (The "touch" option). "Backspace" goes (back) up the "search" (tree). It doesn't have to be a tree. In-memory searching is very fast ... you can easily return all phrases containin the same prefix, word or words in no time. And I eliminate all "single letter" words, etc. from any "searchable words" beforehand. First thing, create a "word dictionary" of all your content; so you never look for a word you don't have. Then "learn" your data and you'll see "patterns" that will help you model. You might be surprised how few unique words and phrases you wind up with for the chosen problem domain.