from util import * st.markdown('# Prediction of coherence in answers to open-ended questions') st.markdown('## Task') st.markdown('The task is to predict whether an answer is incoherent to the question or not.') st.markdown('## Examples') st.markdown('*Examples originally in Spanish*') st.markdown("""|Question|Coherent answer|Incoherent answer| |--------------|-----------|------------| |Maria and her husband cooked a tortilla yesterday, they divided it into 6 equal parts. Maria ate 2/6 and her husband ate 3/6. What fraction of the tortilla was left?| 1/6 | no | |Catalina bought 12 onions. Of the 12 onions, she used 1/4 of them to make some delicious empanadas. How many onions did she use for the empanadas? Explain how you knew the result.|I need 3 and I know this because I divided 12:4=3x1=3|it is ok teacher| |Camilo has to collect 60 balls. So far he has collected 23. To find out how many balls he has left to collect, subtract 23 from 60. Is Camilo’s exercise correct? Justify your answer|it’s ok because I added 37+23 and a half 60|43| |Pablo takes 5 hours to travel from Santiago to La Serena. His friend Pedro traveled from La Serena to Santiago and took 300 minutes. Which of the two children took less time? Explain your answer|both took the same time because I multiplied 5x60=300 and 300 minutes is 5 hours|60x5 gives 300| |What is a line of symmetry? Explain in your own words and give me an example|a line of symmetry is a line that separates two equal images|f| |Pamela has 25 flowers and her friend gives her 17 flowers. Write in words the total number of flowers Pamela has|forty-two|areflowers| """) st.markdown('## Model') st.markdown('Fine tuning of Spanish version of BERT ([BETO](https://huggingface.co/dccuchile/bert-base-spanish-wwm-cased)). This new model is trained using Spanish pairs of questions/answers to predict incoherence. Available on [furrutiav/beto_coherence](https://huggingface.co/furrutiav/beto_coherence).') st.markdown('## Inference') Q = st.text_area('Question:', 'Julieta tiene 20 láminas y le regaló 12 a Daniela ¿Cuántas láminas tiene ahora Julieta?') A = st.text_area('Answer:', 'nose :C') if Q: if A: probs = C1Classifier(Q, A, is_probs=True) value = "coherent" if probs[1]<=0.5 else "incoherent" st.write('Prediction:', f"The answer is {100*probs[1]: .0f}% likely to be incoherent. So, it is {value}!")