Spaces:
Sleeping
Sleeping
Update tasks/text.py
Browse files- tasks/text.py +11 -3
tasks/text.py
CHANGED
@@ -59,13 +59,21 @@ async def evaluate_text(request: TextEvaluationRequest):
|
|
59 |
#--------------------------------------------------------------------------------------------
|
60 |
|
61 |
|
62 |
-
|
63 |
-
# load model from huggingface.co/models using our repository id
|
64 |
classifier = pipeline(
|
65 |
task="text-classification",
|
66 |
model="dvilasuero/ModernBERT-frugal",
|
67 |
-
device=0,
|
68 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
#--------------------------------------------------------------------------------------------
|
71 |
# YOUR MODEL INFERENCE STOPS HERE
|
|
|
59 |
#--------------------------------------------------------------------------------------------
|
60 |
|
61 |
|
62 |
+
# Load the model pipeline
|
|
|
63 |
classifier = pipeline(
|
64 |
task="text-classification",
|
65 |
model="dvilasuero/ModernBERT-frugal",
|
66 |
+
device=0, # Ensure this points to the correct device (GPU or CPU)
|
67 |
)
|
68 |
+
|
69 |
+
# Extract texts from the test dataset for inference
|
70 |
+
texts = [example["text"] for example in test_dataset]
|
71 |
+
|
72 |
+
# Perform predictions using the model
|
73 |
+
raw_predictions = classifier(texts)
|
74 |
+
|
75 |
+
# Convert raw predictions to numeric labels
|
76 |
+
predictions = [LABEL_MAPPING[pred["label"]] for pred in raw_predictions]
|
77 |
|
78 |
#--------------------------------------------------------------------------------------------
|
79 |
# YOUR MODEL INFERENCE STOPS HERE
|