in src/fmeval/eval_algorithms/helper_models/helper_model.py [0:0]
def __init__(self):
"""
Constructor to locally load the helper model for inference.
"""
state_dict = torch.hub.load_state_dict_from_url(self.UNBIASED_MODEL_URL, map_location="cpu")
config = state_dict["config"]["arch"]["args"]
self._model = (
getattr(transformers, config["model_name"])
.from_pretrained(
pretrained_model_name_or_path=None,
config=AutoConfig.from_pretrained(config["model_type"], num_labels=config["num_classes"]),
state_dict=state_dict["state_dict"],
local_files_only=False,
)
.to("cpu")
)
self._tokenizer = getattr(transformers, config["tokenizer_name"]).from_pretrained(config["model_type"])