1. Learn
  2. /
  3. 课程
  4. /
  5. Python 中的 LLM 入门

Connected

道练习

评估困惑度(perplexity)

动手生成文本并评估困惑度分数。

已为您提供一句话的开头 input_text:"Current trends show that by 2030 "。

使用一个 LLM 生成该句子的其余部分。

已为您加载 AutoModelForCausalLM 模型及其分词器,分别存放在变量 model 和 tokenizer 中。

说明

100 XP
  • 对 input_text 进行编码,并将其传入提供的文本生成模型。
  • 加载并计算生成文本的 mean_perplexity 分数。