Spaces:
Runtime error
Runtime error
File size: 676 Bytes
1cb92d8 a8fd8bb 1cb92d8 aeac51e 1cb92d8 a8fd8bb 1cb92d8 a8fd8bb 1cb92d8 aeac51e a8fd8bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and tokenizer with `trust_remote_code=True`
tokenizer = AutoTokenizer.from_pretrained("aisingapore/sea-lion-7b-instruct", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("aisingapore/sea-lion-7b-instruct", trust_remote_code=True)
def generate_response(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
# Launch the interface
iface.launch(share=True, inline=True)
|