Belligerent commited on
Commit
aa700ae
·
1 Parent(s): 583a612

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -1,15 +1,12 @@
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? descriptions:[ " A drink consisting of an infusion of ground coffee beans "," a platform-independent programming language ", or " an island in Indonesia to the south of Borneo " ] context: I like to drink " java " in the morning .'
9
 
10
- example = tokenizer.tokenize(input, add_special_tokens=True)
11
- print(example[0:40])
12
-
13
- answer = model.generate(input_ids=example[0:40],
14
- attention_mask=example[9],
15
- max_length=135)
 
1
  import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
3
 
4
+ pipe = pipeline(tokenizer = AutoTokenizer.from_pretrained("jpelhaw/t5-word-sense-disambiguation"), model = AutoModelForSeq2SeqLM.from_pretrained("jpelhaw/t5-word-sense-disambiguation")
 
 
5
 
6
  input = 'question: which description describes the word " java " best in the following context? descriptions:[ " A drink consisting of an infusion of ground coffee beans "," a platform-independent programming language ", or " an island in Indonesia to the south of Borneo " ] context: I like to drink " java " in the morning .'
7
 
8
+ gr.Interface.from_pipeline(pipe,
9
+ inputs = "text",
10
+ outputs= gr.outputs.TextBox(),
11
+ title = "word sense disambiguation",
12
+ allow_flagging="never").launch(inbrowser=True)