sergioska commited on
Commit
0a86b8d
·
1 Parent(s): 56b88d8

first commit

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1,4 +1,19 @@
1
  import streamlit as st
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ # Load model directly
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
 
5
+ tokenizer = AutoTokenizer.from_pretrained("openchat/openchat_3.5")
6
+ model = AutoModelForCausalLM.from_pretrained("openchat/openchat_3.5")
7
+
8
+ model_open_chat = AutoModelForCausalLM.from_pretrained("openchat/openchat_3.5",
9
+ device_map="auto", temperature=0.1,torch_dtype=torch.bfloat16)
10
+ tokenizer_open_chat = AutoTokenizer.from_pretrained("openchat/openchat_3.5")
11
+
12
+ prompt = st.chat_input("Say something")
13
+ if prompt:
14
+ st.write(f"User has sent the following prompt: {prompt}")
15
+
16
+ model_input = tokenizer_open_chat(prompt, return_tensors="pt").to("cuda")
17
+ response = tokenizer_open_chat.decode(model_open_chat.generate(**model_input,temperature=0.1, max_length=5000)[0], skip_special_tokens=True)
18
+
19
+ print(response)