rdgozum / next-word-prediction

Generative Pretrained Transformer 2 (GPT-2) for Language Modeling using the PyTorch-Transformers library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to get probability of next word?

orenschonlab opened this issue · comments

@rdgozum Is there a way to get probability of specidic next word?
For example,

>>> from next_word_prediction import GPT2
>>> gpt2 = GPT2()
>>> text = "The course starts next"
>>> gpt2.get_next_prob(text, 'semester')
0.024

What will be the best way to implement such function?

If not does it maybe rank by list of most probable first in the result ?

@sktguha The function actually returns k words ranked from highest probability.

ohh that's nice , thanks. actually one issue I find is it doesn't predict word completion
only full next words are returned. any package you might know that does that ??

Thanks in Advance