shuffle few shot examples

This commit is contained in:
hiyouga 2023-09-23 00:53:20 +08:00
parent 2340b0d7df
commit ef1ea1aead
1 changed files with 2 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import os
import fire
import json
import torch
import random
import numpy as np
from tqdm import tqdm
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Tuple
@ -48,6 +49,7 @@ class EvalTemplate:
history = [self.parse_example(support_set[k]) for k in range(len(support_set))]
if len(history):
random.shuffle(history)
temp = history.pop(0)
history.insert(0, (self.system.format(subject=subject_name) + temp[0], temp[1]))
else: