Is perplexity correctly computed?

オープン
#560 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python

調査の方向性

提供された evaluate および datasets のスニペットを使い、指定されたモデル、Wikitext split、パッケージバージョンで問題を再現する。結果をリンクされた LLaMA の議論および Transformers の perplexity チュートリアルと比較する。メトリクスまたはその使用方法が誤っているかどうかを判断し、確認された不一致を文書化または修正できれば完了とする。

索引モデルが issue の本文から書いたものです。

説明

Hello. I'm struggling with replicating the reported perplexity (~6) for LLaMa-2-7b.
I am using this simple code snippet:

import evaluate
import datasets

perplexity = evaluate.load("perplexity", module_type="metric")
input_texts = datasets.load_dataset("wikitext",
                                    "wikitext-2-raw-v1",
                                    split="test")["text"]
input_texts = [s for s in input_texts if s!='']
results = perplexity.compute(
    model_id="sharpbai/Llama-2-7b-hf",
    batch_size=4,
    predictions=input_texts
)
print(results)

And I get among the results: 'mean_perplexity': 60.9764459149642.
In this tutorial it is computed "approximately" by flattening the dataset into a string and by computing the avg. sliding window perplexity. I still get a high perplexity.
I tried to change the model in the code snippet to openai-community/gpt2 and the perplexity is above 600!
Does this depend on using the correct model class?
Thank you for any suggestion.

EDIT: I'm using the following versions

transformers              4.38.2
evaluate                  0.4.1
datasets                  2.18.0 

主要言語
Python
スター
2.5k
フォーク
368
平均マージ
48分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

huggingface/evaluate のほかの issue

huggingface/evaluate の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。