$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Comprehensive Theoretical Basis
QAS Component: The QAS framework consists of three segments, as shown in Figure 3: i) Question processing module (QPM), ii) Document processing module (DPM), and iii) Answer extraction and formulation module (AEFM). The system receives questions that fall into two main categories: Factoid and Non-Factoid. Factoid questions typically use interrogative words like what, where, when, or who, while non-Factoid questions use words such as how and why.
DPM: From the provided list, the user may select a specific passage. Next, each token in the passage is tagged using a Part-of-Speech (POS) Tagger. To extract verbs, identify all tokens tagged as verbs. Combine these verbs with a list of unconventional verbs and apply logic for regular verbs. Create a data structure (array) containing the extracted verbs, their tenses, and their -ing forms.
QPM: The system receives input in the form of a question from the user. The text is tokenized using the StringTokenizer class, and the resulting tokens are stored in a separate data structure. This data structure is then returned for further utilization within the programme.
AEFM: The first step is identifying the verb in the given question. The verb that has been recently identified is now matched with the tokens that were generated during the document processing stage. The chosen case for a specific type of factual question (such as what or when) is utilized to extract and construct the answer in a more precise manner.
Before choosing the sort of questioning, the user is first prompted to select the passage of their choice. The QPM is responsible for processing the user's question and forwarding it to the AEFM. The AEFM utilizes the extractions obtained from the DPM and the processed documents that contain the tagged format of the original input document. The module will pass the required algorithms to the formulation module to obtain the desired answer.

Figure 3: Components of QAS. The figure illustrates the four-step process of a QA system: Question, Question Processing, Answer Processing, and Answer. In Question Processing, the system classifies the question. In Answer Processing, it finds and reviews documents and passages to produce the answer. Please click here to view a larger version of this figure.
BERT model: To discover the associations between words in a text, the BERT method uses a transformer. There are two mechanisms in a transformer- an encoder and a decoder28, but just the encoder is needed for BERT. BERT takes a two-way approach and systematically scans the input text to teach itself the meaning of words in their context. The encoder takes as input a series of tokens that have been vectorized. The vectors are then fed into the neural network, which produces a series of vectors that reflect the input. A word's output vector changes depending on the sentence in which it appears. A word's vector might vary depending on the context in which it appears; for instance, "like" in "He likes to play cricket" has a different vector than "like" in "His face turned red like a tomato." The approach begins with a phase of text processing before moving on to the model-building phase. The steps that BERT takes to process text are discussed in the next section28.
Text processing: The BERT model represents input text in accordance with a prescribed set of principles. Additionally, this factor contributes to the improved performance of the model. The input embedding in BERT consists of an amalgam of three distinct types of embeddings28.
Position embeddings (PEs): To learn the order-related information in the embeddings, PEs are used. PEs are used to restore information about the order that is lost in transformers. BERT develops distinct PEs specifically for each point in the input sequence. BERT possesses the capability to convey the positional information of words inside a sentence by utilizing PEs. This enables BERT to effectively capture and represent the sequence or order of words.
Sentence embeddings (SEs): Additionally, to assist the model in distinguishing between the first and second sentences, BERT learns an embedding that is unique to each of them. It is also capable of accepting paired sentences as inputs for activities such as QA.
Token embeddings (TEs): TEs are taught for each token in the WordPiece token vocabulary. The WordPiece token vocabulary comprises sub-word units derived from words found within the corpus. As an illustrative instance, this vocabulary collection will encompass all conceivable sub-words of the term Question, including Questio, Questi, and so on.
A token's input representation is built by adding together its embeddings at the segment and position levels. Because of this, it is an extensive embedding approach that provides a wealth of information to the model. Figure 49 depicts the embeddings of the BERT model.

Figure 4: BERT embeddings. The figure shows how input embeddings are created for a transformer model. It begins with an input sequence: [CLS] the [MASK] sky is cloudy [SEP] it will rain [SEP]. Each token in the sequence receives its own embedding, such as Ethe or E[MASK]. Then, sentence embeddings are added for each sentence, such as EA for the first and EB for the second. Positional embeddings, labelled E0 to E9, are also included to indicate the position of each token. All of these are combined to form the final input embeddings. This figure has been modified from9. Please click here to view a larger version of this figure.
QAS design using BERT: For illustrative purposes, examine this question in conjunction with a paragraph extracted from a Wikipedia entry on Football League28.
Question: Where was the Football League founded?
Passage: In 1888, the Football League was founded in England, becoming the first of many professional football competitions. During the 20th century, several of the various kinds of football grew to become some of the most popular team sports in the world.
Answer: England
The BERT model utilizes token extraction from both the question and context, subsequently combining them into a unified input. As previously stated, the process begins with the utilization of a [CLS] token, which serves as an indicator for the commencement of a sentence. Additionally, a [SEP] separator is employed to distinctly separate the question and passage. In addition to the [SEP] token, BERT incorporates SEs to distinguish between the question and the passage28 containing the answer. BERT uses two SEs, one dedicated to the question and another to the passage, to establish a clear distinction between them. The embeddings are subsequently combined with a one-hot representation28 of tokens to differentiate between the question and the passage. This process is illustrated in Figure 5.

Figure 5: BERT input representation. The figure illustrates how input embeddings are generated for a BERT-based QAS. It starts with the token [CLS], then the question How many? [SEP], and the passage BERT large is, each with its sentence embeddings (A for the question, B for the passage). Token, sentence, and positional embeddings are combined to make the final input. Please click here to view a larger version of this figure.
Subsequently, the combined embedded representation28 of the question and context is utilized as input in the BERT model. The final hidden layer of BERT is modified to use SoftMax to generate probability distributions. These distributions determine the start and end indices of a substring within the input text sentence, which represents an answer, as depicted in Figure 6, for a visual representation.

Figure 6: BERT processing workflow for QA. The figure shows how the BERT model works for QA. It presents an input sequence that includes a question, marked by a classification token [CLS] at the start and a [SEP] separator token at the end, followed by a context, separated by another [SEP]. The tokens in this sequence are turned into embeddings. The model then predicts the start and end positions of the answer within the passage. Please click here to view a larger version of this figure.
Vector database (VD): A VD17,18 is a specialized system for efficiently storing, managing, indexing, and querying high-dimensional vector representations of data. Vectors are often generated from deep learning models and encapsulate semantic or contextual information about the data. Each dimension of a vector represents a specific feature. Embeddings are numerical representations of objects such as text, images, videos, and audio. These embeddings are used in various applications, including Machine Learning (ML), NLP, recommendation systems, computer vision, and IR. VDs facilitate effective similarity searches and semantic querying by grouping similar objects close together in the vector space. Facebook AI Similarity Search (FAISS)29 is a prominent VD used in this study to identify the most relevant context for user queries. Table 2 outlines the main characteristics of VDs and their use cases.
| Feature | Description |
| High-Dimensional Data | Handles data with hundreds or thousands of dimensions. |
| Approximate Nearest Neighbour (ANN) | Enables fast similarity searches by approximating distances. |
| Scalability | Supports large-scale datasets with billions of vectors. |
| Integration | Often integrates with AI/ML frameworks and tools for seamless workflows. |
| Real-Time Queries | Provides low-latency vector searches for interactive applications. |
Table 2: Main characteristics of VD. The table highlights important features of VD. These include handling high-dimensional data, running fast similarity searches using ANN algorithms, scaling to large datasets, working with AI and ML tools, and supporting quick, real-time queries for interactive use.
Performance evaluation metrics: The SCD-QA system was evaluated using two primary metrics: EM score14 and model Latency15. The EM score, a standard metric in QA studies, assesses prediction accuracy by measuring the proportion of predicted answers that exactly match the ground truth. For a set of N questions, the EM score is formally defined in Equation 1 as follows:
where
(1)
This metric assigns a score of 1 for an exact match with the reference answer, and 0 for any difference.
The Latency metric quantifies the total processing time required by the system to generate a response to an individual query. This metric is calculated as the mean elapsed time across all queries, as presented in Equation 2:
(2)
where Tstarti and Tendi are the timestamps marking the start and end of processing the ith query, respectively. Latency is reported in s and captures the system's responsiveness, encompassing all stages from input processing to answer generation.
Method
In order to implement the SCD-QA, the following test studies are incorporated in this paper.
SCD-QA dataset: A proposed dataset30 is introduced for the implementation of the SCD-QA system. This dataset is derived from a text corpus containing Ph.D. rules for 20228, for student guidelines from NIT Arunachal Pradesh, India. To establish the SCD-QA system, it is necessary to generate a JSON file that will encompass all pertinent information in a precise format. The dataset is generated from the text corpus using the Haystack annotation tool (version 2.18.1)31, an open-source framework. This tool facilitates the creation of the SCD-QA dataset in the style of the SQuAD14. The steps to create a SQuAD-type annotated dataset from the PDF file are shown in Figure 7, and the structure of our dataset in SQuAD style is illustrated in Figure 8.

Figure 7: Steps to create an annotated dataset from a PDF file. The figure illustrates a stepwise workflow for creating a SQuAD-style annotated dataset using Haystack tools. It outlines the process from extracting text from PDFs, cleaning and splitting it into passages, manually annotating question-answer pairs, storing the annotations in SQuAD JSON format, and finally exporting the dataset for model training. Please click here to view a larger version of this figure.

Figure 8: Structure of factoid QA dataset. The figure displays a JSON data structure that represents a paragraph and a QA pair from a dataset. It has a paragraphs section, which contains a set of questions and answers. One question asks, What is the minimum mark required to take admission to Ph.D. Science? Each question has an ID and an array of answers. The answer includes a document ID, question ID, the text 60% marks, the starting position of the answer, and an unspecified answer category. The is_impossible flag is set to false. Please click here to view a larger version of this figure.
The dataset is structured as a list of dictionaries, where each dictionary contains key fields such as data, paragraphs, question, answer_id, document_id, question_id, text, answer_start, answer_end, is_impossible, and context.
data: It contains the overall question-answering information.
paragraphs: A particular context, along with its questions and answers.
question: A particular question.
answer_id: A unique identification number for each answer text.
document_id: A unique identification number for each context.
question_id: A unique identification number for each question.
text: The answer text.
answer_start: The answer starting location of the correct answer in context.
answer_end: The answer ending location of the correct answer in context.
is_impossible: It tells whether the answer to the asked question is available in the context or not.
context: The text corpus from which an answer can be found.
All 80 questions in the proposed dataset follow the factoid and non-factoid question format. Samples of some types of framed questions are shown in Table 3.
| Questions |
| Who is PS? |
| What is the font size of the state-of-the-art document? |
| How many days are in Maternity Leave? |
Table 3: Sample question from the dataset. The table shows examples of two types of questions: the first and second are factoid questions, while the third is a non-factoid question.
FAISS: FAISS (version faiss_cpu-1.9.0)29,32, developed by Facebook AI Research (FAIR), is an open-source library that facilitates efficient similarity search and clustering of dense vectors. It is specifically engineered to manage large-scale, high-dimensional data effectively. This system facilitates rapid and scalable ANN searches within datasets comprising millions or billions of vectors. It is widely utilized in applications related to embeddings, including NLP, recommendation systems, and image or video retrieval. FAISS offers multiple indexing methods, including Flat (brute force), Inverted File (IVF), Hierarchical Navigable Small World graphs (HNSW), and product quantization (PQ). These methods enable users to optimize search performance according to data size, dimensionality, and hardware specifications. In this study, flat indexing is used, which performs a brute-force search using the L2 (Euclidean) distance to identify the nearest neighbors. The system's scalability supports both CPU and GPU implementations, enabling high-performance computations across extensive datasets. Additionally, it provides flexibility to optimize the balance between speed and accuracy based on specific application requirements. FAISS is frequently used in NLP to assess semantic similarity in embeddings, such as BERT or Word2Vec. FAISS is utilized in QAS to store and manage vector representations of documents or sentences. It performs approximate ANN searches33 to retrieve the most relevant context for user questions, enhancing semantic search with embeddings from transformer models such as BERT. FAISS is a fundamental tool in AI and ML workflows due to its versatility.
BERT-large-uncased-whole-word-masking-finetuned- SQuAD model: The present work utilizes a pre-trained language model known as BERT-large-uncased-whole-word-masking finetuned-squad9 to develop a factoid QAS using the dataset proposed in the study. The BERT model underwent pre-training on BookCorpus, a dataset of 11,038 unpublished books9, as well as English Wikipedia, with the exception of lists, tables, and headings. The model in question is uncased, meaning that it does not distinguish between the words english and English. The model is a pre-trained transformer model that has been trained on a substantial amount of English data using a self-supervised approach. The model was pre-trained exclusively on raw texts, without any human annotations. This allows it to leverage a large amount of publicly accessible data. The pre-training process involves automatically generating inputs and labels from the provided texts. The model was trained with two specific objectives9:
MLM: The process involves randomly masking 15%9 of the words in the input sentence. The model then processes the entire masked sentence and predicts the masked words. This approach diverges from conventional Recurrent Neural Networks (RNNs), which typically process words sequentially, and from autoregressive models such as GPT, which employ internal masking of future tokens. The functionality enables the model to acquire a bidirectional representation of the sentence.
NSP: During the pretraining phase, the model combines two disguised sentences as inputs. In some cases, these sentences are adjacent in the original text, indicating a direct relationship. In other cases, they are not, meaning there is no original proximity or context linking them. The subsequent step involves the model predicting whether the two sentences are logically coherent.
The present model is characterized by the subsequent configuration: the model architecture consists of 24 layers, with a hidden dimension of 1024. It utilizes 16 attention heads and has a total of 336 million parameters9.
WordPiece is used to tokenize the texts with a 30,000-word vocabulary size in the pre-processing steps. The model's inputs would then look like this: [CLS] Sentence A [SEP] Sentence B [SEP]. The only requirement is that the total length of the combined sentences is less than 512 tokens9. The specific pre-trained model yields the subsequent output: the F1 score achieved is 93.15%, whereas the precise match score is 86.91%9.
Distilbert/distilbert-base-cased-distilled-squad model: The DistilBERT10 model is a more compact, rapid, and efficient variant of the BERT9 model, developed to maintain the majority of BERT's semantic ability to comprehend while being less resource-intensive and more appropriate for practical applications with restricted computational capacity. The version distilbert-base-cased-distilled-squad has been fine-tuned on the SQuAD14 for QA tasks. The model utilizes the transformer architecture, including a decreased size of 66 million parameters in contrast to BERT's 110 million, while maintaining 97% of BERT's efficacy in language comprehension. DistilBERT reaches this using a method known as Knowledge Distillation, which conveys information from the larger BERT model to the more compact DistilBERT model. Because of its smaller size, it can infer information more quickly and use less memory, which makes it perfect for resource-constrained applications like mobile or edge devices. The model, carefully fine-tuned on the SQuAD 1.1 dataset, demonstrates exceptional proficiency in extractive QA tasks, whereby the objective is to locate a segment of text from a specified context that answers a question. DistilBERT achieves approximately 85% of BERT's F1 score on the SQuAD leaderboard and retains a significant portion of BERT's linguistic capacity, despite its reduced size. This model is an exceptionally efficient solution for production-level QA jobs, optimizing both performance and computational efficiency.
Deepset/roberta-base-squad2: The deepset/roberta-base-squad2 model12,13 is a fine-tuned variant of the RoBERTa architecture. It is specifically designed for the SQuAD14 2.0 dataset, which includes both answered and unanswerable questions. This improved RoBERTa framework eliminates BERT's9 NSP jobs. It also uses dynamic masking during training to boost efficiency and performance in NL comprehension tasks. The model has 125 million parameters and uses a bidirectional transformer. This allows it to acquire contextual information from both directions and excel at extractive QA tasks.
Fine-tuning on SQuAD 2.0 enables the model to identify the correct response span within a given context and to recognize when there is no answer. It uses a Byte Pair Encoding (BPE) tokenizer that handles sub-word tokenization and preserves case sensitivity. This improves its ability to process uncommon and complex words. The model performs well, achieving roughly 85%-90% F1 and 80%-85% EM. Its ability to spot unanswerable questions and its effective deployment make it valuable for customer service, knowledge retrieval, and virtual assistants.
The most effective way to deploy SQuAD-fine-tuned BERT models for QA is to use the Hugging Face Transformers pipeline34. This framework streamlines tokenization, input formatting, model loading, and output post-processing. These models are widely recognized for their effectiveness in extractive QA, where the answer is a text span directly retrieved from the given context. To guide implementation, the following procedure outlines the steps for executing BERT models.
Input and setup: This process requires four main inputs and setup parameters: the model name, specified as a string identifier from the Hugging Face Hub (for example, google-bert/bert-large-uncased-whole-word-masking-finetuned-squad, distilbert/distilbert-base-cased-distilled-squad, or deepset/roberta-base-squad2); the question (Q), provided as a string containing the query; and the context (C), a string representing the relevant text or passage. The primary tool used is the high-level pipeline function from the Hugging Face transformers library (version 4.57.0) in Python (version 3.12.12).
Process: Execution (Hugging Face Pipeline): The process consists of six primary steps and employs the Hugging Face pipeline to address the complexity of the QA task:
Install Library: Begin by installing the required library with the command pip install transformers. This installation enables access to the models and the streamlined pipeline functionality.
Import Pipeline: Import the pipeline function using: from transformers import pipeline.
Initialize QA Pipeline: Initialize the QA pipeline using qa_pipeline = pipeline("question-answering", model=""). This command downloads the model and tokenizer, making them ready for inference.
Define Input: Set question = ... and context = ... to prepare the model's data.
Run Inference: Pass the question and context to the pipeline with result = qa_pipeline(question=question, context=context). The model processes the input and provides an answer.
Extract Answer: Get the answer string from the output dictionary using: answer = result['answer'].
Output: The process produces several output parameters in the following order: Answer (the extracted text span from the context, presented as a string), Score (a floating-point value quantifying the model's confidence in its prediction), and Start and End indices (integers specifying the character positions of the answer span within the context).
Sentence-transformers/all-MiniLM-L6-v2: The all-MiniLM-L6-v235 is a pre-trained sentence transformer from the Sentence-Transformers library (version 5.1.1)36. It is optimized for efficient, precise text embedding. Developed on Microsoft's MiniLM framework, it includes six transformer layers and 384-dimensional embeddings. This design balances performance and computational proficiency, making it suitable for real-time applications. The model was trained on over a billion phrase pairs from datasets like SNLI, MultiNLI, STS benchmarks, and web-crawled data. As a result, it demonstrates proficiency in semantic similarity, grouping, and search-related tasks. Because of its small size (~22MB) and enhanced inference performance, all-MiniLM-L6-v2 simplifies applications such as semantic search, duplication detection, and text categorization. Although it is lightweight, it delivers strong accuracy on benchmarks such as STS-B and SICK-R, making it an effective choice for both scalable and limited-resource scenarios. The workflow for generating the embedding using Sentence-Transformer is depicted in Figure 9 below.

Figure 9: Step of the embedding process using the sentence transformer model. The figure illustrates the workflow for generating text embeddings using the sentence transformers framework. It outlines the process from importing libraries and loading a pretrained model to preparing text data, generating embeddings, converting them into NumPy arrays, and storing them for downstream tasks like indexing or similarity search. Please click here to view a larger version of this figure.
Proposed algorithm: This study outlines a suggested methodology in Algorithm 1 for the development of the SeCD-based SCD-QA system, capable of addressing both factoid and non-factoid questions asked by users.
ALGORITHM 1: Algorithm of the proposed SeCD-based SCD-QA system
Input: Set of raw context file (C), and the User's query (Q).
Output: The selected optimal transformer-based LLM (M'), and the response generated by M'.
Pre-processing Contexts: Annotate the raw context set C to create a structured dataset in DSQuAD format.
DSQuAD = fannonate (C)
Generate Context Embeddings: Use a Sentence-Transformer fembed to convert each context c
DSQuAD into an embedding ec.

Store Embeddings: Store Ec in a vector database V for efficient similarity search.

Generate Query Embedding: Transform the user's query Q into an embedding eq using the same Sentence Transformer.

Context Retrieval: Retrieve the most relevant context embedding
from the database V based on similarity to eq.

where sim(eq,ec), is the similarity function.
Pass Context to LLMs: Feed the retrieved context
into 3 transformer-based LLMs: Google-BERT (M1), DistilBERT (M2), RoBERTa (M3) and a traditional model: TF-IDF+Cosine Similarity (M4)

Model Evaluation: Compare the responses {R1,R2,R3,R4} using an evaluation function feval, which scores each response.

Select the Best Model: Identify the model M' with the highest evaluation score S'

Generate Final Output: Use M' to generate the final response R based on 

End
The proposed algorithm process outlines a systematic approach (Figure 10) for choosing an ideal transformer-based LLM to address user questions. It incorporates preprocessing, embedding-based context retrieval, and multi-model assessment to guarantee high-quality and contextually relevant answers. Below, the step-by-step process is explained for clarity:
Data Preparation and Preprocessing: The first phase involves the processing of raw textual data-
Input: The raw text files8 are adapted into the system.
Annotation Tool31: The input is transformed into a structured dataset in SQuAD14 format. This step involves creating QA pairs. It also organizes relevant textual data into well-defined context blocks.
Output: The dataset is now ready to create embeddings.
Context Embedding Generation: To enable efficient and scalable context retrieval, a trained Sentence-Transformer35,36 model is applied to the annotated dataset. This transformer converts text into high-dimensional embeddings that capture semantic meaning. The embeddings are stored in VD, FAISS29,32 to enable fast similarity-based searches.
User Query Processing: When a user submits a question, the question is processed by the same Sentence Transformer35,36. This generates a corresponding embedding in the same vector space29,32 as the context embeddings. This design ensures the query can be matched with relevant context entries.
Context Retrieval Using Vector Similarity: Using a similarity metric (e.g., cosine similarity), the system compares the query embedding with stored context embeddings. The system selects the most relevant context based on the highest similarity score. This ensures that only pertinent context is passed to downstream models. The process reduces computational overhead and improves relevance.
Model Evaluation Across Multiple LLMs: The selected context is evaluated by three transformer-based LLMs: Google-BERT28, DistilBERT10, and RoBERTa12. It is also evaluated by a traditional keyword-based TF-IDF37 with a cosine similarity model. Each model processes the context and generates a response to the user's question.
Comparative Evaluation: The responses from the four LLM models are evaluated using two key metrics. First, semantic matching is assessed by EM14. Second, model Latency is analyzed by the mean reaction times15.
Model Selection and Final Output: The best-performing model is selected as the appropriate LLM for the user's question. The final response from the selected model is considered. This ensures a balance between computational efficiency and response quality.

Figure 10: Workflow of the SCD-QA system using transformer-based models. The figure shows how the SCD-QA system works. First, a raw context file is processed by an annotation tool to create a dataset in SQuAD format. A sentence transformer then generates embeddings, which are stored in a FAISS vector database. When a user asks a question, the system creates an embedding for it and selects the most relevant context. It compares three transformer-based models- Google-BERT, DistilBERT, and RoBERTa, and one traditional TFIDF + cosine similarity score -and uses the best-performing one to provide the answer. Please click here to view a larger version of this figure.