Spaces:
Runtime error
Runtime error
clean up app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from uq import BertForUQSequenceClassification
|
|
6 |
def predict(sentence):
|
7 |
model_path = "tombm/bert-base-uncased-finetuned-cola"
|
8 |
classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
|
|
|
9 |
label = classifier(sentence)[0]["label"]
|
10 |
return label
|
11 |
|
@@ -15,6 +16,7 @@ def uncertainty(sentence):
|
|
15 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
16 |
model = BertForUQSequenceClassification.from_pretrained(model_path)
|
17 |
|
|
|
18 |
test_input = tokenizer(sentence, return_tensors="pt")
|
19 |
model.return_gp_cov = True
|
20 |
_, gp_cov = model(**test_input)
|
@@ -23,7 +25,6 @@ def uncertainty(sentence):
|
|
23 |
|
24 |
|
25 |
with gr.Blocks() as demo:
|
26 |
-
set_seed(12)
|
27 |
intro_str = """The *cola* dataset focuses on determining whether sentences are grammatically correct.
|
28 |
Firstly, let's see how our finetuned model classifies two sentences,
|
29 |
the first of which is correct (i.e. valid) and the second is not (i.e. invalid):"""
|
@@ -66,5 +67,3 @@ with gr.Blocks() as demo:
|
|
66 |
gr.Markdown(value=final_str)
|
67 |
|
68 |
demo.launch()
|
69 |
-
# iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
70 |
-
# iface.launch()
|
|
|
6 |
def predict(sentence):
|
7 |
model_path = "tombm/bert-base-uncased-finetuned-cola"
|
8 |
classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
|
9 |
+
set_seed(12)
|
10 |
label = classifier(sentence)[0]["label"]
|
11 |
return label
|
12 |
|
|
|
16 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
17 |
model = BertForUQSequenceClassification.from_pretrained(model_path)
|
18 |
|
19 |
+
set_seed(12)
|
20 |
test_input = tokenizer(sentence, return_tensors="pt")
|
21 |
model.return_gp_cov = True
|
22 |
_, gp_cov = model(**test_input)
|
|
|
25 |
|
26 |
|
27 |
with gr.Blocks() as demo:
|
|
|
28 |
intro_str = """The *cola* dataset focuses on determining whether sentences are grammatically correct.
|
29 |
Firstly, let's see how our finetuned model classifies two sentences,
|
30 |
the first of which is correct (i.e. valid) and the second is not (i.e. invalid):"""
|
|
|
67 |
gr.Markdown(value=final_str)
|
68 |
|
69 |
demo.launch()
|
|
|
|