Spaces:
Sleeping
Sleeping
Commit
·
03a5733
1
Parent(s):
e3c19b3
Updated default values
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ itos = { i:ch for i,ch in enumerate(chars) }
|
|
| 22 |
encode = lambda s: [stoi[c] for c in s] # encoder: take a string, output a list of integers
|
| 23 |
decode = lambda l: ''.join([itos[i] for i in l]) # decoder: take a list of integers, output a
|
| 24 |
|
| 25 |
-
def inference(input_text, max_new_tokens=
|
| 26 |
context = torch.tensor(encode(input_text), dtype=torch.long, device=device).view(1, -1)
|
| 27 |
|
| 28 |
output_text = decode(model.generate(context, max_new_tokens=max_new_tokens)[0].tolist())
|
|
@@ -31,22 +31,22 @@ def inference(input_text, max_new_tokens=300):
|
|
| 31 |
|
| 32 |
title = "NanoGPT trained on Shakespeare Plays dataset"
|
| 33 |
description = "A simple Gradio interface to generate text from gpt model trained on Shakespeare Plays"
|
| 34 |
-
examples = [["Shape",
|
| 35 |
-
["Answer",
|
| 36 |
-
["Ideology",
|
| 37 |
-
["Absorb",
|
| 38 |
-
["Triangle",
|
| 39 |
-
["Listen",
|
| 40 |
-
["Census",
|
| 41 |
-
["Balance",
|
| 42 |
-
["Representative",
|
| 43 |
-
["Cinema",
|
| 44 |
]
|
| 45 |
demo = gr.Interface(
|
| 46 |
inference,
|
| 47 |
inputs = [
|
| 48 |
gr.Textbox(label="Enter any word", type="text"),
|
| 49 |
-
gr.Slider(minimum=100, maximum=
|
| 50 |
],
|
| 51 |
outputs = [
|
| 52 |
gr.Textbox(label="Output", type="text")
|
|
|
|
| 22 |
encode = lambda s: [stoi[c] for c in s] # encoder: take a string, output a list of integers
|
| 23 |
decode = lambda l: ''.join([itos[i] for i in l]) # decoder: take a list of integers, output a
|
| 24 |
|
| 25 |
+
def inference(input_text, max_new_tokens=200):
|
| 26 |
context = torch.tensor(encode(input_text), dtype=torch.long, device=device).view(1, -1)
|
| 27 |
|
| 28 |
output_text = decode(model.generate(context, max_new_tokens=max_new_tokens)[0].tolist())
|
|
|
|
| 31 |
|
| 32 |
title = "NanoGPT trained on Shakespeare Plays dataset"
|
| 33 |
description = "A simple Gradio interface to generate text from gpt model trained on Shakespeare Plays"
|
| 34 |
+
examples = [["Shape", 200],
|
| 35 |
+
["Answer", 200],
|
| 36 |
+
["Ideology", 200],
|
| 37 |
+
["Absorb", 200],
|
| 38 |
+
["Triangle", 200],
|
| 39 |
+
["Listen", 200],
|
| 40 |
+
["Census", 200],
|
| 41 |
+
["Balance", 200],
|
| 42 |
+
["Representative", 200],
|
| 43 |
+
["Cinema", 200],
|
| 44 |
]
|
| 45 |
demo = gr.Interface(
|
| 46 |
inference,
|
| 47 |
inputs = [
|
| 48 |
gr.Textbox(label="Enter any word", type="text"),
|
| 49 |
+
gr.Slider(minimum=100, maximum=2000, step=100, value=300, label="Max character to generate")
|
| 50 |
],
|
| 51 |
outputs = [
|
| 52 |
gr.Textbox(label="Output", type="text")
|