Commit
·
7e9df74
1
Parent(s):
e013705
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("jpelhaw/t5-word-sense-disambiguation")
|
|
|
|
| 5 |
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("jpelhaw/t5-word-sense-disambiguation")
|
| 7 |
+
|
| 8 |
+
input = 'question: which description describes the word " java " best in the following context? \
|
| 9 |
+
descriptions:[ " A drink consisting of an infusion of ground coffee beans " ,
|
| 10 |
+
" a platform-independent programming lanugage "
|
| 11 |
+
, or " an island in Indonesia to the south of Borneo " ]
|
| 12 |
+
context: I like to drink " java " in the morning .'
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
example = tokenizer.tokenize(input, add_special_tokens=True)
|
| 16 |
+
|
| 17 |
+
answer = model.generate(input_ids=example['input_ids'],
|
| 18 |
+
attention_mask=example['attention_mask'],
|
| 19 |
+
max_length=135)
|