|
from transformers import pipeline |
|
|
|
def load_model(): |
|
print("Model yükleniyor...") |
|
model = pipeline("question-answering", model="savasy/bert-base-turkish-squad") |
|
print("Model başarıyla yüklendi!") |
|
return model |
|
|
|
def ask_question(question): |
|
context = """ |
|
AFAD, Türkiye'deki afet ve acil durumlara müdahale eden resmi kurumdur. |
|
2023 yılında birçok farklı şehirde arama kurtarma çalışmaları yürütmüştür. |
|
Özellikle deprem, sel ve yangın gibi afetlerde etkin şekilde görev almaktadır. |
|
""" |
|
result = model(question=question, context=context) |
|
return result['answer'], result['score'] |
|
|
|
model = load_model() |
|
|
|
|
|
question = "AFAD hangi konuda çalışır?" |
|
answer, score = ask_question(question) |
|
print(f"Yanıt: {answer} (Güven skoru: {score:.2f})") |
|
|