Refactor the transformers loader (#6859)

This commit is contained in:
oobabooga 2025-04-20 13:33:47 -03:00 committed by GitHub
parent 6ba0164c70
commit ae02ffc605
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 464 additions and 528 deletions

View file

@ -2,13 +2,12 @@ import datetime
from pathlib import Path
import pandas as pd
import torch
from datasets import load_dataset
from tqdm import tqdm
from modules import shared
from modules.logging_colors import logger
from modules.models import clear_torch_cache, load_model, unload_model
from modules.models import load_model, unload_model
from modules.models_settings import get_model_metadata, update_model_parameters
from modules.text_generation import encode
@ -39,6 +38,10 @@ def calculate_perplexity(models, input_dataset, stride, _max_length):
https://huggingface.co/docs/transformers/perplexity#calculating-ppl-with-fixedlength-models
'''
import torch
from modules.torch_utils import clear_torch_cache
if shared.args.loader == "llama.cpp":
logger.error("Perplexity evaluation is not implemented for the llama.cpp loader.")
raise ValueError