<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zeeshan Haque on Medium]]></title>
        <description><![CDATA[Stories by Zeeshan Haque on Medium]]></description>
        <link>https://medium.com/@zeeshan.dsti2019?source=rss-f9dd7836e1ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WWYuFayArsKV_zp-</url>
            <title>Stories by Zeeshan Haque on Medium</title>
            <link>https://medium.com/@zeeshan.dsti2019?source=rss-f9dd7836e1ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 27 May 2026 23:11:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zeeshan.dsti2019/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Virtual Assistant ‘Chatbot’ based on Open Domain Question Answering using Haystack Framework.]]></title>
            <link>https://medium.com/@zeeshan.dsti2019/introduction-d8487ef5ae73?source=rss-f9dd7836e1ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8487ef5ae73</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[digital-transformation]]></category>
            <category><![CDATA[transformers]]></category>
            <dc:creator><![CDATA[Zeeshan Haque]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 10:48:23 GMT</pubDate>
            <atom:updated>2021-12-24T11:27:32.461Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Chatbots or virtual assistants have been around for a while, but with the upcoming of Language pre-trained models like BERT, RoBERTa, the field of Open Domain Question Answering (ODQA) has evolved exponentially over the years. The aim of chatbots is to enhance the digital transformation of companies. Alcatel-Lucent Enterprise (ALE), a French business communication enterprise providing cloud-based collaboration application (Rainbow) and hybrid communication systems (Omni PCX Enterprise OXE), implements chatbots to automate certain processes related to OXE system maintenance. More precisely, ALE operates a business website that provides frontline workers with a bunch of technical documents to ease troubleshoot the OXE systems in case of any technical blocks. The technician can also have support from the customer care team for resolving the technical query. The aim of Virtual Assistant ‘Chatbot’ is to minimize the time for finding the right solution to the technical problem of OXE. It is dedicated to professionals seeking technical help for troubleshooting OXE.</p><p>The state-of-the-art of ‘Virtual assistant’ chatbot is based on Open Domain Question Answering. So, in pursuit of working on Open Domain Question Answering (ODQA), we found this uber cool framework called <strong>Haystack (</strong><a href="https://haystack.deepset.ai/"><strong>https://haystack.deepset.ai</strong>/</a>) which is developed by <strong>Berlin-based Deepset AI</strong>. Our utilization of the Haystack Framework revolved around its three main components: <strong>Storage, Reader, and Retriever</strong>.</p><p>The task of accurate response to a query is a combination of a Retriever (finding the relevant passage within the collection of documents) and Reader (finding the relevant text span within the selected passage provided by retriever). The Haystack framework provides various types of Retrievers and supports many Language models (Readers). The Retriever uses algorithms like <strong>TF-IDF or BM25, custom Elasticsearch</strong> queries, and embedding-based approach to find candidate paragraphs, while the Reader uses pre-trained HuggingFace models like<strong> BERT, RoBERTa</strong> to find the relevant answer within the paragraph. Our contribution in developing ODQA using Haystack framework by <strong>Deepset AI</strong> on certain technical documents are data preprocessing of the documents, annotation of the documents to prepare a set of questions with short and long answers, and also finding a suitable combination of Retriever-Reader as well as optimal parameters (top-k Retriever and top-k Reader) based on both performance and time of computation.</p><h3><strong>Haystack Reader Finetune</strong></h3><p>Like all Machine Learning pre-trained models, the Haystack Reader can be also finetuned in order to ameliorate the performance. Before fine-tuning the pre-trained models for the Reader, we have two preliminary steps: data pre-processing and data annotation.</p><p><strong>Data pre-processing</strong></p><p>About the dataset of the ALE project, we have several PDF documents that discuss the technical specification of a product. Before utilizing the Haystack framework, we need to do some data pre-processing to enhance the performance of the Retriever and Reader. Following are the steps we implemented in the data preprocessing:</p><ul><li>The PDFs need to be converted to .txt files. One can use any online tool or even Python package like pdf2miner. It is also possible to check out the pdf converter included in Haystack too.</li><li>All text files need to be cleaned. It consists of removing the content page, headers and footers, section, and subsection numbers.</li><li>All tables need to be converted to sentences, for example, a particular row in a table having several columns can be transformed into a sentence using simple English. The conversation process has to be applied also for images and diagrams.</li><li>Irrelevant special characters and white space need also to be removed.</li><li>In the case of a large text file, one can split it into several parts. This will help in reducing time computation and improving performance.</li></ul><p><strong>Data Annotation</strong></p><p>With the extensive amount of data preprocessing work, we proceed to the annotation step; Annotation is one of the key components of the state-of-the-art of Open Domain Question Answering. It involves the creation of question-answer pairs for fine-tuning pre-trained HuggingFace models.</p><p>Over the phase of “annotation”, we understood more about our dataset (e.g. what kind of additional data preprocessing we may need, what kinds of questions one can prepare to challenge the ODQA pipeline, etc).</p><p>Deepset AI provides a web-based annotation tool (<a href="https://haystack.deepset.ai/guides/annotation"><strong>https://haystack.deepset.ai/guides/annotation</strong></a>) to label the data. The tool supports structuring the workflow with organizations, projects, and users. The labels can be exported in SQuAD format that is compatible with Haystack training.</p><p>For our ALE project, we have made certain kinds of guidelines in framing Questions and tagging their respective answers in the Annotation web interface by Deepset AI. The guidelines are the following:</p><ul><li>First and foremost, the questions we are framing need to be specific: the more specific the question, the better the performance of the Retriever-Reader.</li><li>Associate one or several questions to one answer. These questions must be composed of different words having the same meaning.</li><li>The above method can be implemented for different paragraphs having a similar context</li></ul><p><strong><em>Annotation example 1:</em></strong></p><blockquote><strong>For Training purposes -</strong></blockquote><blockquote>Q1_1) What is meant by Document Store?</blockquote><blockquote>Q1_2) What is the meaning of Document Store?</blockquote><blockquote><strong>For Evaluation -</strong></blockquote><blockquote>Q1_3) What is the definition of Document Store?</blockquote><p><strong><em>Annotation example 2:</em></strong></p><blockquote><strong>For Training purpose -</strong></blockquote><blockquote>Q2_1) What is meant by F1 Score?</blockquote><blockquote>Q2_2) What is the definition of F1 Score?</blockquote><blockquote><strong>For Evaluation -</strong></blockquote><blockquote>Q2_3) What is the meaning of F1 Score?</blockquote><p>In the above two examples, the questions for training and evaluation purposes contain different words (‘<strong>meaning’, </strong>‘<strong>definition’ and ‘meant’), </strong>but have the same meaning. And we replicate these question framing in a similar manner for preparing our training dataset and evaluation dataset.</p><p>The annotation phase has ended with <strong>1246</strong> Question-Answer pairs for the training purpose and <strong>522</strong> Question-Answer for Evaluation Purpose. Once the annotation process is finished, the obtained data will be used for fine-tuning the Reader pre-trained models.</p><p><strong>The Choice of best Retriever-Reader combination</strong></p><p>Based on the criteria of the most downloaded pre-trained model for Question Answering, the pre-trained models we selected from the <strong>HuggingFace platform </strong>are the following –</p><p><strong>1.</strong> <strong>deepset/RoBERTa-base-squad2</strong></p><p><strong>2.</strong> <strong>distilbert-base-cased-distilled-squad</strong></p><p><strong>3.</strong> <strong>minilm-uncased-squad2</strong></p><p><strong>4.</strong> <strong>deepset/bert-large-uncased-whole-word-masking-finetuned-squad</strong></p><p><strong>5.</strong> <strong>bert-large-uncased-whole-word-masking-squad2</strong></p><p><strong>6.</strong> <strong>bert-large-cased-whole-word-masking-finetuned-squad</strong></p><p>Haystack proposes also different kinds of Retriever. We distinguish Dense Retriever such as Passage Retriever and Embedded Retriever and Sparse Retriever like TF-IDF and Elastic Search. To sum up, there are<strong> almost 24 possible Retriever-Reader combinations</strong>. As the task of choosing the best combination is crucial, we decided to make an evaluation study to pick out the best combination in the context of ALE troubleshooting documents. Among all these combinations, we only evaluate the following ones.</p><ul><li><strong>BERT Large Uncased + ElasticSearch Retriever (ES)</strong></li><li><strong>Deepset BERT Large + ElasticSearch Retriever (ES)</strong></li><li><strong>BERT Large cased + ElasticSearch Retriever (ES)</strong></li><li><strong>RoBERTa Base squad2 + ElasticSearch Retriever (ES)</strong></li><li><strong>miniLM uncased + ElasticSearch Retriever (ES)</strong></li></ul><p>For a Reader-Retriever pipeline, when a query arrives at the Haystack Framework, the retriever finds relevant paragraphs within the collection of documents. One needs to specify the parameter <strong>top-k Retriever</strong> that indicates the number of paragraphs that need to be picked and moved to the Reader. The reader selects then the text span from the given set of paragraphs as the answer. The number of top-ranked answers returned by the Reader is denoted by the parameter <strong>top-k Reader</strong>. Based on these <strong>top-k parameters</strong>, one can compute the number of missed out answers by both Retriever and Reader as an evaluation criterion. Therefore, on basis of lesser answer-miss out criteria, the above-mentioned <strong>five</strong> combinations of Reader-Retriever are selected, the rest is then not included for the further evaluation study.</p><h3>Evaluation Study</h3><p><strong>Evaluation criteria</strong></p><p>Speaking about the evaluation process, the primary metric is <strong>Answer Missed-Out</strong>, which is defined as the number of questions that couldn’t be mapped to their corresponding answer during the evaluation process. Followingly, we have <strong>Accuracy</strong> which predicts the answer’s text span included in the actual answer text), <strong>Exact Match</strong> predicts an answer that is equivalent to the actual answer and lastly, we have an <strong>F1 score</strong> which measures the average overlap between the prediction and actual answer.</p><p><strong>Evaluation results</strong></p><p>Right below is a summary of the evaluation of 5 pre-trained models with <strong>ElasticSearch </strong>Retrievers, these were evaluated on <strong>separate 522 Question-Answers </strong>having <strong>top-k Retriever equals to 10 and top-k Reader Reader equals to 5. </strong>The below table<strong> </strong>compares different combinations of Reader-Retriever in the context of ALE Question-Answering troubleshooting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*U41lctu5lP-GdroqCEpYaA.png" /><figcaption><strong><em>Table 1: Evaluation summary for Fine-Tuned Reader Models with ElasticSearch Retriever</em></strong></figcaption></figure><p>From <strong>Table 1</strong>, we can deduce that the combination of <strong>BERT Large Uncased</strong> with <strong>Elasticsearch</strong> is performing best with respect to its counterparts in top-1 and top-k evaluations, especially in terms of an <strong>exact match. </strong>In the context of the ALE dataset, most of the answers are rather long. As we aim to achieve excellent experience in providing troubleshooting assistance, we have chosen Exact match as the most important evaluation metrics and benchmarked the performance of Retriever-Reader.</p><p>Considering <strong>the pair of Bert Large Uncased and Elasticsearch</strong>, let’s see the evaluation performance by varying the top-k parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*J5WYYBkYjUwGeJQqFt0T8w.png" /><figcaption><strong><em>Table 2: Effect of different top-k parameters on answer-miss out by BERT Large Uncased + ElasticSearch Retriever</em></strong></figcaption></figure><p>From <strong>Table 2</strong>, we can observe that minimizing top-k Reader from 5 to 3 and keeping top-k Retriever equals 10 for the first two lines increase answer miss out. If we decrease top-k Retriever from 10 to 5 and top-k Reader from 5 to 3, we can remark that there is a significant amount of answers missed out by both Reader and Retriever. This definitely impacts the evaluation metrics presented in <strong>Table 3</strong>. We can also highlight that the number of passage candidates given by the Retriever and available for the Reader to select the right answer also affects the evaluation metrics as shown in <strong>Table3</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*wxx30GbWJzOA9rVKBF0Q7Q.png" /><figcaption><strong>Table 3: Evaluation summary for BERT Large Uncased + ElasticSearch Retriever w.r.t different top-k parameters</strong></figcaption></figure><p>From <strong>Table 3</strong>, we can remark that <strong>BERT Large Uncased with Elasticsearch</strong> with top-k Retriever equals 10 and top-k Reader equals 5 has the edge over lesser top-k-parameter in terms of evaluation metrics, but this configuration comes with a cost of high computation time. When one is working in a constrained infrastructure, top-k parameters can be decreased for medium or lower pre-trained models like RoBERTa-base-squad2 and miniLM but the evaluation metrics could be non-convincing. Therefore, we need to make a <strong>tradeoff</strong> between evaluation and computation depending on our infrastructure.</p><h3><strong>Conclusion</strong></h3><p>Virtual assistant Chatbot based on Open Domain Question Answering utilizing Haystack Framework is a powerful solution enabling professionals to seek technical help on ALE’s Omni PCX Enterprise business website. Our experimentation achieved its pinnacle of success when our paper was published in KES International Journal in the month of September 2021 (<a href="https://medium.com/@zeeshan.dsti2019/virtual-assistant-chatbot-based-on-open-domain-question-answering-using-haystack-framework-d8487ef5ae73"><strong>https://www.sciencedirect.com/science/article/pii/S1877050921015854</strong></a>).</p><p>The efficiency of ODQA using Haystack Framework depends on what types of Retriever-Reader are employed, fine-tuning with the guidelines of question format and also the top-k parameters for both Reader and Retriever.</p><h3>Acknowledgment</h3><p>I would like to express my special thanks of gratitude to my mentors <strong>Dr. Asma Trabelsi, </strong>and <strong>Emmanuel Helbert</strong> for their able guidance and support in completing my work. I would also like to extend my gratitude to <strong>colleagues at Alcatel Lucent Enterprise</strong> for providing me with all the facilities and infrastructure that were required.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8487ef5ae73" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>