Hi everyone,
I’m testing some zero-shot classification models on a dataset using the following configuration:
possible_models = [
"vicgalle/xlm-roberta-large-xnli-anli",
"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
"joeddav/xlm-roberta-large-xnli",
"MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
"MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
]
categories = [
'Carrot',
'Potato',
'Tomato',
'Onion',
'Broccoli',
'Pepper',
'Cucumber',
'Spinach',
'Zucchini',
'Pumpkin',
'Lettuce',
'Corn',
]
data = []
for model in possible_models:
print("*"*20, model, "*"*20)
classifier = pipeline(
"zero-shot-classification",
model=model,
device=0
)
model_result_data = []
for term in search_terms:
result = classifier(term, candidate_labels=categories)
top_label = result["labels"][0]
top_score = result["scores"][0]
model_result_data.append(top_label)
While executing the script, I observe the following outputs in my terminal:
******************** vicgalle/xlm-roberta-large-xnli-anli ********************
Device set to use mps:0
******************** emrecan/bert-base-multilingual-cased-allnli_tr ********************
******************** MoritzLaurer/mDeBERTa-v3-base-mnli-xnli ********************
Device set to use mps:0
Device set to use mps:0
******************** vicgalle/xlm-roberta-large-xnli-anli ********************
Device set to use mps:0
******************** emrecan/bert-base-turkish-cased-allnli_tr ********************
Device set to use mps:0
******************** MoritzLaurer/mDeBERTa-v3-base-mnli-xnli ********************
The issue I’m facing is that instead of loading each model listed in possible_models, the script seems to load the same model multiple times. This behavior suggests that some parallel process in the background might be causing interference.
Has anyone else faced a similar issue or have any suggestions on how to ensure that the correct models load sequentially without repeating?
• Transformers version: 4.47.1
Any help would be greatly appreciated!