supernovamutinda commited on
Commit
a7ac16a
1 Parent(s): 2cdea27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,4 +1,6 @@
1
  import streamlit as st
 
 
2
 
3
 
4
  with st.sidebar:
@@ -13,7 +15,30 @@ if choice == "Home/about":
13
 
14
  if choice == "Meal Suggester":
15
  st.title("Time to Eat")
16
- st.write("Feeling Hungry? Let get you some nice meal to silence that grumbling. In a healthy way ofcourse")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  if choice == "Accomodation available":
19
  st.title("Ready to Move in?")
 
1
  import streamlit as st
2
+ import torch
3
+ from transformers import pipeline
4
 
5
 
6
  with st.sidebar:
 
15
 
16
  if choice == "Meal Suggester":
17
  st.title("Time to Eat")
18
+ st.write("Feeling Hungry? Let get you some nice meal to silence that grumbling. In a healthy way ofcourse")# Install transformers from source - only needed for versions <= v4.34
19
+ # pip install git+https://github.com/huggingface/transformers.git
20
+ # pip install accelerate
21
+
22
+ pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
23
+
24
+ # We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
25
+ messages = [
26
+ {
27
+ "role": "system",
28
+ "content": "You are a friendly chatbot who always responds in the style of a pirate",
29
+ },
30
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
31
+ ]
32
+ prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
33
+ outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
34
+ print(outputs[0]["generated_text"])
35
+ # <|system|>
36
+ # You are a friendly chatbot who always responds in the style of a pirate.</s>
37
+ # <|user|>
38
+ # How many helicopters can a human eat in one sitting?</s>
39
+ # <|assistant|>
40
+ # Ah, me hearty matey! But yer question be a puzzler! A human cannot eat a helicopter in one sitting, as helicopters are not edible. They be made of metal, plastic, and other materials, not food!
41
+
42
 
43
  if choice == "Accomodation available":
44
  st.title("Ready to Move in?")