Spaces:
Sleeping
Sleeping
temperature slider added
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import torch
|
|
| 4 |
|
| 5 |
big_text = """
|
| 6 |
<div style='text-align: center;'>
|
| 7 |
-
<h1 style='font-size: 30x;'>Knowledge Extraction
|
| 8 |
</div>
|
| 9 |
"""
|
| 10 |
st.markdown(big_text, unsafe_allow_html=True)
|
|
@@ -35,13 +35,16 @@ if 'is_initialized' not in st.session_state:
|
|
| 35 |
#prompt = "question: Do you understand that every minute you're on the verge of death?"
|
| 36 |
#most recent:
|
| 37 |
#prompt = "question: Are you going to wait until the last moment to let death be your teacher?"
|
|
|
|
| 38 |
|
| 39 |
query = st.text_input("Enter your query")
|
| 40 |
if query:
|
| 41 |
prompt = "question: "+query
|
| 42 |
input_ids = st.session_state.tokenizer(prompt, return_tensors="pt").input_ids.to(st.session_state.device)
|
| 43 |
# Generate a response
|
| 44 |
-
output = st.session_state.model.generate(input_ids, max_length=2048, do_sample=True,temperature=0.01, pad_token_id=st.session_state.tokenizer.eos_token_id) #exact result for single paragraph
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# Decode the output
|
| 47 |
response = st.session_state.tokenizer.decode(output[0], skip_special_tokens=True)
|
|
|
|
| 4 |
|
| 5 |
big_text = """
|
| 6 |
<div style='text-align: center;'>
|
| 7 |
+
<h1 style='font-size: 30x;'>Knowledge Extraction B</h1>
|
| 8 |
</div>
|
| 9 |
"""
|
| 10 |
st.markdown(big_text, unsafe_allow_html=True)
|
|
|
|
| 35 |
#prompt = "question: Do you understand that every minute you're on the verge of death?"
|
| 36 |
#most recent:
|
| 37 |
#prompt = "question: Are you going to wait until the last moment to let death be your teacher?"
|
| 38 |
+
temperature = st.slider("Select Temperature", min_value=0.01, max_value=2.0, value=0.01, step=0.01)
|
| 39 |
|
| 40 |
query = st.text_input("Enter your query")
|
| 41 |
if query:
|
| 42 |
prompt = "question: "+query
|
| 43 |
input_ids = st.session_state.tokenizer(prompt, return_tensors="pt").input_ids.to(st.session_state.device)
|
| 44 |
# Generate a response
|
| 45 |
+
#output = st.session_state.model.generate(input_ids, max_length=2048, do_sample=True,temperature=0.01, pad_token_id=st.session_state.tokenizer.eos_token_id) #exact result for single paragraph
|
| 46 |
+
output = st.session_state.model.generate(input_ids, max_length=2048, do_sample=True, temperature=temperature,
|
| 47 |
+
pad_token_id=st.session_state.tokenizer.eos_token_id) # exact result for single paragraph
|
| 48 |
|
| 49 |
# Decode the output
|
| 50 |
response = st.session_state.tokenizer.decode(output[0], skip_special_tokens=True)
|