Spaces:
Sleeping
Sleeping
Reduce sample size and increase epochs
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
|
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
import numpy as np
|
|
|
6 |
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
|
7 |
|
8 |
import torch
|
@@ -13,6 +14,7 @@ from torch.utils.data import DataLoader
|
|
13 |
from transformers import AutoModelForTokenClassification, AutoTokenizer, DataCollatorForTokenClassification
|
14 |
from transformers import DebertaV2Config, DebertaV2ForTokenClassification
|
15 |
|
|
|
16 |
|
17 |
# print weights
|
18 |
def print_trainable_parameters(model):
|
@@ -44,7 +46,7 @@ st.write("dimension", dimension)
|
|
44 |
|
45 |
student_model_config = teacher_model.config
|
46 |
student_model_config.num_attention_heads = 8
|
47 |
-
student_model_config.num_hidden_layers =
|
48 |
student_model = DebertaV2ForTokenClassification.from_pretrained(
|
49 |
"microsoft/mdeberta-v3-base",
|
50 |
config=student_model_config)
|
@@ -59,7 +61,7 @@ if torch.cuda.is_available():
|
|
59 |
# Load data.
|
60 |
raw_dataset = load_dataset("ai4privacy/pii-masking-400k", split='train')
|
61 |
raw_dataset = raw_dataset.filter(lambda example: example["language"].startswith("en"))
|
62 |
-
raw_dataset = raw_dataset.select(range(
|
63 |
raw_dataset = raw_dataset.train_test_split(test_size=0.2)
|
64 |
print(raw_dataset)
|
65 |
print(raw_dataset.column_names)
|
@@ -175,7 +177,7 @@ def distillation_loss(student_logits, teacher_logits, true_labels, temperature,
|
|
175 |
# hyperparameters
|
176 |
batch_size = 32
|
177 |
lr = 1e-4
|
178 |
-
num_epochs =
|
179 |
temperature = 2.0
|
180 |
alpha = 0.5
|
181 |
|
|
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
import numpy as np
|
6 |
+
import os
|
7 |
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
|
8 |
|
9 |
import torch
|
|
|
14 |
from transformers import AutoModelForTokenClassification, AutoTokenizer, DataCollatorForTokenClassification
|
15 |
from transformers import DebertaV2Config, DebertaV2ForTokenClassification
|
16 |
|
17 |
+
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
|
18 |
|
19 |
# print weights
|
20 |
def print_trainable_parameters(model):
|
|
|
46 |
|
47 |
student_model_config = teacher_model.config
|
48 |
student_model_config.num_attention_heads = 8
|
49 |
+
student_model_config.num_hidden_layers = 4
|
50 |
student_model = DebertaV2ForTokenClassification.from_pretrained(
|
51 |
"microsoft/mdeberta-v3-base",
|
52 |
config=student_model_config)
|
|
|
61 |
# Load data.
|
62 |
raw_dataset = load_dataset("ai4privacy/pii-masking-400k", split='train')
|
63 |
raw_dataset = raw_dataset.filter(lambda example: example["language"].startswith("en"))
|
64 |
+
raw_dataset = raw_dataset.select(range(2000))
|
65 |
raw_dataset = raw_dataset.train_test_split(test_size=0.2)
|
66 |
print(raw_dataset)
|
67 |
print(raw_dataset.column_names)
|
|
|
177 |
# hyperparameters
|
178 |
batch_size = 32
|
179 |
lr = 1e-4
|
180 |
+
num_epochs = 300
|
181 |
temperature = 2.0
|
182 |
alpha = 0.5
|
183 |
|