Downstream Validation Using Eleuther Eval Harness
This page walks through the steps for performing downstream validation on the Cerebras Wafer-Scale cluster using EleutherAI’s Evaluation Harness (EEH). EEH is a popular framework for evaluating large language models across various different datasets and tasks.
While you can configure EEH as part of your training (see Pretraining with Downstream Validation from the Cerebras Model Zoo.
The examples in this guide will perform downstream validation on LLaMA3 8B.
By the end of this guide, you will be able to leverage the EEH framework to perform standalone downstream validation on your models on CS-X.
To skip ahead to the examples covered in this guide without following the entire walk through, please follow the links:
Prerequisites
Please ensure that you have installed the Cerebras Model Zoo package by going through the installation guide. Note that EEH version tested and packaged in the Cerebras Model Zoo is the official release v0.4.2.
Please also read through the Trainer Overview and Trainer Configuration Overview, as these guides will help understand how to configure running EEH standalone.
This guide configures the downstream EEH run using V2 YAML. While release 2.3 includes support for legacy V1 YAML, please convert the configuration to V2 using convert_legacy_params_to_trainer_params
from the script src/cerebras/modelzoo/trainer/utils.py
.
Configure the Run
This section covers the required steps for setting up an EEH run to perform standalone downstream validation on various tasks.
In particular, you will need to write a YAML configuration file to configure an instance of the Trainer
callback.
The example in this section configures evaluation for LLaMA3 8B
via the multiple choice (non-generative) eval harness task winogrande
using a single CSX.
If you aren’t interested in seeing the break down of the configuration, feel free to skip ahead to the Putting it All Together section to see the full YAML configuration.
Configure the CSX Backend
The first step is to specify the CSX backend and resources required for the run.
Please create a YAML configuration file with the following cluster config:
This example uses a single CSX, but you can readily update num_csx
to run EEH on multiple CSXs for improved performance.
Configure the Model
Next, please add the following model configuration in the YAML for LLaMA3 8B with 8K context length:
To run downstream validation harness, you must specify the name
setting in the model configuration. Valid names corresponding to the supported models include:
-
btlm
-
bloom
-
gpt2
-
gptj
-
falcon
-
gpt3
-
gpt-neox
-
llama
-
mistral
-
mpt
-
jais
-
santacoder
-
starcoder
Configure the EEH Callback
EEH is implemented as an extension to the Trainer
callback.
Add the following section in the YAML to set up the EleutherEvalHarness
callback:
The eeh_args
section exposes the following settings to configure the EEH run:
Eleuther Eval Harness CLI Arguments | Description |
---|---|
--tasks | Comma separated string specifying Eleuther Eval Harness tasks. To get full list of tasks, use the command lm-eval --tasks list from within your python venv. |
--num_fewshot | Number of examples to be added to the fewshot context string. Defaults to 0 |
--output_path | The path to the output file where the result metrics will be saved. If the path is a directory and log_samples is true, the results will be saved in the directory. Else the parent directory will be used. |
--limit | Accepts an integer, or a float between 0.0 and 1.0. This limits the number of documents to evaluate per task to the first X documents (if an integer) or first X% of documents. This is useful for debugging. |
--use_cache | A path to a sqlite db file for caching model responses. None if not caching. |
--cache_requests {true,refresh,delete} | Speed up evaluation by caching the building of dataset requests. None if not caching. |
--check_integrity | Whether to run the relevant part of the test suite for the tasks. |
--write_out | Prints the prompt for the first few documents. Defaults to False. |
--log_samples | If True, write out all model outputs and documents for per-sample measurement and post-hoc analysis. Defaults to False. |
--show_config | If True, shows the the full config of all tasks at the end of the evaluation. Defaults to False. |
--include_path | Additional path to include if there are external tasks to include. |
--predict_only | Use with –log_samples. Only model outputs will be saved and metrics will not be evaluated. |
--seed | Set seed for python’s random, numpy and torch. |
--temperature | Sampling temperature used for generation (autoregressive, generate_until tasks only). |
--top_p | Top-p parameter used for nucleus sampling (autoregressive, generate_until tasks only). |
--top_k | Top-k parameter used for generation (autoregressive, generate_until tasks only). |
You can either specify the settings here or pass them via CLI arguments to the standalone EEH run script.
The callback configuration also accepts dataloader settings that you must specify in the YAML to set up input data preprocessing for the run:
DataLoader Settings | Description |
---|---|
data_dir | This setting is required. Provide a path to the mounted directory visible to the worker containers where eval harness task data samples are dumped after preprocessing. Use the mount_dirs argument to specify a dir mount, similar to our existing flows. |
tokenizer_file_path | Path to a custom tokenizer (JSON) file. If you provide a custom tokenizer, then you must also specify eos_id ; otherwise, you must provide a pretrained tokenizer from Hugging Face in pretrained_model_name_or_path . |
pretrained_model_name_or_path | Hugging Face (HF) pretrained model name or path. This setting is required if you do not specify tokenizer_file_path . For detailed description, see HF AutoTokenizers. |
eos_id | End-of-sentence (eos) token ID to signal the termination of a sequence. This setting is required if you specify a custom tokenizer in tokenizer_file_path . You can set this by looking for the ID corresponding to the eos token in the custom tokenizer JSON file. |
max_sequence_length | Maximum length of the input sequence. This setting is required for preprocessing input data samples from the specified eval harness tasks. You should align the max_sequence_length field to the max_position_embeddings value in the model configuration of the YAML. If you don’t specify max_sequence_length , the flow defaults to this max_position_embeddings setting. |
Additionally, you may optionally specify the following, CSX-specific eval harness setting:
keep_data_dir
: Use this to preserve the preprocessed eval harness task data samples, i.e. the directory specified underdata_dir
. Defaults to False, i.e. data samples are deleted after the run.
(Optional) Configure HuggingFace (HF) Cache Directory
EEH utilizes HF’s APIs to download task data and other configurations. This data is by default cached under $HOME/.cache/huggingface
.
However, you may choose to specify a different directory for this cached data via the HFCacheDir
callback:
Putting it All Together
Here’s what the full YAML configuration looks like once you follow this guide for configuring the individual pieces:
Running EEH on CS-X
Now that the the YAML configuration is complete, you will use the run script src/cerebras/modelzoo/common/run_eleuther_eval_harness.py
from the Cerebras Model Zoo to run EEH on various tasks.
This script accepts the following command line interface (CLI) arguments:
-
We support a subset of Eleuther’s command line interface (CLI) arguments above. For a more detailed descrition of these supported arguments, see https://github.com/EleutherAI/lm-evaluation-harness/blob/v0.4.0/docs/interface.md.
-
You may also specify these arguments in the YAML under the
eeh_args
key of theEleutherEvalHarness
configuration, but please note that the CLI setting will override the settings in the YAML. -
The
--params
CLI argument is required. Use it to specify the path to the YAML configuration file. Note that while we do support the old V1 YAML specification, it will soon be deprecated so we recommend using the new V2 YAML. -
Use the
--checkpoint_path
CLI argument to specify the path to the checkpoint file to load model weights from. If a checkpoint path is not provided, we support checkpoint autoloading in this flow such that the latest checkpoint file will be picked up from the specifiedmodel_dir
.
Supported Tasks
-
As of our 2.4.0 release, we support
lm_eval@v0.4.5
. -
You may perform downstream validation on all EEH tasks with
output_type: loglikelihood
oroutput_type: multiple_choice
in the task specification. See asdiv and arc_easy for respective examples. You may specify each of these types of tasks separately or together in a singleEleutherEvalHarness
callback. -
We currently do not support eval harness tasks with
output_type: loglikelihood_rolling
. These unsupported tasks arepile
andwikitext
for the supported EEH version 0.4.2.-
agieval
-
babi
-
bbh
-
bbh_cot_fewshot
-
bbh_cot_zeroshot
-
bbh_fewshot
-
bbh_zeroshot
-
bigbench
-
codexglue_code2text
-
math_word_problems
-
mgsm_direct
-
mgsm_cot_native
-
mmlu_flan_cot_fewshot
-
mmlu_flan_cot_zeroshot
-
mmlu_flan_n_shot_generative
-
polemo2
-
super-glue-lm-eval-v1
-
unscramble
-
Adding New Tasks
Please refer to Eleuther’s new task implementation guide here to add new tasks.
Limitations
-
We currently do not support running multiple generative eval harness tasks in the same callback.
-
EEH task groups, such as agieval, comprise multiple generative sub tasks that you will have to configure in the YAML via separate callbacks.
-
Please turn on grad accumulation and choose a small micro batch size (between 16 to 32) under the
flags
configuration of theEleutherEvalHarness
callback of the YAML,
Conclusion
In summary, by following this guide you have run standalone downstream validation for the Llama3-8B model on EEH’s multiple different evaluation datasets / tasks.
You should now be comfortable in configuring more downstream EEH runs on your model of choice on even more eval harness tasks.
What’s next?
To run downstream validation on code generation tasks, please see check out:
You can also perform downstream validation using EEH as part of your pretraining runs with upstream validation. Check out the following guide: