Spaces:
Sleeping
Sleeping
File size: 760 Bytes
86be357 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from transformers import AutoTokenizer, AutoModelForCausalLM
import gradio as gr
model_id = "RWKV/rwkv-raven-1b5"
model = AutoModelForCausalLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
def chat(question):
prompt = f"### Instruction: {question}\n### Response:"
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(inputs["input_ids"], max_new_tokens=100)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
iface = gr.Interface(fn=chat,
inputs=gr.inputs.Textbox(label="Enter your text"),
outputs="text",
title="Chat with Surrey County Council InfoBot")
# index = construct_index("docs")
iface.launch() |