File size: 1,438 Bytes
a77edda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# /// script
# dependencies = ["lighteval", "torch", "transformers", "datasets", "accelerate"]
# ///
import sys, os

MODEL = "Nanthasit/sakthai-plus-1.5b"
BASELINE = "Qwen/Qwen2.5-1.5B-Instruct"
TASKS = os.environ.get("TASKS") or (sys.argv[2] if len(sys.argv) > 2 else "mmlu|0,gsm8k|0,hellaswag|0,winogrande|0")
COMPARE = "--compare" in sys.argv

models = [MODEL]
if COMPARE:
    models.append(BASELINE)

from lighteval.logging.evaluation_tracker import EvaluationTracker
from lighteval.models.transformers.transformers_model import TransformersModelConfig
from lighteval.pipeline import ParallelismManager, Pipeline, PipelineParameters

for model in models:
    name = model.split("/")[-1]
    print(f"\n=== Evaluating {name} ===")

    evaluation_tracker = EvaluationTracker(
        output_dir=f"./results/{name}",
        save_details=True,
        push_to_hub=False,
    )
    pipeline_params = PipelineParameters(
        launcher_type=ParallelismManager.ACCELERATE,
    )
    model_config = TransformersModelConfig(
        model_name=model,
        dtype="bfloat16",
    )

    pipeline = Pipeline(
        tasks=TASKS,
        pipeline_parameters=pipeline_params,
        evaluation_tracker=evaluation_tracker,
        model_config=model_config,
    )
    pipeline.evaluate()
    pipeline.show_results()
    pipeline.save_and_push_results()

results = pipeline.get_results()
print(f"\nResults: {results}")