Menu

Language Model

Help
Anuj Kumar
2011-06-07
2012-09-22
  • Anuj Kumar

    Anuj Kumar - 2011-06-07

    I have a language model, and I want to obtain the list of alternative words
    (along with their scores) when I input a phrase.

    For instance, if I feed in the word "Good" in a n-gram language model, it
    outputs possible next words as "Morning", "Afternoon", "Evening", "Night",
    etc. in a "conversations-based" language model.

    Would anyone know how to do that?

     
  • Nickolay V. Shmyrev

    The algorithm to select this is trivial, you just check all possible word
    combinations and select the best follower

    String w1 = "good";
    String bestWord = null;
    float bestProb = -10000;
    for (Word w : words) {
          if (languageModel.prob(w1, w) > bestProb) {
                bestProb = languageModel.prob(w1, w);
                bestWord = w;
         }
    }
    

    If you want to do this quickly and repeatedly, you need to precompile this
    information into a separate structure.

     
  • Nickolay V. Shmyrev

    And please next time when you post something try to select a more descriptive
    subject. Something like "Prediction of most probable following word with a
    language model" is way better name of the topic than "Language Model".

     

Log in to post a comment.