theachyuttiwari commited on
Commit
2859a34
·
1 Parent(s): a2e6572

Upload settings.py

Browse files
Files changed (1) hide show
  1. settings.py +95 -0
settings.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ settings = {}
4
+
5
+ def app():
6
+ st.markdown("""
7
+ <style>
8
+ div[data-testid="stForm"] {
9
+ border: 0;
10
+ }
11
+ .footer-custom {
12
+ position: fixed;
13
+ bottom: 0;
14
+ width: 100%;
15
+ color: var(--text-color);
16
+ max-width: 698px;
17
+ font-size: 14px;
18
+ height: 50px;
19
+ padding: 10px 0;
20
+ z-index: 50;
21
+ }
22
+ footer {
23
+ display: none !important;
24
+ }
25
+ .footer-custom a {
26
+ color: var(--text-color);
27
+ }
28
+ button[kind="formSubmit"]{
29
+ margin-top: 40px;
30
+ border-radius: 20px;
31
+ padding: 5px 20px;
32
+ font-size: 18px;
33
+ background-color: var(--primary-color);
34
+ }
35
+ #lfqa-model-parameters {
36
+ margin-bottom: 50px;
37
+ font-size: 36px;
38
+ }
39
+ #tts-model-parameters {
40
+ font-size: 36px;
41
+ margin-top: 50px;
42
+ }
43
+ .stAlert {
44
+ width: 250px;
45
+ margin-top: 32px;
46
+ }
47
+ </style>
48
+ """, unsafe_allow_html=True)
49
+
50
+ with st.form("settings"):
51
+ footer = """
52
+ <div class="footer-custom">
53
+ Streamlit app - <a href="https://www.linkedin.com/in/danijel-petkovic-573309144/" target="_blank">Danijel Petkovic</a> |
54
+ LFQA/DPR models - <a href="https://www.linkedin.com/in/blagojevicvladimir/" target="_blank">Vladimir Blagojevic</a> |
55
+ Guidance & Feedback - <a href="https://yjernite.github.io/" target="_blank">Yacine Jernite</a>
56
+ </div>
57
+ """
58
+ st.markdown(footer, unsafe_allow_html=True)
59
+
60
+ st.title("LFQA model parameters")
61
+
62
+ settings["min_length"] = st.slider("Min length", 20, 80, st.session_state["min_length"],
63
+ help="Min response length (words)")
64
+ st.markdown("""<hr></hr>""", unsafe_allow_html=True)
65
+ settings["max_length"] = st.slider("Max length", 128, 320, st.session_state["max_length"],
66
+ help="Max response length (words)")
67
+ st.markdown("""<hr></hr>""", unsafe_allow_html=True)
68
+ col1, col2 = st.columns(2)
69
+ with col1:
70
+ settings["do_sample"] = st.checkbox("Use sampling", st.session_state["do_sample"],
71
+ help="Whether or not to use sampling ; use greedy decoding otherwise.")
72
+ with col2:
73
+ settings["early_stopping"] = st.checkbox("Early stopping", st.session_state["early_stopping"],
74
+ help="Whether to stop the beam search when at least num_beams sentences are finished per batch or not.")
75
+ st.markdown("""<hr></hr>""", unsafe_allow_html=True)
76
+ settings["num_beams"] = st.slider("Num beams", 1, 16, st.session_state["num_beams"],
77
+ help="Number of beams for beam search. 1 means no beam search.")
78
+ st.markdown("""<hr></hr>""", unsafe_allow_html=True)
79
+ settings["temperature"] = st.slider("Temperature", 0.0, 1.0, st.session_state["temperature"], step=0.1,
80
+ help="The value used to module the next token probabilities")
81
+
82
+ st.title("TTS model parameters")
83
+ settings["tts"] = st.selectbox(label="Engine", options=("Google", "HuggingFace"),
84
+ index=["Google", "HuggingFace"].index(st.session_state["tts"]),
85
+ help="Answer text-to-speech engine")
86
+
87
+ # Every form must have a submit button.
88
+ col3, col4, col5, col6 = st.columns(4)
89
+ with col3:
90
+ submitted = st.form_submit_button("Save")
91
+ with col4:
92
+ if submitted:
93
+ for k, v in settings.items():
94
+ st.session_state[k] = v
95
+ st.success('App settings saved successfully.')