Lighteval 文件

儲存和讀取結果

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

儲存和讀取結果

在本地儲存結果

Lighteval 將自動將結果和評估詳情儲存在透過 --output-dir 選項設定的目錄中。結果將儲存在 {output_dir}/results/{model_name}/results_{timestamp}.json這是一個結果檔案的示例。輸出路徑可以是任何與 fsspec 相容的路徑(本地、s3、hf hub、gdrive、ftp 等)。

要儲存評估的詳細資訊,可以使用 --save-details 選項。詳細資訊將儲存在一個 parquet 檔案中:{output_dir}/details/{model_name}/{timestamp}/details_{task}_{timestamp}.parquet

將結果推送到 Hugging Face Hub

您可以將結果和評估詳情推送到 Hugging Face Hub。為此,您需要設定 --push-to-hub 以及 --results-org 選項。結果將儲存在名為 {results_org}/{model_org}/{model_name} 的資料集中。要推送詳情,您需要設定 --save-details 選項。建立的資料集預設是私有的,您可以透過設定 --public-run 選項將其設為公開。

將結果推送到 Tensorboard

您可以透過設定 --push-to-tensorboard 將結果推送到 Tensorboard。這將在透過 --results-org 選項設定的 HF 組織中建立一個 Tensorboard 面板。

將結果推送到 WandB

您可以透過設定 --wandb 將結果推送到 WandB。這將初始化一個 WandB 執行並記錄結果。

Wandb 引數需要在您的環境變數中設定。

export WANDB_PROJECT="lighteval"

您可以在 wandb 文件 中找到變數列表。

如何載入和研究詳情

從本地詳情檔案載入

from datasets import load_dataset
import os

output_dir = "evals_doc"
model_name = "HuggingFaceH4/zephyr-7b-beta"
timestamp = "latest"
task = "lighteval|gsm8k|0"

if timestamp == "latest":
    path = f"{output_dir}/details/{model_org}/{model_name}/*/"
    timestamps = glob.glob(path)
    timestamp = sorted(timestamps)[-1].split("/")[-2]
    print(f"Latest timestamp: {timestamp}")

details_path = f"{output_dir}/details/{model_name}/{timestamp}/details_{task}_{timestamp}.parquet"

# Load the details
details = load_dataset("parquet", data_files=details_path, split="train")

for detail in details:
    print(detail)

從 Hugging Face Hub 載入

from datasets import load_dataset

results_org = "SaylorTwift"
model_name = "HuggingFaceH4/zephyr-7b-beta"
sanitized_model_name = model_name.replace("/", "__")
task = "lighteval|gsm8k|0"
public_run = False

dataset_path = f"{results_org}/details_{sanitized_model_name}{'_private' if not public_run else ''}"
details = load_dataset(dataset_path, task.replace("|", "_"), split="latest")

for detail in details:
    print(detail)

詳情檔案包含以下列

  • choices: 在多選題任務中呈現給模型的選項。
  • gold: 黃金答案。
  • gold_index: 黃金答案在選項列表中的索引。
  • cont_tokens: 續寫(continuation)的 token。
  • example: 文字形式的輸入。
  • full_prompt: 將輸入到模型的完整提示。
  • input_tokens: 完整提示的 token。
  • instruction: 給模型的指令。
  • metrics: 為該示例計算的指標。
  • num_asked_few_shots: 請求模型的少樣本(few shot)數量。
  • num_effective_few_shots: 有效的少樣本數量。
  • padded: 輸入是否被填充。
  • pred_logits: 模型的 logits。
  • predictions: 模型的預測結果。
  • specifics: 任務的細節。
  • truncated: 輸入是否被截斷。

結果檔案示例

{
  "config_general": {
    "lighteval_sha": "203045a8431bc9b77245c9998e05fc54509ea07f",
    "num_fewshot_seeds": 1,
    "override_batch_size": 1,
    "max_samples": 1,
    "job_id": "",
    "start_time": 620979.879320166,
    "end_time": 621004.632108041,
    "total_evaluation_time_secondes": "24.752787875011563",
    "model_name": "gpt2",
    "model_sha": "607a30d783dfa663caf39e06633721c8d4cfcd7e",
    "model_dtype": null,
    "model_size": "476.2 MB"
  },
  "results": {
    "lighteval|gsm8k|0": {
      "qem": 0.0,
      "qem_stderr": 0.0,
      "maj@8": 0.0,
      "maj@8_stderr": 0.0
    },
    "all": {
      "qem": 0.0,
      "qem_stderr": 0.0,
      "maj@8": 0.0,
      "maj@8_stderr": 0.0
    }
  },
  "versions": {
    "lighteval|gsm8k|0": 0
  },
  "config_tasks": {
    "lighteval|gsm8k": {
      "name": "gsm8k",
      "prompt_function": "gsm8k",
      "hf_repo": "gsm8k",
      "hf_subset": "main",
      "metric": [
        {
          "metric_name": "qem",
          "higher_is_better": true,
          "category": "3",
          "use_case": "5",
          "sample_level_fn": "compute",
          "corpus_level_fn": "mean"
        },
        {
          "metric_name": "maj@8",
          "higher_is_better": true,
          "category": "5",
          "use_case": "5",
          "sample_level_fn": "compute",
          "corpus_level_fn": "mean"
        }
      ],
      "hf_avail_splits": [
        "train",
        "test"
      ],
      "evaluation_splits": [
        "test"
      ],
      "few_shots_split": null,
      "few_shots_select": "random_sampling_from_train",
      "generation_size": 256,
      "generation_grammar": null,
      "stop_sequence": [
        "Question="
      ],
      "num_samples": null,
      "suite": [
        "lighteval"
      ],
      "original_num_docs": 1319,
      "effective_num_docs": 1,
      "trust_dataset": true,
      "must_remove_duplicate_docs": null,
      "version": 0
    }
  },
  "summary_tasks": {
    "lighteval|gsm8k|0": {
      "hashes": {
        "hash_examples": "8517d5bf7e880086",
        "hash_full_prompts": "8517d5bf7e880086",
        "hash_input_tokens": "29916e7afe5cb51d",
        "hash_cont_tokens": "37f91ce23ef6d435"
      },
      "truncated": 2,
      "non_truncated": 0,
      "padded": 0,
      "non_padded": 2,
      "effective_few_shots": 0.0,
      "num_truncated_few_shots": 0
    }
  },
  "summary_general": {
    "hashes": {
      "hash_examples": "5f383c395f01096e",
      "hash_full_prompts": "5f383c395f01096e",
      "hash_input_tokens": "ac933feb14f96d7b",
      "hash_cont_tokens": "9d03fb26f8da7277"
    },
    "truncated": 2,
    "non_truncated": 0,
    "padded": 0,
    "non_padded": 2,
    "num_truncated_few_shots": 0
  }
}
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.