Spaces:
Runtime error
Runtime error
File size: 689 Bytes
3bdb9f0 2d71f41 abd754d 3bdb9f0 a3beba9 9da3581 a3beba9 dfc3b85 d942439 7469f5d be6172f 06ffcdd d942439 4d5ed6a d942439 3bdb9f0 |
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 |
import gradio
from os import system
system("pip3 install torch")
system("pip3 install transformers")
from transformers import AutoTokenizer,AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("apple/OpenELM-270M")
model = openelm_270m = AutoModelForCausalLM.from_pretrained("apple/OpenELM-270M", trust_remote_code=True)
def work(inp_text):
out = tokenizer.encode(inp_text,return_tensors="pt")
out = model.generate(
out,
max_new_tokens=20,
do_sample=True,
temperature=0.3,
)
out = tokenizer.decode(out[0])
return str(out)
demo = gradio.Interface(
fn=work,
inputs=["text"],
outputs=["text"],
)
demo.launch() |