Views
No views yet
wikipedia, oscar). Within each directory, you will find several models trained on different language subsets of the dataset (e.g. en (English), es (Spanish), fr (French)). For each language you will find three different files{language}.arpa.bin: The trained KenLM model binary{language}.sp.model: The trained SentencePiece model used for tokenization{language}.sp.vocab: The vocabulary file for the SentencePiece modellower_case, remove_accents, normalize_numbers and punctuation when using the pre-trained models in order to replicate the same pre-processing steps at inference time.pip install https://github.com/kpu/kenlm/archive/master.zippip install sentencepiecefrom model import KenlmModel
# Load model trained on English wikipedia
model = KenlmModel.from_pretrained("wikipedia", "en")
# Get perplexity
model.get_perplexity("I am very perplexed")
# 341.3 (low perplexity, since sentence style is formal and with no grammar mistakes)
model.get_perplexity("im hella trippin")
# 46793.5 (high perplexity, since the sentence is colloquial and contains grammar mistakes)