Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.56 KB | None | 0 0
  1. \chapter{Our Contribution}
  2. In previous chapters, we have covered the basics of reading comprehension and question answering. Also, we have described two main models designed for this task – BiDAF \ref{bidaf} and BERT \ref{bert}. They were trained on the one of the most popular datasets called SQuAD \ref{squad}. Especially the second model has achieved very good results. Unfortunately, this dataset is in English language. We would like to be able to train such models also for QA in Czech language. In this chapter, we will describe, how previously described dataset and models can be reused for reaching this goal.
  3.  
  4. \section{Introduction}
  5. At first, we have to describe basic tools and technologies, that we have used for reaching the goal of our work and describe dataset structure in detail.
  6.  
  7. \subsection{Dataset}
  8. We have downloaded the dataset SQuAD 1.0 from here \cite{squadsource}. We have chosen SQuAD version 1.0, because there always exists the answer for the question in the text, so the answers are easier to be predicted. In version 2.0, answers can be unanswerable and it makes QA tasks even more challenging. More about SQuAD dataset can be found in \ref{chapter02}.
  9.  
  10. The structure of the dataset is following. There are two .json files. First one is \textit{train-v1.1.json} and it contains all data for training. It means there are context paragraphs with several questions and each question has one answer. Second one is \textit{dev-v1.1.json}, which is used for evaluation. The structure of this file is almost the same with one difference. It was annotated manually by several crowdworkers, so there can be several answers for one question. The most matching answer was always chosen to be compared with the predicted one to reach the highest accuracy. It also allows a little deviations in answering, which can be useful as the predicted answer is not always 100 \% same like the original one and still can be correct. The size of training dataset is 87,599 questions and development set is 10,570 questions.
  11.  
  12. The structure of both data files looks like this. There is a tag \textit{data} containing list of all articles. Inside this tag, there is always a title of the article in \textit{title} tag having a list of single paragraphs containing the context related to this title. They are called \textit{paragraphs} tags. Each paragraph has its own list with answers and questions in \textit{qas} tag, which furthermore consists of three tags. First one is \textit{question} tag, which contains the text of the question. Second one is \textit{id} tag, as each question has its own id for easier identification. Last one is \textit{answers} tag containing the text of the answer in \textit{text} tag, and also, starting index of the answer in the text represented in the \textit{answer\_start} tag.
  13.  
  14. Basically, the structure looks like this:
  15.  
  16. \lstset{language=C}
  17. \begin{lstlisting}
  18. { Data[
  19. title
  20. paragraphs [{
  21. context
  22. qas [{
  23. answers[
  24. text
  25. answer_start
  26. }]
  27. question
  28. id
  29. }]
  30. ]
  31. version }
  32. \end{lstlisting}
  33.  
  34.  
  35. \subsection{Translation of the data}
  36. We have used several data translation of the SQuAD dataset to Czech and eventually back to English language. For that, we have used LINDAT Translator, which is the best translator between Czech and English, that is freely distributed and developed at Faculty of Mathematics and Physics at Charles University by the Institute of Formal and Applied Linguistics. More about this translator can be found here \cite{lindat}.
  37.  
  38. The translation of the dataset brings a noise into in. It means that in English dataset the answer in the text was the same as the text in the answer tag. Unfortunately, now the answer in the text and answer in answers tag may differ. We need to handle this problem. Moreover, the \textit{answer\_start} tag value must be recomputed as the order of the words may have changed after translation.
  39.  
  40. As mention above, when we have translated all of the paragraphs, answers and questions, the start index of each answer in the text had have to be recomputed as we need it during training. The problem is that we cannot use exact match because of several reasons.
  41.  
  42. First one is that the answer may not fit the text exactly. For that, we cannot use exact match and we need to go character by character and find longest common substring by following algorithm. See alg.\ref{Alg:lcs}. We will start with the whole text and compute match between it and the translated answer. Meanwhile, we will systematically delete first character until we have empty string and measure which of the resultant common substrings is the longest one.
  43.  
  44. \begin{algorithm}[H]
  45. \caption{Calculation of the cylinder from the plane}
  46. \label{Alg:lcs}
  47. \hspace*{\algorithmicindent} \textbf{Input:} \\
  48. $text$ = translated text \\
  49. $answer$ = translated answer \\
  50. $idx$ = original index of the middle of the answer \\
  51.  
  52. \hspace*{\algorithmicindent} \textbf{Output:} \\
  53. $bestMatch$ = start index of the bes answer\\
  54.  
  55. \begin{algorithmic}
  56. \FOR{i = 0 to len($text$)}
  57. \STATE $lcs$ = longestCommonSubstring(text[i:len($text$)], $answer$)
  58. \ENDFOR
  59. \STATE $maxLcs$ = find maximum of $lcs$
  60. \IF{$maxLcs$ is only one item}
  61. \STATE return $maxLlcs$
  62. \ELSE
  63. \FOR {i = 0 to len($maxLcs$)}
  64. \STATE $maxPos$=$maxLcs.match$*(1-abs($idx$-$maxLcs[i].idx$)/len($text$))
  65. \ENDFOR
  66. \ENDIF
  67. \STATE return max($maxPos$)
  68. \end{algorithmic}
  69.  
  70. \end{algorithm}
  71.  
  72. The other problem is that there can be more occurrences of the answer in the text and only one is the correct one. For that, we will consider that the text sentences are approximately in the same order in English and in Czech and we will use the original answer position to find the correct position of translated answer. Therefore, for each possible answer we compute its final score according to its value of longest common substring match multiplied by the distance from the position of original answer in original text. To facilitate the work, middle position of the answer is taken. Nearer is the actual position to original one and more similar is, the higher the score is correspondingly. Finally, the answer with the highest score is chosen and its starting index is taken as the correct one. Obviously, if starting index points to the middle of the word, it is moved that it points to the beginning of it.
  73.  
  74. To facilitate our work with translated data, we have modified the final .json file after translation a bit. Two new tags into the \textit{answers} tag were added. First one is \textit{answer\_end}, which is computed during recomputation of the starting index. It is pointing to the end of the last word of the answer in the text and it was added because of the easier visualization of the answer in the context paragraph. The other one is \textit{answer\_match} and it is value of the score of the match. See the new structure below.
  75.  
  76. \lstset{language=C}
  77. \begin{lstlisting}
  78. { Data[
  79. title
  80. paragraphs [{
  81. context
  82. qas [{
  83. answers[
  84. text
  85. answer_start
  86. }]
  87. question
  88. id
  89. }]
  90. ]
  91. version }
  92. \end{lstlisting}
  93.  
  94. Unfortunately, every machine makes some mistakes during translation. We will now describe the most common ones. One of them is word order, that is confusing the system while recomputing start index of the answer in the text. One of the examples can be seen in \ref{Fig:img-order}. The other common mistake is caused by synonyms. The translator has chosen two different Czech words in question and answer for the same one in English. See \ref{Fig:img-synonyms}. Another problem is caused by different language properties - Czech words are declined. See \ref{Fig:img-declination}. The last common mistake I will mention is translating of numbers. They can be once written as words and translated and secondly written as numbers. Then the algorithm of recomputing index is confused. See \ref{Fig:img-numbers}. By the way, the same problem is with names. See \ref{Fig:img-names}. You can observe some of the deviations in translations in images below.
  95.  
  96. \begin{figure}[H]
  97. \centering
  98. \includegraphics[width=140mm]{../img/example-order.png}
  99. \caption{Example of the selected answer by the algorithm with changed word order between text and answer.}
  100. \label{Fig:img-order}
  101. \end{figure}
  102.  
  103. \begin{figure}[H]
  104. \centering
  105. \includegraphics[width=140mm]{../img/example-declination.png}
  106. \caption{Example of the selected answer by the algorithm with different declination in text and answer.}
  107. \label{Fig:img-declination}
  108. \end{figure}
  109.  
  110. \begin{figure}[H]
  111. \centering
  112. \includegraphics[width=140mm]{../img/example-synonyms.png}
  113. \caption{Example of the selected answer by the algorithm with synonyms in text and answer.}
  114. \label{Fig:img-synonyms}
  115. \end{figure}
  116.  
  117. \begin{figure}[H]
  118. \centering
  119. \includegraphics[width=140mm]{../img/example-declination.png}
  120. \caption{Example of the selected answer by the algorithm with different declination in text and answer.}
  121. \label{Fig:img-declination}
  122. \end{figure}
  123.  
  124. \begin{figure}[H]
  125. \centering
  126. \includegraphics[width=140mm]{../img/example-numbers.png}
  127. \caption{Example of the selected answer by the algorithm with non-translated numbers in text and answer.}
  128. \label{Fig:img-numbers}
  129. \end{figure}
  130.  
  131. \begin{figure}[H]
  132. \centering
  133. \includegraphics[width=140mm]{../img/example-names.png}
  134. \caption{Example of the selected answer by the algorithm with partially translated names in text and answer.}
  135. \label{Fig:img-names}
  136. \end{figure}
  137.  
  138.  
  139. After having all the data translated and successfully recomputed start and end index, we had to analyze them and observe, how good or bad the translation was. For that we have created following graphs \ref{Fig:img-devmatch} and \ref{Fig:img-trainmatch}. They are showing how successful the translation was. We can also observe, that we have really similar numbers for both sets, what is really good, because the development set and train set do not differ too much and they were similarly difficult for the translator and there is not too much deviation between these two datasets.
  140. \begin{figure}[H]
  141. \centering
  142. \includegraphics[width=140mm]{../img/train-match.png}
  143. \caption{Plot of how much the answers match the answers in the text for training set}
  144. \label{Fig:img-trainmatch}
  145. \end{figure}
  146.  
  147.  
  148. \begin{figure}[H]
  149. \centering
  150. \includegraphics[width=140mm]{../img/dev-match.png}
  151. \caption{Plot of how much the answers match the answers in the text for development.}
  152. \label{Fig:img-devmatch}
  153. \end{figure}
  154.  
  155. According to the observation of the graph \ref{Fig:img-trainmatch}, we can see that almost all the translations were with match more than 50\% in both sets. Moreover, we can see that there are only few translation that have match less than 80 \%. If we thrown them away, we still would have preserved almost 90\% of the data and it still would be enough to make good predictions. For that we can throw them away for that they would not case too much mess during training. These answers will be probably wrongly found in the text or wrongly translated. We can observe exact values of how many percent of data will be preserved for different values of exact match in the table \ref{tab:match-after-trans}.
  156. \begin{table}[h]
  157. \centering
  158. \begin{tabular}{| l | l | l |}
  159. \hline
  160. \textbf{Match} & \textbf{Train set size} & \textbf{Test set size} \\
  161. \hline
  162. \textbf{100\%} & 57.8\% & 58.0\% \\
  163. \hline
  164. \textbf{$\geq$ 90\%} & 78.9\% & 78.2\% \\
  165. \hline
  166. \textbf{$\geq$ 80\%} & 89.0\% & 88.6\% \\
  167. \hline
  168. \textbf{$\geq$ 70\%} & 94.7\% & 94.2\% \\
  169. \hline
  170. \textbf{$\geq$ 60\%} & 89.2\% & 98.0\% \\
  171. \hline
  172. \textbf{$\geq$ 50\%} & 99.8\% & 99.8\% \\
  173. \hline
  174. \end{tabular}
  175. \caption{Preservation of original datasets [in \%], where the match is higher than defined value.}
  176. \label{tab:match-after-trans}
  177. \end{table}
  178.  
  179. For better observation of the influence of the translation mistakes to the training model process, we will create several datasets. They will contain only answers with match greater of equal to certain value. We found out that the best partitions will be after 5\%, so we will create datasets where we have match 100\%, more than 95\%, more than 90\%, more than 85\% and more than 80\% for both training and development set. We will use them for the training. This process will be described in detail in following part. For the information how much percent of original data was preserved in newly created files see table \ref{tab:match-after-trans-files}. We can see that the numbers are a bit different than in previous ones. It is because of rounding deviations. Basically, we have still more than 85\% of data saved so it is still enough.
  180.  
  181. \begin{table}[h]
  182. \centering
  183. \begin{tabular}{| l | l | l |}
  184. \hline
  185. \textbf{Match} & \textbf{Train set size} & \textbf{Test set size} \\
  186. \hline
  187. \textbf{100\%} & 50.6\% & 51.0\% \\
  188. \hline
  189. \textbf{$\geq$ 95\%} & 59.1\% & 59.2\% \\
  190. \hline
  191. \textbf{$\geq$ 90\%} & 71.2\% & 71.2\% \\
  192. \hline
  193. \textbf{$\geq$ 85\%} & 80.0\% & 78.9\% \\
  194. \hline
  195. \textbf{$\geq$ 80\%} & 85.1\% & 84.5\% \\
  196. \hline
  197. \end{tabular}
  198. \caption{Preservation of original datasets [in \%], where the match is higher than defined value.}
  199. \label{tab:match-after-trans-files}
  200. \end{table}
  201.  
  202.  
  203. \subsection{Machine for training}
  204. For training and testing, we have used Artificial Intelligence Cluster (AIC). See \cite{aic}.
  205. \cite[AIC (Artificial Intelligence Cluster) is a computational grid with sufficient computational capacity for research in the field of deep learning using both CPU and GPU. It was built on top of SGE scheduling system. MFF students of Bc. and Mgr. degrees can use it to run their experiments and learn the proper ways of grid computing in the process.]{aic}.
  206. %4 processors Intel(R) Xeon(R) Silver 4110 CPU @ 2.10GHz.
  207.  
  208. \section{BiDAF Model}
  209. Biderectional Attention Flow (BiDAF) model was trained on SQuAD dataset. It is a multi-level hierarchical process. With help of attention mechanism, it represents the context od words on several levels of granularity. It also limits the information loss in context ans relation representation. More about this model can be found at \ref{chapter03}.
  210.  
  211. As mentioned above, the goal of this work is to reuse this model to solve QA task also in Czech language. We have used model from here \cite{biattflowsource}. There are two main attitudes, both linked with machine translation of data between English and Czech. First one is to take whole SQuAD dataset and translate it into Czech. Then, train model in Czech. The second is to train model in English and translate Czech input to English, then let the model to produce the answer and finally, translate it back to Czech.
  212.  
  213. \subsection{Translation of English data to Czech}
  214. We have taken whole SQuAD data set and translated from English to Czech by LINDAT translator. Then, we have trained model in Czech and tested its accuracy. It took from 62 to 213 hours on CPU dependently on the combination of train and test files.
  215.  
  216. For the training process, we had to change English embeddings used for the English dataset to Czech embeddings. We have used Czech embeddings created by RNDr. Milan Straka, PhD. on 4 milliards of Czech words using word2vec model. There are 1.5 millions of embeddings.
  217.  
  218. After translation, we have obtained 5 data files for train and 5 data files for testing with different matches between the answer in the text and translated answer as described above. To find the best combination of train and testing dataset we have tried to train model on all the possible combinations. For that, we have trained 25 models with different train and test having answers with match from $\geq$80\% to 100\%. The resultant accuracies and F1 scores of these training processes can be observed in tables \ref{tab:cz-results-acc} and \ref{tab:cz-resultsf1}.
  219.  
  220. \begin{table}[]
  221. \begin{tabular}{|l|l|l|l|l|l|}
  222. \hline
  223. \textbf{Test/Train} & \textbf{100\%}& \textbf{$\geq$95\%}& \textbf{$\geq$90\%}& \textbf{$\geq$85\%}& \textbf{$\geq$80\%} \\
  224. \hline
  225. \textbf{100\%}& 57.03\% & 57.34\% & 58.84\% & 59.23\% & 59.6\% \\ \hline
  226. \textbf{$\geq$95\%}& 53.14\% & 55.7\% & 57.17\% & 57.69\% & 57.71\% \\ \hline
  227. \textbf{$\geq$90\%}& 48.25\% & 51.31\% & 54.78\% & 56.12\% & 53.14\% \\ \hline
  228. \textbf{$\geq$85\%}& 45.72\% & 47.47\% & 49.3\% & 52.86\% & 54.56\% \\ \hline
  229. \textbf{$\geq$80\%}& 43.86\% & 48.1\% & 50.76\% & 52.34\% & 53.43\% \\ \hline
  230. \end{tabular}
  231. \caption{Exact match after translation SQuAD to Czech and then training and testing models on data files with corresponding matching values.}
  232. \label{tab:cz-results-acc}
  233. \end{table}
  234.  
  235. \begin{table}[]
  236. \begin{tabular}{|l|l|l|l|l|l|}
  237. \hline
  238. \textbf{Test/Train} & \textbf{100\%}& \textbf{95\%}& \textbf{90\%}& \textbf{85\%}& \textbf{85\%} \\
  239. \hline
  240. \textbf{100\%}& 65.01\% & 65.75\% & 67.49\% & 67.95\% & 67.89\% \\ \hline
  241. \textbf{95\%}& 62.35\% & 64.86\% & 66.27\% & 67.18\% & 67.37\% \\ \hline
  242. \textbf{90\%}& 58.56\% & 61.85\% & 65.19\% & 66.4\% & 65.99\% \\ \hline
  243. \textbf{95\%}& 56.57\% & 60.83\% & 62.02\% & 64.64\% & 65.35\% \\ \hline
  244. \textbf{80\%}& 55.01\% & 59.88\% & 62.09\% & 63.88\% & 64.79\% \\ \hline
  245. \end{tabular}
  246. \caption{F1 after translation SQuAD to Czech and then training and testing models on data files with corresponding matching values.}
  247. \label{tab:cz-results-f1}
  248. \end{table}
  249.  
  250. If we compare all these results in the graph with exact match \ref{Fig:graph-acc} and f1 score \ref{Fig:graph-f1}, we can see that the best results we had with train data having answers with match grater or equal to 80\% and training set with 100\% match between translated answer and answer in the text. The results are logical because match above 80\% does not bring such a noise into the dataset as the lower values do, and we also have much more data for training than with match 100\%. Therefore, the model can then answer more questions. Te reason why the best testing set is with answers with match 100\% is because the other development sets are noisy and it is harder for the model to predict them correctly.
  251.  
  252. \begin{figure}[H]
  253. \centering
  254. \includegraphics[width=140mm]{../img/transl_cz_accuracy.png}
  255. \caption{Plot of exact match how much the answers match the answers in the text for testing.}
  256. \label{Fig:graph-acc}
  257. \end{figure}
  258.  
  259. \begin{figure}[H]
  260. \centering
  261. \includegraphics[width=140mm]{../img/transl_cz_f1.png}
  262. \caption{Plot of f1 score how much the answers match the answers in the text for testing.}
  263. \label{Fig:graph-f1}
  264. \end{figure}
  265.  
  266. \subsection{Translation of Czech input into English}
  267. We have trained the BiDAF model in English. It took 124 hours 29 minutes and 31 seconds on CPU. Then we have taken Czech testing data set, we have translated it into English and then, we have run in on a pretrained English model. Subsequently, we have measured exact match and we got following results. See table \ref{tab:cz-en-results}.
  268. \begin{table}[h]
  269. \centering
  270. \begin{tabular}{| l | l |}
  271. \hline
  272. \textbf{Exact match} & \textbf{F1} \\
  273. \hline
  274. 54.39\% & 67.58\% \\
  275. \hline
  276. \end{tabular}
  277. \caption{Results after translation of Czech input to English for evaluation. Exact match and f1 were computed on this dataset without translating answer back to Czech.}
  278. \label{tab:cz-en-results}
  279. \end{table}
  280.  
  281. To make the evaluation completed, we have taken English answers and translated them back to Czech language. Then we have measured similarity between original and newly obtained Czech answers. We got these results. See table \ref{tab:cz-en-cz-results}.
  282.  
  283. \begin{table}[h]
  284. \centering
  285. \begin{tabular}{| l | l |}
  286. \hline
  287. \textbf{Exact match} & \textbf{F1} \\
  288. \hline
  289. 62.08\% & 70.36\% \\
  290. \hline
  291. \end{tabular}
  292. \caption{Results after translation of Czech input to English for evaluation. Then, the answers were translated back to Czech and exact match and f1 were computed on translated and original Czech answers.}
  293. \label{tab:cz-en-cz-results}
  294. \end{table}
  295.  
  296. As we do not have any Czech training or testing dataset, we have translated whole testing dataset from English to Czech. From that, we have chosen only questions and answers having the match between translated answer and answer in the text with more than 95 \%. Match was computed by the same way like it was mentioned in the previous section and by the same algorithm which is described in \ref{Alg:lcs}.
  297.  
  298. \subsection{Summary of results}
  299.  
  300. If we compare the best result of the model trained in Czech and the best result of the model trained in English, we can see, that the total best results we obtained from English model trained on English data set and with translating Czech input into English and then translating English output back into Czech. See table \ref{tab:all-results}
  301.  
  302. We think that English model is better because we have more data and there is no noise caused by translation. Moreover, LINDAT translator used for translation was constructed that if we translate sentence from English to Czech and then back to English, it is trying to return original sentence and for that, the loss is minimal.
  303.  
  304. \begin{table}[h]
  305. \centering
  306. \begin{tabular}{| l | l | l |}
  307. \hline
  308. \textbf{Model} & \textbf{Exact match} & \textbf{F1} \\
  309. \hline
  310. \textbf{English} & 64.22\% & 75.29\% \\
  311. \hline
  312. \textbf{CZ} & 59.6\% & 67.89\% \\
  313. \hline
  314. \textbf{CZ-EN} & 54.39\% & 67.58\% \\
  315. \hline
  316. \textbf{CZ-EN-CZ} & 62.08\% & 70.36\% \\
  317. \hline
  318. \end{tabular}
  319. \caption{Comparison of results from all models.}
  320. \label{tab:all-results}
  321. \end{table}
  322.  
  323.  
  324. To sum it up, with the best model for Czech we have exact match 62\% and f1 score 70.36\% and for English model we have exact match 64.00\% and f1 score 75.29\%. We can see that exact match of better model is only 2\% lower and f1 score is only 5\% lower, what is not such a difference.
  325.  
  326. Basically original English BiDAF model is generally not so good. It has exact match only 64\% and F1 score 75\%. For that, we have tried to reuse another model that gives exact match 80.69\% and f1 score 88.16\% for English. It is called Transformer model.
  327.  
  328.  
  329. \section{Transformer model}
  330. We have downloaded Transformer model from here \cite{bertsource}. It is an universal language representation model which was originally pretrained on huge unlabeled corpus. We have finetuned it on SQuAD dataset to create model called BERT for our QA task. Basically, finetunning took from 3 to 6 six hours on GPU, dependently on train and test datasets.
  331.  
  332. Firstly, we have trained Transformer on original English SQuAD dataset. We have tried different number of epochs. The best results we obtained with 2 epochs and for that, we have trained the other models only with 2 epochs. See table \ref{tab:bert-epochs}.
  333.  
  334. \begin{table}[h]
  335. \centering
  336. \begin{tabular}{| l | l | l |}
  337. \hline
  338. \textbf{BERT (Train EN, Test EN)} & \textbf{Exact match} & \textbf{F1} \\
  339. \hline
  340. \textbf{1 epoch} & 79.2\% & 87.35\% \\
  341. \hline
  342. \textbf{2 epochs} & 80.69\% & 88.16\% \\
  343. \hline
  344. \textbf{3 epochs} & 80.03\% & 87.8\% \\
  345. \hline
  346. \end{tabular}
  347. \caption{Comparison of results of BERT using different number of epochs.}
  348. \label{tab:bert-epochs}
  349. \end{table}
  350.  
  351.  
  352. After having ideal number of epochs, we have trained BERT also on SQuAD translated to Czech. For that, we have to use Multilingual BERT model, which was designed for other languages. There are two versions of this model. First one is Multilingual BERT cased, that is using cased dataset. Second one is multilingual BERT uncased, which is converting dataset to its uncased version. The uncased model basically gives better results. It is logical as the dataset is simpler. We have trained it on two different combinations of Czech datasets.
  353.  
  354. At first, we have chosen Czech training dataset witch match $\qed$80\% and testing dataset with match 100\%. The reason was simple - it has given the best results in BiDAF model. Moreover, we have tested Czech training dataset and testing dataset both witch match 100\%, because we just wanted to be sure, that first combination is really the best one for BERT too.
  355.  
  356. Surprisingly, we have found, that training on dataset with match 100\% gives us 2\% better results than training dataset with match $\qed$80\%. It is quiet surprising as more accurate dataset contains less data for training. On the other and, BERT is already pretrained on huge unlabeled corpus so the training dataset with matching value $\qed$80\% is bringing more noise into the results. Therefore, the best combination for BERT is training and testing datasets both with match 100\%. See table \ref{tab:bert-cs}.
  357.  
  358.  
  359. \begin{table}[h]
  360. \centering
  361. \begin{tabular}{| l | l | l |}
  362. \hline
  363. \textbf{Multilingual BERT (Train CZ, Test CZ)} & \textbf{Exact match} & \textbf{F1} \\
  364. \hline
  365. \textbf{Cased (Train 80\%, Test 100\%)} & 64.55\% & 73.66\% \\
  366. \hline
  367. \textbf{Uncased (Train 80\%, Test 100\%)} & 66.58\% & 75.6\% \\
  368. \hline
  369. \textbf{Cased (Train 100\%, Test 100\%)} & 66.15\% & 74.28\% \\
  370. \hline
  371. \textbf{Uncased (Train 100\%, Test 100\%)} & 68.45\% & 76.0\% \\
  372. \hline
  373. \end{tabular}
  374. \caption{Comparison of results of Multilingual BERTs trained and evaluated on Czech using different training and testing sets.}
  375. \label{tab:bert-cs}
  376. \end{table}
  377.  
  378.  
  379. Moreover, we have also tried to train Multilingual BERT for English. Firstly, we have evaluated it on English to see, how much differs the multilingual model is from the original BERT. We have seen that it gives approximately the same results. Then, we have evaluated the model on Czech by the same way as in BiDAF model. We have translated Czech inputs into English and then answers back to Czech and evaluated it. We got following results table \ref{tab:multibert-csen}.
  380.  
  381.  
  382. \begin{table}[h]
  383. \centering
  384. \begin{tabular}{| l | l | l |}
  385. \hline
  386. \textbf{Multilingual BERT (Train EN)} & \textbf{Exact match} & \textbf{F1} \\
  387. \hline
  388. \textbf{Cased (Test EN)} & 81.5\% & 88.75\% \\
  389. \hline
  390. \textbf{Uncased (Test EN)} & 81.86\% & 89.12\% \\
  391. \hline
  392. \textbf{Cased (Test CZ)} & 72.53\% & 83.93\% \\
  393. \hline
  394. \textbf{Uncased (Test CZ)} & 72.7\% & 84.23\% \\
  395. \hline
  396. \end{tabular}
  397. \caption{Comparison of results of Multilingual BERTs trained on English and evaluated on English and Czech.}
  398. \label{tab:multibert-csen}
  399. \end{table}
  400.  
  401. We can see that Multilingual BERT for Czech is a bit worse than Multilingual BERT for English. It makes perfect sense as the Czech is much harder for Transformer and BERT than English. Basically, the results are 9\% worse in exact match and 4\% worse in f1 score.
  402.  
  403.  
  404. \subsection{Conclusion}
  405. Basically, we have again observed, that training Multilingual BERT on Czech dataset gives us 5\% worse in exact match and 8\% worse in F1 results that training it on English and only translating the Czech input into English and then translating the answer back to Czech. See table \ref{tab:multibert-cs}.
  406.  
  407.  
  408. \begin{table}[h]
  409. \centering
  410. \begin{tabular}{| l | l | l |}
  411. \hline
  412. \textbf{Multilingual BERT} & \textbf{Exact match} & \textbf{F1} \\
  413. \hline
  414. \textbf{Cased (Trained EN)} & 66.15\% & 74.28\% \\
  415. \hline
  416. \textbf{Uncased (Trained EN)} & 68.45\% & 76.0\% \\
  417. \hline
  418. \textbf{Cased (Trained CZ)} & 72.53\% & 83.93\% \\
  419. \hline
  420. \textbf{Uncased (Trained CZ)} & 72.7\% & 84.23\% \\
  421. \hline
  422. \end{tabular}
  423. \caption{Comparison of all the Multilingual BERT models for Czech QA}
  424. \label{tab:multibert-cs}
  425. \end{table}
  426.  
  427.  
  428. \section{Summary}
  429. To sum everything up, we have to compare BiDAF and BERT model results. In both of these, we have observed, that training in English gives better results than training in Czech.
  430.  
  431. Firstly, it is important to mention, that BERT has reached much better results in QA task than BiDAF. See table \ref{tab:tab:both-only-en}.
  432.  
  433. \begin{table}[h]
  434. \centering
  435. \begin{tabular}{| l | l | l |}
  436. \hline
  437. \textbf{Model} & \textbf{Exact match} & \textbf{F1} \\
  438. \hline
  439. \textbf{BiDAF} & 64.22\% & 75.19\% \\
  440. \hline
  441. \textbf{BERT} & 80.69\% & 88.16\% \\
  442. \hline
  443. \end{tabular}
  444. \caption{Comparison of results of BiDAF and BERT trained and evaluated on English SQuAD}
  445. \label{tab:both-only-en}
  446. \end{table}
  447.  
  448. Secondly, we can observe results of training both models in Czech. We can see that BiDAF is better on training dataset of matching value 80\% and BERT is better on training dataset of matching value 100\%. If we compare the best results for both model for Czech, we can see that the best model Multilingual BERT uncased is 9\% better in exact match and 12\% better in f1 score than the best model BiDAF. See table \ref{tab:both-cs}.
  449.  
  450. \begin{table}[h]
  451. \centering
  452. \begin{tabular}{| l | l | l |}
  453. \hline
  454. \textbf{Model (trained in CZ)} & \textbf{Exact match} & \textbf{F1} \\
  455. \hline
  456. \textbf{BiDAF (Train 80\%, Test 100\%)} & 59.6\% & 67.89\% \\
  457. \hline
  458. \textbf{BiDAF (Train 100\%, Test 100\%)} & 57.03\% & 65.01\% \\
  459. \hline
  460. \textbf{Multi BERT cased(Train 80\%, Test 100\%)} & 64.55\% & 73.66\% \\
  461. \hline
  462. \textbf{Multi BERT uncased(Train 80\%, Test 100\%)} & 66.58\% & 75.6\% \\
  463. \hline
  464. \textbf{Multi BERT cased(Train 100\%, Test 100\%)} & 66.15\% & 74.28\% \\
  465. \hline
  466. \textbf{Multi BERT uncased(Train 100\%, Test 100\%)} & 68.45\% & 76.0\% \\
  467. \hline
  468. \end{tabular}
  469. \caption{Comparison of Multilingual BERTs and BiDAF trained on Czech.}
  470. \label{tab:both-cs}
  471. \end{table}
  472.  
  473.  
  474. Thirdly, we have compared models trained in English and evaluated on Czech dataset, where we have translated the inputs into English, we have let the model to predict answer and then, we have translated the answer back to Czech and compared it with original answer. We can see that both BERTs are 10\% better in exact match and 13-14\% better in f1 score even in Czech. See table \ref{tab:both-en}.
  475.  
  476. \begin{table}[h]
  477. \centering
  478. \begin{tabular}{| l | l | l |}
  479. \hline
  480. \textbf{Model (trained in EN)} & \textbf{Exact match} & \textbf{F1} \\
  481. \hline
  482. \textbf{BiDAF} & 62.08\% & 70.36\% \\
  483. \textbf{Multi BERT cased} & 72.53\% & 83.93\% \\
  484. \hline
  485. \textbf{Multi BERT uncased} & 72.7\% & 84.23\% \\
  486. \hline
  487. \end{tabular}
  488. \caption{Comparison of Multilingual BERTs and BiDAF trained on English and evaluated on Czech.}
  489. \label{tab:both-en}
  490. \end{table}
  491.  
  492.  
  493. Finally, the best model for Czech QA is definitely Multilingual BERT uncased, that has reached 72.7\% exact match 84.23\% f1 score. In comparison with best model for QA in English, BERT, it is 8\% worse in exact match and 4\% worse in f1. See table \ref{tab:best-comp}.
  494.  
  495. \begin{table}[h]
  496. \centering
  497. \begin{tabular}{| l | l | l |}
  498. \hline
  499. \textbf{Model} & \textbf{Exact match} & \textbf{F1} \\
  500. \hline
  501. \textbf{BERT for English} & 80.69\% & 88.16\% \\
  502. \hline
  503. \textbf{Multi BERT for Czech} & 72.7\% & 84.23\% \\
  504. \hline
  505. \end{tabular}
  506. \caption{Comparison of best models for English QA and Czech QA.}
  507. \label{tab:best-comp}
  508. \end{table}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement