Update pages/bot.py
Browse files- pages/bot.py +3 -22
pages/bot.py
CHANGED
|
@@ -102,27 +102,7 @@ def main():
|
|
| 102 |
|
| 103 |
# Erstelle die Question Answering-Pipeline für Deutsch
|
| 104 |
qa_pipeline = pipeline("question-answering", model="deutsche-telekom/bert-multi-english-german-squad2", tokenizer="deutsche-telekom/bert-multi-english-german-squad2")
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
# Frage beantworten und mehrere Antworten erhalten
|
| 108 |
-
answers = qa_pipeline(
|
| 109 |
-
question=question,
|
| 110 |
-
context=context
|
| 111 |
-
#top_k=3, # Anzahl der zurückgegebenen Antworten
|
| 112 |
-
#top_p=0.8 # Wahrscheinlichkeit der Antwort
|
| 113 |
-
)
|
| 114 |
-
|
| 115 |
-
# Nur Antworten mit mindestens 200 Zeichen behalten
|
| 116 |
-
filtered_answers = [answer for answer in answers if len(answer['answer']) >= 200]
|
| 117 |
-
|
| 118 |
-
# Ergebnisse ausgeben
|
| 119 |
-
for i, answer in enumerate(filtered_answers):
|
| 120 |
-
st.text(f"Antwort {i+1}:")
|
| 121 |
-
st.text(f"Antwort: {answer['answer']}")
|
| 122 |
-
st.text(f"Konfidenz: {answer['score']}")
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
"""
|
| 126 |
# Frage beantworten
|
| 127 |
#answer = qa_pipeline(question=question, context=context, top_k=3)
|
| 128 |
answer = qa_pipeline(question=question, context=context)
|
|
@@ -130,8 +110,9 @@ def main():
|
|
| 130 |
# Gib die Antwort aus
|
| 131 |
st.text("Basisantwort:")
|
| 132 |
st.text(answer["answer"])
|
| 133 |
-
|
| 134 |
|
|
|
|
| 135 |
#Die Basisantwort müsste man jetzt ausformulieren
|
| 136 |
text2text_generator = pipeline("text2text-generation", model="google/flan-t5-xxl")
|
| 137 |
#newText=text2text_generator(question=question, context=answer)
|
|
|
|
| 102 |
|
| 103 |
# Erstelle die Question Answering-Pipeline für Deutsch
|
| 104 |
qa_pipeline = pipeline("question-answering", model="deutsche-telekom/bert-multi-english-german-squad2", tokenizer="deutsche-telekom/bert-multi-english-german-squad2")
|
| 105 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# Frage beantworten
|
| 107 |
#answer = qa_pipeline(question=question, context=context, top_k=3)
|
| 108 |
answer = qa_pipeline(question=question, context=context)
|
|
|
|
| 110 |
# Gib die Antwort aus
|
| 111 |
st.text("Basisantwort:")
|
| 112 |
st.text(answer["answer"])
|
| 113 |
+
st.text(answer)
|
| 114 |
|
| 115 |
+
"""
|
| 116 |
#Die Basisantwort müsste man jetzt ausformulieren
|
| 117 |
text2text_generator = pipeline("text2text-generation", model="google/flan-t5-xxl")
|
| 118 |
#newText=text2text_generator(question=question, context=answer)
|