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