Spaces:
Sleeping
Sleeping
update
Browse files- tasks/text.py +4 -2
tasks/text.py
CHANGED
@@ -65,7 +65,7 @@ async def evaluate_text(request: TextEvaluationRequest):
|
|
65 |
|
66 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
67 |
|
68 |
-
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
|
69 |
model = AutoModelForSequenceClassification.from_pretrained("cococli/bert-base-uncased-frugalai").to(device)
|
70 |
|
71 |
def tokenize_function(examples):
|
@@ -76,7 +76,7 @@ async def evaluate_text(request: TextEvaluationRequest):
|
|
76 |
print('AFTER TOKENIZING')
|
77 |
print(tokenized_test.column_names) # Debugging step
|
78 |
print(tokenized_test['input_ids'][:5]) # Debugging step
|
79 |
-
|
80 |
# Create DataLoader
|
81 |
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)
|
82 |
dataloader = DataLoader(tokenized_test, batch_size=16, shuffle=False, collate_fn=data_collator)
|
@@ -88,7 +88,9 @@ async def evaluate_text(request: TextEvaluationRequest):
|
|
88 |
predictions = np.array([])
|
89 |
|
90 |
with torch.no_grad():
|
|
|
91 |
for batch in dataloader:
|
|
|
92 |
test_input_ids = batch["input_ids"].to(device)
|
93 |
test_attention_mask = batch["attention_mask"].to(device)
|
94 |
outputs = model(test_input_ids, test_attention_mask)
|
|
|
65 |
|
66 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
67 |
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained("cococli/bert-base-uncased-frugalai")
|
69 |
model = AutoModelForSequenceClassification.from_pretrained("cococli/bert-base-uncased-frugalai").to(device)
|
70 |
|
71 |
def tokenize_function(examples):
|
|
|
76 |
print('AFTER TOKENIZING')
|
77 |
print(tokenized_test.column_names) # Debugging step
|
78 |
print(tokenized_test['input_ids'][:5]) # Debugging step
|
79 |
+
|
80 |
# Create DataLoader
|
81 |
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)
|
82 |
dataloader = DataLoader(tokenized_test, batch_size=16, shuffle=False, collate_fn=data_collator)
|
|
|
88 |
predictions = np.array([])
|
89 |
|
90 |
with torch.no_grad():
|
91 |
+
print('BEFORE PREDICTION')
|
92 |
for batch in dataloader:
|
93 |
+
print('INSIDE PREDICTION')
|
94 |
test_input_ids = batch["input_ids"].to(device)
|
95 |
test_attention_mask = batch["attention_mask"].to(device)
|
96 |
outputs = model(test_input_ids, test_attention_mask)
|