├── README.md └── TurkishQuestionPairs.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Question Paraphrases Dataset For Turkish Language 2 | This data set contains 1377 positive question paraphrases for Turkish Languages and 2187 negative examples. 3 | The original questions are taken from Istanbul Bilgi Universitiy Frequently Asking Questions resource 4 | https://www.bilgi.edu.tr/tr/yasam/ogrenci/sss/. Later,we manually created two additional truly semantically equivalent questions. These quesitons pairs are considered postivie example of the quesiton paraphrasing. 5 | 6 | ## Negative Sampling: 7 | We also supplemented 2187 negative examples labeled as 0. The source of negative examples are be pairs of "related questions" which, although pertaining to similar topics, are not truly semantically equivalent. It would be very much like Quora Question Pairs 8 | https://www.quora.com/q/quoradata/First-Quora-Dataset-Release-Question-Pairs 9 | 10 | 11 | ## Paraphrasing Detection 12 | To do classify wheter two questions are duplicate, we trained a simple classification algorithm based on BERT. It would be very helpfull especially for ChatBot framework in Turkish Language. 13 | 14 | Following code shows how to run the detection model 15 | 16 | 17 | ``` 18 | from transformers import * 19 | import torch 20 | from transformers import AutoTokenizer, AutoModelForSequenceClassification 21 | tokenizer = AutoTokenizer.from_pretrained("savasy/TurkQP") 22 | model = AutoModelForSequenceClassification.from_pretrained("savasy/TurkQP") 23 | 24 | 25 | s0="Bugün yağmur yağacak mı ?" 26 | s1="Yağmur yağabilir mi bugün ?" 27 | inputs= tokenizer(s0, s1, add_special_tokens=True, return_tensors='pt') 28 | output= pytorch_model(inputs['input_ids'], token_type_ids=inputs['token_type_ids'])[0] 29 | pred = output.argmax().item() 30 | 31 | pred==1 32 | 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /TurkishQuestionPairs.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 62, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import pandas as pd" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 63, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "d=pd.read_csv(\"TurkQP.csv\")" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 64, 24 | "metadata": {}, 25 | "outputs": [ 26 | { 27 | "data": { 28 | "text/html": [ 29 | "
\n", 30 | "\n", 43 | "\n", 44 | " \n", 45 | " \n", 46 | " \n", 47 | " \n", 48 | " \n", 49 | " \n", 50 | " \n", 51 | " \n", 52 | " \n", 53 | " \n", 54 | " \n", 55 | " \n", 56 | " \n", 57 | " \n", 58 | " \n", 59 | " \n", 60 | " \n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " \n", 67 | " \n", 68 | " \n", 69 | " \n", 70 | " \n", 71 | " \n", 72 | " \n", 73 | " \n", 74 | " \n", 75 | " \n", 76 | " \n", 77 | " \n", 78 | " \n", 79 | " \n", 80 | " \n", 81 | " \n", 82 | " \n", 83 | " \n", 84 | "
q1q2duplicate
774Öğrenci kulüplerine sağlanan imkanlar nelerdir?öğrenci kulüplerine ne tip imkanlar sunuluyor1
2370Diplomamı kaybettim yeni diploma alabilir miyim?Diplomamı benim yerime bir başkası alabilir mi?0
470ders kaydımda çakışma olduğunda ne yapmalıyımÇakışan derslerim var ders kaydım onaylanır mı?1
2403Mezuniyet başarı sıralamamı öğrenebilir miyim?Mezuniyet başarı sıralamamı öğrenebilir miyim?0
1775Hangi üniversitelerden yatay geçiş kabul ediyo...Ana dal yan dal çift anadal programlarında der...0
\n", 85 | "
" 86 | ], 87 | "text/plain": [ 88 | " q1 \\\n", 89 | "774 Öğrenci kulüplerine sağlanan imkanlar nelerdir? \n", 90 | "2370 Diplomamı kaybettim yeni diploma alabilir miyim? \n", 91 | "470 ders kaydımda çakışma olduğunda ne yapmalıyım \n", 92 | "2403 Mezuniyet başarı sıralamamı öğrenebilir miyim? \n", 93 | "1775 Hangi üniversitelerden yatay geçiş kabul ediyo... \n", 94 | "\n", 95 | " q2 duplicate \n", 96 | "774 öğrenci kulüplerine ne tip imkanlar sunuluyor 1 \n", 97 | "2370 Diplomamı benim yerime bir başkası alabilir mi? 0 \n", 98 | "470 Çakışan derslerim var ders kaydım onaylanır mı? 1 \n", 99 | "2403 Mezuniyet başarı sıralamamı öğrenebilir miyim? 0 \n", 100 | "1775 Ana dal yan dal çift anadal programlarında der... 0 " 101 | ] 102 | }, 103 | "execution_count": 64, 104 | "metadata": {}, 105 | "output_type": "execute_result" 106 | } 107 | ], 108 | "source": [ 109 | "d.sample(frac=1).head()" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 65, 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "0 2187\n", 121 | "1 1377\n", 122 | "Name: duplicate, dtype: int64" 123 | ] 124 | }, 125 | "execution_count": 65, 126 | "metadata": {}, 127 | "output_type": "execute_result" 128 | } 129 | ], 130 | "source": [ 131 | "d.duplicate.value_counts()" 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "* 0: is not duplicate\n", 139 | "* 1: is duplicate " 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": null, 152 | "metadata": {}, 153 | "outputs": [], 154 | "source": [] 155 | } 156 | ], 157 | "metadata": { 158 | "kernelspec": { 159 | "display_name": "Python 3", 160 | "language": "python", 161 | "name": "python3" 162 | }, 163 | "language_info": { 164 | "codemirror_mode": { 165 | "name": "ipython", 166 | "version": 3 167 | }, 168 | "file_extension": ".py", 169 | "mimetype": "text/x-python", 170 | "name": "python", 171 | "nbconvert_exporter": "python", 172 | "pygments_lexer": "ipython3", 173 | "version": "3.7.6" 174 | } 175 | }, 176 | "nbformat": 4, 177 | "nbformat_minor": 4 178 | } 179 | --------------------------------------------------------------------------------