jeevavijay10 commited on
Commit
86be357
1 Parent(s): a2ca0f6

Upload app.py

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