Spaces:
Sleeping
Sleeping
Varun Wadhwa
commited on
Logs
Browse files
app.py
CHANGED
@@ -80,12 +80,10 @@ print(raw_dataset.column_names)
|
|
80 |
# --> if tokens are inside a word, replace 'B-' with 'I-'
|
81 |
def align_labels_with_tokens(labels):
|
82 |
aligned_label_ids = []
|
83 |
-
aligned_label_ids.append(-100)
|
84 |
for i, label in enumerate(labels):
|
85 |
if label.startswith("B-"):
|
86 |
label = label.replace("B-", "I-")
|
87 |
aligned_label_ids.append(label2id[label])
|
88 |
-
aligned_label_ids.append(-100)
|
89 |
return aligned_label_ids
|
90 |
|
91 |
# create tokenize function
|
@@ -151,10 +149,8 @@ def evaluate_model(model, dataloader, device):
|
|
151 |
print("evaluate_model sizes")
|
152 |
print(len(all_preds))
|
153 |
print(len(all_labels))
|
154 |
-
|
155 |
-
|
156 |
-
print(id2label[all_preds[i]])
|
157 |
-
print(id2label[all_labels[i]])
|
158 |
all_preds = np.asarray(all_preds, dtype=np.float32)
|
159 |
all_labels = np.asarray(all_labels, dtype=np.float32)
|
160 |
accuracy = accuracy_score(all_labels, all_preds)
|
|
|
80 |
# --> if tokens are inside a word, replace 'B-' with 'I-'
|
81 |
def align_labels_with_tokens(labels):
|
82 |
aligned_label_ids = []
|
|
|
83 |
for i, label in enumerate(labels):
|
84 |
if label.startswith("B-"):
|
85 |
label = label.replace("B-", "I-")
|
86 |
aligned_label_ids.append(label2id[label])
|
|
|
87 |
return aligned_label_ids
|
88 |
|
89 |
# create tokenize function
|
|
|
149 |
print("evaluate_model sizes")
|
150 |
print(len(all_preds))
|
151 |
print(len(all_labels))
|
152 |
+
print(id2label[all_preds[0]])
|
153 |
+
print(id2label[all_labels[0]])
|
|
|
|
|
154 |
all_preds = np.asarray(all_preds, dtype=np.float32)
|
155 |
all_labels = np.asarray(all_labels, dtype=np.float32)
|
156 |
accuracy = accuracy_score(all_labels, all_preds)
|