ganga-1b / app.py
Lingo-IITGN's picture
Update app.py
f95955d verified
raw
history blame
1.06 kB
import gradio as gr, spaces
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
# tokenizer = AutoTokenizer.from_pretrained("LingoIITGN/ganga-1b")
# model = AutoModelForCausalLM.from_pretrained("LingoIITGN/ganga-1b")
# @spaces.GPU
# def greet(input_text):
# input_token = tokenizer.encode(input_text, return_tensors="pt").to("cuda")
# output = model.generate(input_token, max_new_tokens=100, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95, temperature=0.7)
# output_text = tokenizer.batch_decode(output)[0]
# return output_text
# demo = gr.Interface(fn=greet, inputs=["text"], outputs=["text"],)
@spaces.GPU
def greet(input_text):
input_token = tokenizer.encode(input_text, return_tensors="pt").to("cpu")
output = model.generate(input_token, max_new_tokens=100, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95, temperature=0.7)
output_text = tokenizer.batch_decode(output)[0]
return output_text
demo = gr.Interface(fn=greet, inputs=["text"], outputs=["text"],)
demo.launch()