1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to LLMs in Python

Connected

Exercise

Evaluating perplexity

Try your had at generating text and evaluating the perplexity score.

You've been provided some input_text that is the start of a sentence: "Current trends show that by 2030 ".

Use an LLM to generate the rest of the sentence.

An AutoModelForCausalLM model and its tokenizer have been loaded for you as model and tokenizer variables.

Instructions

100 XP
  • Encode the input_text and pass it to the provided text generation model.
  • Load and compute the mean_perplexity score on the generated text.