Downloads · 30 days
20
1% of all-time downloads
emre/distilbert-tr-q-a
distilbert-tr-q-a is a question answering model from emre. Use it when the input is a question plus a passage. It is set up for transformers.
Fine-tuned Loodos-Turkish-Bert-Model for Question-Answering problem with TQuAD dataset Loodos-BERT-base: https://huggingface.co/loodos/bert-base-turkish-uncased TQuAD dataset: https://github.com/TQuad/turkish-nlp-qa-d…
Downloads · 30 days
20
1% of all-time downloads
All-time downloads
1.4K
Public
Repo size
880 MB
Likes
0
Public
Click a slice to open those files.
.bin440 MB · 100%
From the Hugging Face model README
Fine-tuned Loodos-Turkish-Bert-Model for Question-Answering problem with TQuAD dataset
!python3 Turkish-QA.py \
--model_type bert \
--model_name_or_path loodos/bert-base-turkish-uncased
--do_train \
--do_eval \
--train_file trainQ.json \
--predict_file dev1.json \
--per_gpu_train_batch_size 8 \
--learning_rate 5e-5 \
--num_train_epochs 10 \
--max_seq_length 384 \
--output_dir "./model"
Load Model
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("emre/distilbert-tr-q-a")
model = AutoModelForQuestionAnswering.from_pretrained("emre/distilbert-tr-q-a")
nlp = pipeline('question-answering', model=model, tokenizer=tokenizer)
Apply the model
def ask(question,context):
temp = nlp(question=question, context=context)
start_idx = temp["start"]
end_idx = temp["end"]
return context[start_idx:end_idx]
izmir="İzmir, Türkiye'de Ege Bölgesi'nde yer alan şehir ve ülkenin 81 ilinden biridir. Ülkenin nüfus bakımından en kalabalık üçüncü şehridir. Ekonomik, tarihi ve sosyo-kültürel açıdan önde gelen şehirlerden biridir. Nüfusu 2021 itibarıyla 4.425.789 kişidir. Yüzölçümü olarak ülkenin yirmi üçüncü büyük ilidir."
soru1 = "İzmir'in nüfusu kaçtır?"
print(ask(soru1,izmir))
soru2 = "İzmir hangi bölgede bulunur?"
print(ask(soru2,izmir))