Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,13 @@ st.markdown('## Text-generation OPT from Meta ')
|
|
| 8 |
@st.cache(allow_output_mutation=True, suppress_st_warning =True, show_spinner=False)
|
| 9 |
def get_model():
|
| 10 |
return pipeline('text-generation', model=model, skip_special_tokens=True)
|
| 11 |
-
|
| 12 |
col1, col2 = st.columns([2,1])
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
with col2:
|
| 15 |
select_model = st.radio(
|
| 16 |
"Select the model to use:",
|
|
@@ -27,21 +31,13 @@ with col2:
|
|
| 27 |
with st.spinner('Loading Model... (This may take a while)'):
|
| 28 |
generator = get_model()
|
| 29 |
st.success('Model loaded correctly!')
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
'''AI will help humanity? ''')
|
| 35 |
-
|
| 36 |
-
answer = generator(prompt,
|
| 37 |
-
max_length=60,
|
| 38 |
-
no_repeat_ngram_size=2, early_stopping=True, num_beams=5, skip_special_tokens=True)
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
# answer = ['ciao come stai stutto bene']
|
| 43 |
-
# lst = ''.join(answer)
|
| 44 |
-
|
| 45 |
t = st.empty()
|
| 46 |
for i in range(len(lst)):
|
| 47 |
t.markdown(" %s..." % lst[0:i])
|
|
|
|
| 8 |
@st.cache(allow_output_mutation=True, suppress_st_warning =True, show_spinner=False)
|
| 9 |
def get_model():
|
| 10 |
return pipeline('text-generation', model=model, skip_special_tokens=True)
|
| 11 |
+
|
| 12 |
col1, col2 = st.columns([2,1])
|
| 13 |
|
| 14 |
+
with col1:
|
| 15 |
+
prompt= st.text_area('Your prompt here',
|
| 16 |
+
'''AI will help humanity? ''')
|
| 17 |
+
|
| 18 |
with col2:
|
| 19 |
select_model = st.radio(
|
| 20 |
"Select the model to use:",
|
|
|
|
| 31 |
with st.spinner('Loading Model... (This may take a while)'):
|
| 32 |
generator = get_model()
|
| 33 |
st.success('Model loaded correctly!')
|
| 34 |
+
|
| 35 |
+
answer = generator(prompt,
|
| 36 |
+
max_length=100,
|
| 37 |
+
no_repeat_ngram_size=3, early_stopping=True, num_beams=10, skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
lst = answer[0]['generated_text']
|
| 40 |
+
|
|
|
|
|
|
|
|
|
|
| 41 |
t = st.empty()
|
| 42 |
for i in range(len(lst)):
|
| 43 |
t.markdown(" %s..." % lst[0:i])
|