un-index commited on
Commit
8f74a40
·
1 Parent(s): ee527bb
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -1,36 +1,36 @@
1
 
2
- import gradio as gr
3
- # from transformers import AutoModelForCausalLM, AutoTokenizer
4
 
5
 
6
- # prompt = "In a shocking finding, scientists discovered a herd of unicorns living in a remote, " \
7
- # "previously unexplored valley, in the Andes Mountains. Even more surprising to the " \
8
- # "researchers was the fact that the unicorns spoke perfect English."
9
 
10
 
11
- def predict(text):
12
 
13
- tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
14
- model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-j-6B")
15
- input_ids = tokenizer(text, return_tensors="pt").input_ids
16
- gen_tokens = model.generate(input_ids, do_sample=True, temperature=0.9, max_length=100)
17
- gen_text = tokenizer.batch_decode(gen_tokens)[0]
18
- return gen_text
19
 
20
- iface = gr.Interface(fn=predict, inputs="text", outputs="text")
21
- iface.launch()
22
 
23
- # all below works but testing
24
- # import gradio as gr
25
 
26
- # title = "GPT-J-6B"
27
 
28
- # examples = [
29
- # ['The tower is 324 metres (1,063 ft) tall,'],
30
- # ["The Moon's orbit around Earth has"],
31
- # ["The smooth Borealis basin in the Northern Hemisphere covers 40%"]
32
- # ]
33
 
34
- # gr.Interface.load("huggingface/EleutherAI/gpt-j-6B",
35
- # inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
36
- # title=title, examples=examples).launch();
 
1
 
2
+ # import gradio as gr
3
+ # # from transformers import AutoModelForCausalLM, AutoTokenizer
4
 
5
 
6
+ # # prompt = "In a shocking finding, scientists discovered a herd of unicorns living in a remote, " \
7
+ # # "previously unexplored valley, in the Andes Mountains. Even more surprising to the " \
8
+ # # "researchers was the fact that the unicorns spoke perfect English."
9
 
10
 
11
+ # def predict(text):
12
 
13
+ # tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
14
+ # model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-j-6B")
15
+ # input_ids = tokenizer(text, return_tensors="pt").input_ids
16
+ # gen_tokens = model.generate(input_ids, do_sample=True, temperature=0.9, max_length=100)
17
+ # gen_text = tokenizer.batch_decode(gen_tokens)[0]
18
+ # return gen_text
19
 
20
+ # iface = gr.Interface(fn=predict, inputs="text", outputs="text")
21
+ # iface.launch()
22
 
23
+ # # all below works but testing
24
+ # # import gradio as gr
25
 
26
+ # # title = "GPT-J-6B"
27
 
28
+ # # examples = [
29
+ # # ['The tower is 324 metres (1,063 ft) tall,'],
30
+ # # ["The Moon's orbit around Earth has"],
31
+ # # ["The smooth Borealis basin in the Northern Hemisphere covers 40%"]
32
+ # # ]
33
 
34
+ # # gr.Interface.load("huggingface/EleutherAI/gpt-j-6B",
35
+ # # inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
36
+ # # title=title, examples=examples).launch();