Spaces:
Build error
Build error
length tags
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ examples = [
|
|
| 21 |
|
| 22 |
# pass in Strings of model choice and input text for context
|
| 23 |
@st.cache
|
| 24 |
-
def genQuestion(model_choice, context):
|
| 25 |
# global descriptions
|
| 26 |
if model_choice=="Base model":
|
| 27 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-question-remake")
|
|
@@ -30,6 +30,26 @@ def genQuestion(model_choice, context):
|
|
| 30 |
elif model_choice=="Lengthed model":
|
| 31 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-length-tagged")
|
| 32 |
tok = BartTokenizer.from_pretrained("hyechanjun/interview-length-tagged")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# descriptions = "Interview question tagged is a model that..."
|
| 34 |
elif model_choice=="Reverse model":
|
| 35 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/reverse-interview-question")
|
|
@@ -56,9 +76,9 @@ st.caption("With the advent of machine learning, it has become increasingly clea
|
|
| 56 |
if 'button_sent' not in st.session_state:
|
| 57 |
st.session_state.button_sent = False
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
context_option =
|
| 62 |
'Feel free to choose one of our premade contexts',
|
| 63 |
('Select one','Elon Musk', 'Fashion designer', 'Young entrepreneur', 'Michael Jordan')
|
| 64 |
)
|
|
@@ -74,7 +94,7 @@ elif context_option == 'Young entrepreneur':
|
|
| 74 |
else:
|
| 75 |
context_example = examples[3]
|
| 76 |
|
| 77 |
-
option =
|
| 78 |
'Please select a model.',
|
| 79 |
('Base model', 'Lengthed model', 'Reverse model'))
|
| 80 |
|
|
@@ -87,13 +107,18 @@ elif option == 'Lengthed model':
|
|
| 87 |
elif option == 'Reverse model':
|
| 88 |
st.write("This model asks a question that would have resulted in the context you provide (a.k.a. it traverses backward through the interview)")
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
# Input fields
|
| 91 |
input = st.text_area('Context', value=context_example) # user inputs context to construct a response (str)
|
| 92 |
|
| 93 |
|
| 94 |
if st.button('Submit') or st.session_state.button_sent:
|
| 95 |
with st.spinner('Generating a response...'):
|
| 96 |
-
output = genQuestion(option, input)
|
| 97 |
print(output)
|
| 98 |
# st.write(output)
|
| 99 |
st.session_state.button_sent = True
|
|
|
|
| 21 |
|
| 22 |
# pass in Strings of model choice and input text for context
|
| 23 |
@st.cache
|
| 24 |
+
def genQuestion(model_choice, context, tag):
|
| 25 |
# global descriptions
|
| 26 |
if model_choice=="Base model":
|
| 27 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-question-remake")
|
|
|
|
| 30 |
elif model_choice=="Lengthed model":
|
| 31 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-length-tagged")
|
| 32 |
tok = BartTokenizer.from_pretrained("hyechanjun/interview-length-tagged")
|
| 33 |
+
if (tag == '1-10'):
|
| 34 |
+
context += ' <TEN>'
|
| 35 |
+
elif (tag == '11-20'):
|
| 36 |
+
context += ' <TWENTY>'
|
| 37 |
+
elif (tag == '21-30'):
|
| 38 |
+
context += ' <THIRTY>'
|
| 39 |
+
elif (tag == '31-40'):
|
| 40 |
+
context += ' <FORTY>'
|
| 41 |
+
elif (tag == '51-60'):
|
| 42 |
+
context += ' <FIFTY>'
|
| 43 |
+
elif (tag == '61-70'):
|
| 44 |
+
context += ' <SIXTY>'
|
| 45 |
+
elif (tag == '71-80'):
|
| 46 |
+
context += ' <SEVENTY>'
|
| 47 |
+
elif (tag == '81-90'):
|
| 48 |
+
context += ' <EIGHTY>'
|
| 49 |
+
elif (tag == '81-90'):
|
| 50 |
+
context += ' <NINETY>'
|
| 51 |
+
elif (tag == '91+'):
|
| 52 |
+
context += ' <HUNDRED>'
|
| 53 |
# descriptions = "Interview question tagged is a model that..."
|
| 54 |
elif model_choice=="Reverse model":
|
| 55 |
model = BartForConditionalGeneration.from_pretrained("hyechanjun/reverse-interview-question")
|
|
|
|
| 76 |
if 'button_sent' not in st.session_state:
|
| 77 |
st.session_state.button_sent = False
|
| 78 |
|
| 79 |
+
col1, col2, = st.columns(3)
|
| 80 |
|
| 81 |
+
context_option = col2.selectbox(
|
| 82 |
'Feel free to choose one of our premade contexts',
|
| 83 |
('Select one','Elon Musk', 'Fashion designer', 'Young entrepreneur', 'Michael Jordan')
|
| 84 |
)
|
|
|
|
| 94 |
else:
|
| 95 |
context_example = examples[3]
|
| 96 |
|
| 97 |
+
option = col1.selectbox(
|
| 98 |
'Please select a model.',
|
| 99 |
('Base model', 'Lengthed model', 'Reverse model'))
|
| 100 |
|
|
|
|
| 107 |
elif option == 'Reverse model':
|
| 108 |
st.write("This model asks a question that would have resulted in the context you provide (a.k.a. it traverses backward through the interview)")
|
| 109 |
|
| 110 |
+
if option == 'Lengthed model':
|
| 111 |
+
context_length = col3.selectbox('Length of response'
|
| 112 |
+
('1-10', '11-20', '21-30', '31-40', '41-50', '51-60', '61-70', '71-80', '81-90', '91+'))
|
| 113 |
+
|
| 114 |
+
|
| 115 |
# Input fields
|
| 116 |
input = st.text_area('Context', value=context_example) # user inputs context to construct a response (str)
|
| 117 |
|
| 118 |
|
| 119 |
if st.button('Submit') or st.session_state.button_sent:
|
| 120 |
with st.spinner('Generating a response...'):
|
| 121 |
+
output = genQuestion(option, input, tag)
|
| 122 |
print(output)
|
| 123 |
# st.write(output)
|
| 124 |
st.session_state.button_sent = True
|