Downloaded From: Https://ray - Yorksj.ac - Uk/id/eprint/9863/: Institutional Repository Policy Statement
Downloaded From: Https://ray - Yorksj.ac - Uk/id/eprint/9863/: Institutional Repository Policy Statement
Downloaded From: Https://ray - Yorksj.ac - Uk/id/eprint/9863/: Institutional Repository Policy Statement
The version presented here may differ from the published version or version of record. If
you intend to cite from the work you are advised to consult the publisher's version:
http://dx.doi.org/10.36548/jitdw.2024.1.006
RaY
Research at the University of York St John
For more information please contact RaY at [email protected]
Journal of Information Technology and Digital World (ISSN: 2582-418X)
www.irojournals.com/itdw/
3
Department of Library and Learning Services, York St John University, London, United
Kingdom
Abstract
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1, Pages 70-86 70
DOI: https://doi.org/10.36548/jitdw.2024.1.006
Received: 04.02.2024. received in revised form: 06.03.2024, accepted: 22.03.2024, published: 07.04.2024
© 2024 Inventive Research Organization. This is an open access article under the Creative Commons Attribution-NonCommercial International (CC BY-NC 4.0) License
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
Keywords: Langchain, PDF Summarizer, Streamlit, OpenAI APIs, ChatBots, Large Language
Models
Introduction
Large language models (LLMs) represent the main element of recent breakthroughs in
NLP, as they transform the way machines interpret and generate human-like text. These
models, trained on vast datasets, demonstrate exceptional capabilities in comprehending and
creating natural language, making them perfect candidates for powering specialized chatbots
to document summarization and question-answering tasks [2]. The value of LLMs in NLP tasks
cannot be emphasized since they enable chatbots to analyze and synthesize complicated textual
information with unparalleled accuracy and efficiency [3]. The rationale for designing
customized chatbots for document summarizing and question-answering originates from the
inherent challenges caused by information overload. As the volume of digital information
continues to rise dramatically, individuals and organizations are flooded with massive amounts
of textual data, making it increasingly difficult to extract meaningful insights promptly.
Customized chatbots equipped with document summarizing and question-answering
capabilities offer a solution to this difficulty, enabling users to effectively explore and derive
meaningful insights from vast quantities of text [4].
OpenAI's GPT models, in particular, have gained notable attention in the field of NLP
because of their capacity to provide logical and contextually relevant text. Exclusively pre-
trained on vast amounts of text data, these models stand as the backbone of this platform ,
providing the core language understanding capabilities necessary for document summarizing,
and question-answering activities [5].On the other hand, LangChain enhances the capabilities
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 71
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
of OpenAI's GPT models by offering a framework for performing linguistic processing tasks
efficiently. With its modular architecture and wide support for diverse NLP activities,
LangChain supports the integration of language models into chatbot applications effortlessly
[6]. Streamlit serves as the user interface foundation for our proposed framework, enabling
developers to design intuitive and interactive interfaces for chatbots. With its simplicity and
versatility, Streamlit has improved the creation and deployment of chatbot apps, allowing users
to interact seamlessly with the system [7].
Background Study
In this research review, the progress of NLP technology and the essential role of LLMs
in redefining the capabilities of chatbots has been examined along with the importance of
personalized chatbots that can summarise documents and answer questions to address the
difficulties caused by an excessive amount of information. The article [1] utilized extractive
summarizers to refine the main components of research papers, aiming to address information
overload in the scientific literature. Through experiments, they found that enhancements
considering the text's sophisticated structure improved summarization, especially for languages
lacking refined NLP tools. This approach helped overcome challenges in extracting relevant
insights from vast amounts of scientific text, emphasizing the need for deep text understanding
for high-quality summaries. [2] explored conversational interfaces, specifically chatbots, in the
context of AI ethics. The study explored the differences between scenario-based and large
language model (LLM)-based chatbots in generating recommendations and discussed the
ethical implications of LLM-based recommendations. By comparing their characteristics and
limitations, the study highlighted concerns such as transparency, fairness, privacy, and
ISSN: 2582-418X 72
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
Re discussed. The results showcased the model's ability to generate accurate and
human-like summaries across various dimensions. The paper concludes by emphasizing the
significance of automatic text summarization tools in meeting the increasing demand for
accessible and user-friendly solutions, especially in the mobile domain, and proposes future
directions for their development to cater to a wider audience. The authors of [8] developed a
content generation tool utilizing the OpenAI language model, specifically GPT-3, as an API to
streamline content creation for businesses and individuals. Powered by advanced machine
learning algorithms, including a recurrent neural network (RNN) architecture, the tool aimed
to efficiently produce high-quality content across various platforms. With a user-friendly
dashboard, it offered a range of features, such as Facebook ads, LinkedIn posts, Amazon
product descriptions, and blogs. Addressing the challenges of limited writing skills and time
constraints, the tool emphasized its efficacy in simplifying content creation across multiple
platforms, highlighting its value in assisting users with diverse content generation needs.
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 73
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
The study of [9] introduced LangChain, a query system utilizing LLMs for efficient
information retrieval from PDF documents. By employing natural language processing
algorithms and Streamlit, the authors found that LangChain streamlined the querying process
and enhanced information retrieval. This approach overcame challenges in extracting relevant
information from PDFs, offering a valuable tool for efficient data access. The authors of [10]
explored a new approach to text summarization models by considering large language models
(LLMs) like GPT-3.5 as reference or gold-standard oracles. They investigated the implications
of using LLMs as references for model training and evaluation practices. The research
investigated two LLM-based methods for evaluating summary quality, namely GPTScore and
GPTRank, in conjunction with contrastive learning training techniques leveraging LLM-
guided signals. Experiments conducted on CNN/DailyMail and XSum datasets demonstrated
that smaller summarization models could attain comparable performance to LLMs when
evaluated using LLM-based criteria.
In their study outlined in reference [6], researchers explored the utilization of LLMs for
rapid application development, centering on LangChain, an accessible open-source software
library.Highlighting LLMs like OpenAI's ChatGPT, renowned for tasks such as essay writing
and code generation, the research underscored LangChain's modular structure. By showcasing
practical examples across autonomous agents, chatbots, and document-based question
answering, the study illuminated LangChain's prowess in accelerating application
development. It emphasized the revolutionary impact of LLMs in the AI landscape and
positioned LangChain as a pivotal tool in streamlining the development process, fostering
ongoing exploration and innovation in the domain. The research of [11] investigated the
problem-solving capabilities of LLMs like LaMDA, OPT, and GPT-3 in math word problems.
Using the SVAMP dataset, GPT-3's “davinci-002” model showed robust performance on both
ISSN: 2582-418X 74
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
symbolic and numeric problems, with a two-step approach improving accuracy in the
numerical test set. Specific prompting techniques enhanced the model's ability to explain its
thought process and solve complex problems. The study suggested that large LLMs can
effectively solve symbolic math problems but highlights room for improvement.
In the paper [13], they have introduced an approach for abstractive text summarization
applying deep learning, aiming for precise and coherent summaries without redundancy. It
employed an Encoder-decoder architecture with Bi-LSTM and attention mechanisms to reduce
repetition as well as to enhance the contextual phrase generation. The model focused on multi-
sentence summarization using the Double Attention Pointer Network and employed data
processing methods such as cleansing, padding, and tokenizing. The proposed model, utilizing
T5 for conditional generation and evaluated using ROUGE scores, shows competitive
performance compared to the SASSBOOK TOOL with Daily Mail dataset and CNN ,
achieving a ROUGE score of 71%. The paper concluded that the proposed algorithm yields
promising outcomes, outperforming existing methods in terms of semantic and syntactic
structure, and suggests future work to enhance the system by including the paraphrasing
method that has a abstractive summarizer.
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 75
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
dependent aspects. Sentences were scored using cosine similarity, and the top five formed the
summary. Elmo embedding facilitated accurate summary generation. Future work includes
improving summarization for multiple documents and enhancing speed and accuracy.
[15] The proposal suggests integrating LLMs, including GPT-based technologies, into
multiagent systems (MASs) to improve the communication and decision-making capabilities.
A novel agent architecture, that is based on the MAPE-K model, has been devised to enhance
conversational features, reasoning, and decision-making abilities. Through a marketplace
scenario, integration showcased the potential to revolutionize agent interactions and problem-
solving capabilities within MASs. Challenges such as computational overhead and
interpretability of decisions were acknowledged for future improvement. [16] created a web
application that aimed to create concise summaries of YouTube video transcripts using NLP
techniques and the Flask framework to overcome challenges in accessing video content
efficiently. By providing features such as translation and text-to-speech, the authors found that
the summarizer improved user accessibility to video content, overcoming challenges in
understanding lengthy videos.
From the literature review, it is evident that the integration of AI and NLP technologies,
particularly through large language models (LLMs), offers promising solutions for addressing
information overload. Chatbots powered by these technologies excel in tasks such as document
summarization and question answering, demonstrating their efficiency in managing vast
amounts of digital information across various domains.
ISSN: 2582-418X 76
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
Framework Architecture
Initially, the PDF document is uploaded into the system, followed by the importation
of the PdfReader class from the PyPDF2 module. This Python library facilitates working with
PDF files, allowing tasks like reading, manipulation, and text extraction from PDF documents.
The whole document will be split into chunks, creating an embedding from each chunk,
and all the chunks will be stored in the vector database. In the context of data processing, a
chunk is the segment of the data that has been divided from a larger dataset. It is often employed
to break down into more manageable units for processing, analysis, or storage. Embeddings
are quantitative representations of data that encapsulate its semantic meaning. In natural
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 77
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
language processing (NLP), word embeddings are frequently employed to depict words as
vectors within a high-dimensional space. This representation arranges words with akin
meanings closer together in the vector space. These embeddings can be generated through
diverse techniques, including Word2Vec, GloVe, or deep learning models like transformers.
In this paper, we utilized the OpenAI embeddings class from the LangChain embeddings.
OpenAI module. It is a part of the LangChain package and provides embeddings based on
OpenAI’s language models for text data. A vector store, also known as a knowledge base, is a
repository where embeddings or vectors representing data are stored. The embeddings
generated from the extracted data are stored in a vector store, which acts as a repository of
knowledge that the system can reference during the search process. This vector store facilitates
semantic search and retrieval of relevant information based on user queries.
When the user asks a question i.e prompt, it performs a semantic search in the vector
store and searches for the chunks to find the ranked results. Based on the large language model,
the OpenAI API has been integrated at the backend, which answers the user. If the user is
satisfied with the answer, they can use it; if not, the user will ask with a more detailed
customized prompt and wait for the specific answer. The figure 2 defines the proposed system
block diagram.
ISSN: 2582-418X 78
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
The open AI API secret key was created from the OpenAI website and saved in an
environment that needs to be treated like the password and avoid sharing it publicly. Once the
secret key has been created (shown in Figure 3), it can be used for accessing the OpenAI API
and integrate it into our application, projects, and research.
The web application was designed using Streamlit, which is a promising open-source
Python library that enables developers to build interfaces most easily. It simplifies the process
of creating interactive and customizable web-based user interfaces (UIs) directly from Python
scripts without needing knowledge of web development languages such as HTML, CSS, or
JavaScript. Users can create interactive components such as sliders, buttons, text inputs, and
data visualizations with only a few lines of code [18].
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 79
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
Figure 4 shows the interface of our web application, where the information has been
kept on the left side of the web and the ask about your pdf has been the main target where it
takes pdf files. This whole system has been integrated with Streamlit, long-chain, and OpenAI
large language models. When people are trying to save time and quickly want to receive a
response from that pdf, they can simply ask the chatbot any questions, and answers can be
obtained by searching in the pdf.
Initially, the script verifies whether a PDF file has been uploaded (i.e., checks if the
variable ‘pdf’ is None). Upon confirmation of an uploaded PDF file, it instantiates a PdfReader
object to access the contents of the PDF (shown in figure 5). It iterates through PDF document
to retrieve the text from each page. Finally, it concatenates the extracted text from all pages
into a unified string variable.
ISSN: 2582-418X 80
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
Once the PDF is uploaded, the question-answering chatbot is initialized and a question
from the user about the PDF is asked (as shown in figure 6).
Prompt 1
From the given pdf file
'Self-Adaptive_Large_Language_Model_LLM-Based_Multiagent_Systems', please
summarize the pdf in approximately 200 words including all the details that have been
discussed in the paper (shown in figure 7).
Results
This paper presents a novel method for overseeing multiagent systems (MASs) within
autonomic computing. This method entails incorporating large language models (LLMs),
particularly GPT-based technologies, into MASs to enhance communication and the
adaptability of agents. Additionally, this paper introduces a fresh architecture for LLM/GPT-
based agents founded in the MAPE-K model, fostering system adaptability within dynamic
environments. To assess this approach, a simplified marketplace scenario served as a testbed,
where autonomous agents utilized embedded LLMs to make decisions and exhibit self-
adaptation. The future work will include establishing individual OpenAI accounts for each
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 81
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
agent and investigating alternative application scenarios. overall, this paper proposes for a
paradigm shift in MAS self-adaptation and indicates further research prospects to evaluate the
viability of LLMs in increasingly intricate MAS scenarios.
Result: A self-adaptive large language model (LLM) is a type of technology that is integrated
into multiagent systems (MASs) to enhance communication and adaptability. It uses cutting-
edge large language models, such as GPT-4, to enable agents to adapt to complex tasks and
react intelligently to changing situations. This technology is based on the MAPE-K model,
which is known for its ability to support system adaptations in response to dynamic
environments (shown in figure 8).
ISSN: 2582-418X 82
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
The framework has some limitations where it relies on pre-trained language models,
like OpenAI’s GPT models, which may not always understand specialized topics well or
summarize complex documents accurately. While these models excel in generating human-like
text, their summarization performance can be hindered by documents outside their training data
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 83
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
scope. Additionally, dependence on cloud-based APIs like OpenAI raises concerns regarding
data privacy, security, and long-term service availability. Hence, careful consideration and
potential fine-tuning are essential to ensure the chatbot’s robustness and reliability, particularly
in diverse and specialized domains.
References
[1] Balage Filho, Pedro Paulo, TA Salgueiro Pardo, and M. das Gracas Volpe Nunes.
"Summarizing scientific texts: Experiments with extractive summarizers." In Seventh
International Conference on Intelligent Systems Design and Applications (ISDA 2007),
pp. 520-524. IEEE, 2007.
[2] Bang, Junseong, Byung-Tak Lee, and Pangun Park. "Examination of Ethical Principles
for LLM-Based Recommendations in Conversational AI." In 2023 International
Conference on Platform Technology and Service (PlatCon), pp. 109-113. IEEE, 2023.
ISSN: 2582-418X 84
Sangita Pokhrel, Swathi Ganesan, Tasnim Akther, Lakmali Karunarathne
[3] Prasad, Rajesh S., U. V. Kulkarni, and Jayashree R. Prasad. "Machine learning in
evolving connectionist text summarizer." In 2009 3rd International Conference on
Anti-counterfeiting, Security, and Identification in Communication, pp. 539-543. IEEE,
2009.
[4] Nalini, N., Agrim Narayan, Akshay Mambakkam Sridharan, and Arkon Pradhan.
"Automated Text Summarizer Using Google Pegasus." In 2023 International
Conference on Smart Systems for applications in Electrical Sciences (ICSSES), pp. 1-
4. IEEE, 2023.
[5] Patil, Dinesh D., Dhanraj R. Dhotre, Gopal S. Gawande, Dipali S. Mate, Mayura V.
Shelke, and Tejaswini S. Bhoye. "Transformative trends in generative ai: Harnessing
large language models for natural language understanding and
generation." International Journal of Intelligent Systems and Applications in
Engineering 12, no. 4s (2024): 309-319.
[6] Topsakal, Oguzhan, and Tahir Cetin Akinci. "Creating large language model
applications utilizing langchain: A primer on developing llm apps fast." In International
Conference on Applied Engineering and Natural Sciences, vol. 1, no. 1, pp. 1050-1056.
2023.
[7] Monks, Thomas, and Alison Harper. "Improving the usability of open health service
delivery simulation models using Python and web apps." NIHR Open Research 3
(2023).
[8] Pokhrel, Sangita, and Shiv Raj Banjade. "AI Content Generation Technology based on
Open AI Language Model." Journal of Artificial Intelligence and Capsule Networks 5,
no. 4 (2023): 534-548.
[9] S, Adith Sreeram A, and Pappuri Jithendra Sai. “An Effective Query System Using
LLMS and Langchain.” International Journal of Engineering Research & Technology,
July 4, 12(6), 2023. 367 -369
[10] Liu, Yixin, Alexander R. Fabbri, Pengfei Liu, Dragomir Radev, and Arman Cohan. "On
learning to summarize with large language models as references." arXiv preprint
arXiv:2305.14239 (2023).
Journal of Information Technology and Digital World, March 2024, Volume 6, Issue 1 85
Building Customized Chatbots for Document Summarization and Question Answering using Large Language Models using a Framework with OpenAI, Lang
chain, and Streamlit
[11] Gaur, Vedant, and Nikunj Saunshi. "Symbolic math reasoning with language models."
In 2022 IEEE MIT Undergraduate Research Technology Conference (URTC), pp. 1-5.
IEEE, 2022.
[13] Shibi, Krithick, R. Kingsy Grace, and M. Sri Geetha. "Abstractive Summarizer using
Bi-LSTM." In 2022 International Conference on Edge Computing and Applications
(ICECAA), pp. 1605-1609. IEEE, 2022.
[14] Gupta, Hritvik, and Mayank Patel. "Study of extractive text summarizer using the elmo
embedding." In 2020 Fourth International Conference on I-SMAC (IoT in Social,
Mobile, Analytics and Cloud)(I-SMAC), pp. 829-834. IEEE, 2020.
[15] Nascimento, Nathalia, Paulo Alencar, and Donald Cowan. "Self-adaptive large
language model (llm)-based multiagent systems." In 2023 IEEE International
Conference on Autonomic Computing and Self-Organizing Systems Companion
(ACSOS-C), pp. 104-109. IEEE, 2023.
[16] Kumar, Jitender, Ritu Vashistha, Roop Lal, and Dhrumil Somanir. "YouTube
Transcript Summarizer." In 2023 14th International Conference on Computing
Communication and Networking Technologies (ICCCNT), pp. 1-4. IEEE, 2023.
[18] pokhrel, Sangita. “LLM Based PDF Summarizer and Q/A App Using OpenAI,
LangChain, and Streamlit.” Medium, February 26, 2024.
https://medium.com/@sangitapokhrel911/llm-based-pdf-summarizer-and-q-a-app-
using-openai-langchain-and-streamlit-807b9b133d9c.
ISSN: 2582-418X 86