Instructions to use emre/distilbert-tr-q-a with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use emre/distilbert-tr-q-a with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("question-answering", model="emre/distilbert-tr-q-a")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForQuestionAnswering tokenizer = AutoTokenizer.from_pretrained("emre/distilbert-tr-q-a") model = AutoModelForQuestionAnswering.from_pretrained("emre/distilbert-tr-q-a", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from emre/distilbert-tr-q-a: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/emre/distilbert-tr-q-a/resolve/main/README.md
- Command line
-
hf download hf://emre/distilbert-tr-q-a/README.md
-
curl -L -o README.md https://huggingface.co/emre/distilbert-tr-q-a/resolve/main/README.md
1.72 kB
| language: tr | |
| tags: | |
| - question-answering | |
| - loodos-bert-base | |
| - TQuAD | |
| - tr | |
| datasets: | |
| - TQuAD | |
| # Turkish SQuAD Model : Question Answering | |
| 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-dataset | |
| # Training Code | |
| ``` | |
| !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" | |
| ``` | |
| # Example Usage | |
| > 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)) | |
| ``` |