Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,10 +16,13 @@ name = "karalif/myTestModel"
|
|
| 16 |
model = AutoModelForSequenceClassification.from_pretrained(name)
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(name, normalization=True)
|
| 18 |
|
| 19 |
-
text = "hvað er maðurinn eiginlega að pæla ég fatta ekki??????????"
|
| 20 |
-
tokens = tokenizer.tokenize(text)
|
| 21 |
-
decoded_text = tokenizer.convert_tokens_to_string(tokens)
|
| 22 |
bench = Benchmark(model, tokenizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
def get_prediction(text):
|
| 25 |
encoding = tokenizer(text, return_tensors="pt", padding="max_length", truncation=True, max_length=200)
|
|
|
|
| 16 |
model = AutoModelForSequenceClassification.from_pretrained(name)
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(name, normalization=True)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
bench = Benchmark(model, tokenizer)
|
| 20 |
+
text = "hvað er maðurinn eiginlega að pæla ég fatta ekki??????????"
|
| 21 |
+
|
| 22 |
+
explanations_formality = bench.explain(text, target=0)
|
| 23 |
+
explanations_sentiment = bench.explain(text, target=1)
|
| 24 |
+
explanations_politeness = bench.explain(text, target=2)
|
| 25 |
+
explanations_toxicity = bench.explain(text, target=3)
|
| 26 |
|
| 27 |
def get_prediction(text):
|
| 28 |
encoding = tokenizer(text, return_tensors="pt", padding="max_length", truncation=True, max_length=200)
|