Spaces:
Sleeping
Sleeping
File size: 2,094 Bytes
17a7426 496a393 17a7426 d3ca4f2 17a7426 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import gradio as gr
import torch
from pathlib import Path
torch.set_float32_matmul_precision("high")
from generate.base import main
def generate(prompt, max_new_tokens, temperature, num_samples):
prompt = prompt.strip()
responses = main(
prompt=prompt,
checkpoint_dir=Path("./out/redpajama"),
max_new_tokens=max_new_tokens,
temperature=temperature,
num_samples=num_samples,
)
return {output: responses}
with gr.Blocks() as app:
gr.Markdown("## Pythia-160M Pre-training with LitGPT")
gr.Markdown(
"""This is an implementation of Pythia-160M using [LitGPT](https://github.com/Lightning-AI/lit-gpt) by LightningAI.
Please find the source code and training details [here](https://github.com/RaviNaik/ERA-SESSION22).
Dataset used to train: [RedPajama](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-1T).
"""
)
with gr.Row():
with gr.Column():
prompt_box = gr.Textbox(label="Initial Prompt", interactive=True)
max_new_tokens = gr.Slider(
minimum=10,
maximum=200,
value=50,
step=10,
label="Select Number of Tokens to be Generated",
interactive=True,
)
temperature = gr.Slider(
minimum=0.1,
maximum=1,
value=0.7,
step=0.1,
label="Select Temperature",
interactive=True,
)
num_samples = gr.Dropdown(
choices=[1, 2, 5, 10],
value=1,
interactive=True,
label="Select No. of outputs to be generated",
)
submit_btn = gr.Button(value="Generate")
with gr.Column():
output = gr.JSON(label="Generated Text")
submit_btn.click(
generate,
inputs=[prompt_box, max_new_tokens, temperature, num_samples],
outputs=[output],
)
app.launch()
|