diff --git a/nanochat/core_eval.py b/nanochat/core_eval.py index f3c9a9f..06508c1 100644 --- a/nanochat/core_eval.py +++ b/nanochat/core_eval.py @@ -174,7 +174,7 @@ def evaluate_example(idx, model, tokenizer, data, device, task_meta): # Sample few-shot examples (excluding current item) fewshot_examples = [] - if num_fewshot > 0: + if num_fewshot > 0 and len(data) > num_fewshot: rng = random.Random(1234 + idx) available_indices = [i for i in range(len(data)) if i != idx] fewshot_indices = rng.sample(available_indices, num_fewshot)