"tests/pipelines/vscode:/vscode.git/clone" did not exist on "9b37ed33b5fa09e594b38e4e6f7477beff3bd66a"
Unverified Commit 538b4393 authored by Haodong Duan's avatar Haodong Duan Committed by GitHub
Browse files

[Fix] Fix seed in HFEvaluator (#122)

parent 46c96457
import random
from typing import List
import evaluate
import numpy as np
from opencompass.registry import ICL_EVALUATORS
......@@ -12,10 +14,15 @@ class HuggingfaceEvaluator(BaseEvaluator):
Args:
metric (str): Metric name in evaluate module.
seed (int): There exists some randomness during the calculation of some
metrics, thus we set a fixed random seed for reproducing. Defaults
to 0.
"""
def __init__(self, metric: str) -> None:
def __init__(self, metric: str, seed: int = 0) -> None:
self.metric = metric
random.seed(seed)
np.random.seed(seed)
super().__init__()
def _preprocess(self, predictions: List, references: List) -> dict:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment