Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Large Language Models in Consumer Electronic Retail Industry: An AI Product Advisor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology

ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Large Language Models in Consumer Electronic


Retail Industry: An AI Product Advisor
Loo Seng Xian1; Lim Tong Ming2*
Tunku Abdul Rahman University of Management and Technology
Kuala Lumpur, Malaysia

Corresponding Author: Lim Tong Ming2*

Abstract:- This paper explores the development of an The role of product or sales advisors in customer
AI product advisor utilizing large language models education and engagement is central to the retail shopping
(LLMs). Firstly, we discuss the needs and the current experience and cannot be overstated. With extensive
problems faced by industry. Subsequently, we reviewed training on product specifications, usage, reviews, and
past works by various scholars regarding AI Assistant compatibility, product advisors can provide tailored advice
in Retail and Other Industries, and LLM Models and that aligns with the specific needs and preferences of each
techniques used in generative AI chatbot for sales and customer (AIContentfy, 2023). This personalized
service activity related works. Next, we assessed the interaction not only enhances customer satisfaction but also
performance of various models including Llama2B, fosters loyalty. As consumer electronics and appliances
Falcon-7B, and Mistral-7B, in conjunction with continue to advance technologically, the expertise required
advanced response generation techniques such as by product advisors deepens, necessitating continuous
Retrieval Augmented Generation (RAG), fine-tuning training to keep up with the latest technological
through QLora and LLM chaining. Our experimental advancements and product releases. But with vast amounts
findings reveal that the combination of Mistral-7B with of features and functions, to promote the products
the RAG and LLM chaining technique enhances both effectively and accurately to the potential consumer, it is
efficiency and the quality of model responses. Among always a great challenge.
the models evaluated, Mistral-7B consistently delivered
satisfactory outcomes. We deployed a prototype system Based on the material we have studied; many
using Streamlit, creating a chatbot-like interface that electronic retail stores are integrating advanced
allows users to interact with the AI advisor. This technologies such as augmented reality (AR) and virtual
prototype could potentially increase the productivity of reality (VR) besides personalized service bots to create
frontliners in the retail space and provide benefits for immersive experiences that simulate product usage (Kim et
the industry. al., 2022). These technologies help to bridge the gap
between a customer’s perception and the actual product
Keywords:- Mistral-7B, Llama-2, Falcon-7B Generative functionality, thereby aiding in informed purchasing
AI, Generation AI, Language Model-based AI, Retrieval decisions. As consumers today are more informed and hold
Augmented Generation (RAG), QLora, LangChain higher expectations due to easy access to product
information online, retail stores are challenged to provide
I. INTRODUCTION added value through exceptional customer service and
expert advice, areas where product advisors are pivotal.
A. Background of the Consumer Electronics Retail This shift in consumer expectations underscores the
Industry ongoing relevance of retail stores and their product advisors
The consumer electronic industry has seen a in the consumer journey, despite the growing prevalence of
significant transformation in consumer shopping experience e-commerce in the electronic consumer industry.
at the retail outlets; evolving from mere sales points to
sophisticated experience centers (Reinart et al., 2019). B. Needs of the Consumer Electronics Retail Industry
These modern retail environments are designed to allow In the fast-paced consumer electronics retail industry,
customers to interact with and test products firsthand, addressing specific operational and strategic needs is
offering a tactile experience that online platforms cannot crucial for sustaining growth and enhancing customer
replicate. This hands-on approach is crucial in aiding satisfaction. To stay competitive, retailers must
consumers' decision-making processes when it comes to continuously adapt by integrating emerging technologies
electronic products, which often require a feel for usability such as AI powered gadgets to their product offerings
and quality. (Hopkins, M., 2023). This approach not only keeps
offerings current but also meets the high expectations of
today's tech-savvy consumers.

IJISRT24MAY2422 www.ijisrt.com 3260


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Enhancing customer experience is another need of the prepared to handle different types of customer interactions
industry, especially in a market where many products have effectively. Overall, the integration of a sales assistant
minimal technical differentiation. Providing exemplary chatbot empowers new staff by equipping them with the
customer service, personalized marketing, and tools and knowledge needed to excel in their roles from the
comprehensive after-sales support can significantly outset.
differentiate a retailer in the consumer's eyes (Varnika Om,
2022). Each interaction needs to be positive and tailored, C. Problems faced by Industry
transforming basic transactions into unique experiences that One of the problems faced by those in the industry is
encourage loyalty and repeat business. stiff competition. The consumer electronics sector is
characterized by intense competition not just within local
Efficient inventory management is equally vital. markets but on a global scale. Retailers must constantly
Retailers must employ accurate demand forecasting and innovate and differentiate their offerings to capture
efficient stock management systems to prevent stock customer loyalty to reduce churn rate. This includes not
surplus (Netstock, 2023), hence minimizing overhead costs only the latest technology but also richer and higher quality
to align with the dynamic consumer demand. Additionally, services like extended warranties, flexible return policies,
developing a seamless omnichannel presence is essential and loyalty programs. Companies compete on multiple
(Expert Marketing Advisors, 2023). This approach fronts—product variety, price, technological advancements,
integrates various shopping channels—online, in-store, and and customer service quality. To maintain a competitive
mobile—to deliver a unified customer experience. edge, retailers must stay ahead of market trends, understand
Consumers expect to interact with retailers across multiple consumer preferences, and effectively leverage digital
platforms seamlessly, whether it’s making purchases, marketing strategies to reach a broader audience (Anchanto,
checking product availability, or processing returns (Cook, 2022).
B., 2023).
Besides that, technological advancement is a core
Sustainability is becoming increasingly important as challenge in the consumer electronics industry due to the
public awareness of environmental issues grows. Retailers speed with which new technologies are developed and
are pressured to source eco-friendly products and introduced to the market. This rapid evolution drives
implement greener business practices, which not only help demand for the latest devices but also shortens the lifecycle
in building a positive brand image but also comply with of products. Retailers and manufacturers often face the risk
regulatory standards (Mahmoud et al., 2022; Cohen, S., of unsold inventory becoming obsolete as newer models are
2022; Reddy, K. Pradeep., 2023). launched. Effective inventory management and strategic
planning are essential to mitigate these risks. Retailers must
Competitive pricing strategies are imperative in a balance between offering cutting-edge technology and
saturated market (Hackett, T., 2024). Retailers can attract managing the stock of older models, often through
price-sensitive consumers through dynamic pricing, discounting or special promotions to clear out older
bundled offers, and periodic promotions (PROS, Inc., inventory without incurring significant losses.
2023). Furthermore, with the shift towards online retail,
protecting customer data with robust cybersecurity Today’s consumers are more informed and demanding
measures is paramount to prevent breaches and maintain than ever before. With easy access to information via the
consumer trust (Walia, E., 2024). internet, consumers often research extensively before
making purchases. They expect high-quality products,
Lastly, given the rapid technological advancements in competitive pricing, and excellent customer service.
the industry, ongoing training and development for staff are Additionally, the rise of smart and connected devices has
crucial. Well-informed employees are better equipped to led to expectations for products that are not only functional
manage and sell modern consumer electronics, providing but also seamlessly integrate with the consumer’s existing
informed advice and superior customer service. ecosystem of devices. Retailers need to ensure their staff is
well-trained and that their service channels are equipped to
With all that being said, having a product or sales handle complex queries and provide comprehensive
assistant chatbot can significantly enhance customer support. Enhancing the customer experience in-store and
experience, not keeping potential customers waiting and online is crucial for meeting these expectations and
providing poor or old advice, and serve as an invaluable fostering loyalty.
tool for new staff by guiding them in improving sales
techniques and customer interactions. Acting as a real-time Lastly, price sensitivity is particularly pronounced in
knowledge base, the chatbot provides immediate answers to the consumer electronics market, where similar products
product-related questions, sales protocols, and customer are often available from multiple brands and retailers,
handling strategies, which can reduce the learning curve for leading to price comparisons by consumers. Retailers must
new employees and boost their confidence by providing strategically price their products to attract price-conscious
consistent, accurate information on demand. Additionally, consumers without entering a downward spiral of price
the chatbot can simulate various customer scenarios, wars that erode profit margins. Developing effective
allowing new staff to practice and refine their approach to pricing strategies, such as dynamic pricing, promotional
sales conversations. This aspect ensures they are well- discounts, and bundle offers, can help attract customers

IJISRT24MAY2422 www.ijisrt.com 3261


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

while managing profitability. Additionally, adding value II. LITERATURE REVIEW


through customer service, exclusive products, or unique
shopping experiences can justify premium pricing and help This section is organized into four subsections.
maintain healthy margins. Subsection A explores the involvement of AI assistants in
the retail industry and other sectors, examining their
Overall, the implementation of a product or sales integration and impact on service efficiency and customer
advisor chatbot serves as an invaluable tool for new staff, it interaction.
is a trend nowadays to provide improved and high value
customer interactions. Acting as a real-time and self- Subsection B provides a comprehensive summary and
learning generative model, the chatbot provides immediate analysis of commonly used large language models (LLMs)
answers to product-related questions, sales protocols, and in the current AI generation landscape, detailing their
customer handling strategies, which can reduce the learning functionalities and unique characteristics.
curve for new employees and boost their confidence by
providing consistent, accurate information on demand Subsection C highlights various works that have
through periodical data crawling and knowledge learning utilized LLM models and techniques in generative AI
from multiple online resources. Additionally, the chatbot chatbots for sales and service activities, showcasing
can simulate various customer scenarios, allowing new practical applications and outcomes in different contexts.
staff to learn, practice and refine their approach to sales
conversations and customer interactions. This aspect Lastly, Subsection D offers a summary of the past
ensures they are well-prepared to handle different types of works discussed in Subsection C, synthesizing key findings
customer interactions effectively. Overall, not only does the and insights to provide a cohesive understanding of the
chatbot help with improving customer service and support, advancements and applications of LLMs in generative AI
but it also helps make the outlet stand out from the rest of chatbots.
the competition.
A. AI Assistant in Retail and Other Industries Related
D. Objectives Works
The primary objective of this project is to enhance the Chong et al (2021) examined the integration of AI-
efficiency and knowledge distribution among product chatbots as frontline service agents within the retail and
advisors within the consumer electronics retail industry. consumer services sectors. Utilizing Social Cognitive
Theory (Acxiom Technologies LLP, 2023) to frame their
To achieve this, we plan to develop a specialized analysis, they propose a three-level classification of AI-
chatbot tailored to the needs of electronic retail consumers. chatbot design—anthropomorphic role, appearance, and
This tool will assist product advisors in their daily interactivity—and explore how these elements influence
operations by providing accurate product recommendations the complementarities of agency. Chong et al. recognize the
to customers. The chatbot will also function as a support current implementation challenges and suggest that
system for junior product advisors, empowering them to achieving the full potential of AI-chatbots involves
manage customer inquiries and make informed decisions navigating the complexities of agency at each design level.
independently, without the need for constant oversight from They also develop a research agenda that includes the
senior staff. Furthermore, the chatbot will keep all advisors emotional interface, resolving the proxy agency dilemma,
up to date with the latest product lineups, ensuring that the and fostering collective agency to enhance the deployment
advice and support they offer to customers are current and of AI-chatbots as effective service tools (LaMorte, W.,
relevant. This initiative aims to foster a more efficient, 2022). The study provides a thorough investigation into the
knowledgeable, and responsive service environment, functional benefits and efficiencies AI-chatbots offer, while
significantly enhancing the quality of customer interactions. also addressing quality of service challenges and the need
for better utilization strategies to deliver high-quality
From a technical standpoint, we aim to utilize large consumer services.
language models (LLMs) available on HuggingFace and
integrate them with our chatbot system. We will test Research done by Pantano et al. (2020) and Ostojić, I.,
various LLM models and response generation techniques to (2024) is anchored on a comprehensive analysis of chatbot
identify the optimal combination for our system. patents over the past two decades, demonstrating an
Additionally, we plan to gather and preprocess relevant increasing trend towards the adoption of sophisticated
data to enhance the response generation capabilities of the conversational agents capable of engaging customers
chosen LLM model and technique. By leveraging state-of- through natural language. The findings underscore the
the-art NLP technologies and continuous data updates, we significant research and development efforts aimed at
aim to create a robust and efficient chatbot that enhancing the capabilities of chatbots, particularly in terms
significantly improves the productivity and effectiveness of of drawing inferences from diverse data sources and
product advisors in the consumer electronics retail industry. providing personalized customer interactions (Mehta, J.,
2023). Pantano and Pizzi's work not only highlights the
technological advancements within the AI field but also
maps out the future directions of online customer
assistance, offering valuable insights into the evolving

IJISRT24MAY2422 www.ijisrt.com 3262


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

interface between consumers and digital systems in retail In a paper by Roy (2022), "Artificial Intelligence in
settings. Pharmaceutical Sales & Marketing - A Conceptual
Overview”, the focus is on how AI is revolutionizing
Shankar et al (2018) explored how AI, as a pharmaceutical sales and marketing strategies. Roy delves
combination of programs, algorithms, systems, and into the potential of AI to transform traditional marketing
machines demonstrating intelligence, is revolutionizing approaches through hyper-personalization and hyper-
retailing through enhanced product, service, or solution customization, enabling marketers to target individual
intelligence (Trend Hunter, 2023). His research highlights doctors with unprecedented precision (Ruparelia, 2022).
how AI applications in retailing are expanding due to the The research highlights AI's role in enhancing Customer
exponential growth of business data, exemplified by large Relationship Management (CRM), pre-call planning, and
retailers like Walmart which processes immense volumes guided sales, which significantly improve sales outcomes
of transaction data. These AI systems are pivotal in helping and competitive advantage (Roy, 2022; Hashemi-Pour,
retailers optimize both demand and supply elements, 2023). Roy's analysis not only underscores the
enhancing customer relationship management and transformative capabilities of AI in pharmaceutical
streamlining supply chain efficiencies (Fergus, S., 2024). marketing but also maps out future directions for the field,
Shankar's analysis not only underscores the critical role of including the integration of conversational AI, natural
AI in modern retailing but also provides a strategic language processing, and robot-based process automation.
framework for understanding and deploying AI effectively
in retail operations. Besides that, Trivedi and Patel (2020) investigated the
effects of artificial intelligence and automation on
A study focusing on how AI facilitates automated enhancing sales volume in medium-sized enterprises.
decision-making with precision and speed based on data Anchored on robust statistical methods including M-
analytics, complemented by AI's self-learning capabilities estimation, S-estimation, and MM-estimation (Susanti et
was done (Kaur et al., 2020). The research further al., 2014), their research found that online content, product
highlights the substantial changes brought by digitalization, quality, and marketing resources significantly boost sales
including the impact of eCommerce giants like Alibaba and volume, while competition presents a challenge. Trivedi
Amazon, which have elevated consumer expectations. Kaur and Patel’s analysis highlights the nuanced role of AI and
et al. provide a detailed examination of the revolutionary automation in improving sales strategies, underscoring the
developments in retail technologies such as AI, Big Data, potential of these technologies to transform business
and the Internet of Things (IoT), discussing how these operations and competitive dynamics in the market. Their
technologies enhance customer interactions and operational work mapped out the pivotal influences of AI and
efficiency. Their work offers a comprehensive automation, suggesting strategic implementations for
understanding of AI's expanding role in retail, suggesting businesses aiming to leverage technology for sales
that AI not only improves the customer experience but also enhancement (Dwivedi et al., 2021).
optimizes retail management practices (Stalmachova et al.,
2022; Buehler, T.Leigh., 2024). Oosthuizen et al (2020) contributed by exploring the
transformative role of artificial intelligence (AI) within the
Moore et al (2020) explored the impact of AI digital retail sector (V-Count, 2024). Their research provides a
humans on consumer interactions in retail settings conceptual framework for understanding AI's application
(Coherent Market Insights, 2023). The research is grounded across the traditional retail value chain, highlighted its
in practice-informed, ethnographic methods, focusing on potential to streamline operations, enhance customer
the integration of AI digital humans during the launch engagement, and optimize inventory and supply chain
phase of a flagship store's digital kiosk greeter. Their management (Integration, 2023). Oosthuizen et al (2020)
findings provide insights into the novel social consequences discussed how AI technologies can be integrated at various
and opportunities that arise from consumer interactions stages of the value chain to enhance efficiency and improve
with AI in retail environments, revealing how these customer satisfaction. The paper underscored the
interactions reshape in-store customer experiences and significant impact of AI in redefining retail operations and
influence broader shopping practices. Moore et al. not only suggests practical implications for retail managers to
illuminate the complexities of AI in customer service roles leverage AI technologies to gain a competitive advantage.
but also discuss the managerial implications of integrating The authors’ framework not only illustrates AI's strategic
AI to enhance the shopping environment and customer role in retail but also maps out future directions for research
engagement. Their work contributes significantly to the and implementation in the industry.
understanding of the evolving relationship between digital
technology and customer experience in retail contexts
(Grewal et al., 2023).

IJISRT24MAY2422 www.ijisrt.com 3263


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

B. Current LLM AI Generation Model Landscape

Table 1: AI Assistant Related Workds Summary


Model Primary Function Unique Characteristics
Text generation,
GPT-3 - Capable of generating human-like text across various domains.
conversation, content
(OpenAI) - Adaptable to a wide range of language tasks.
creation
BERT Text analysis, language - Enhances search engines and improves language understanding.
(Google) understanding - Primarily used for analysis rather than generation.
Text-to-text tasks,
- Converts all text-based language problems into a text-to-text format.
translation,
T5 (Google)
summarization, question
- Versatile for various NLP tasks.
answering
Text generation, - Designed to be smaller and more efficient than GPT-3.
Mistral-7B
summarization,
(Mistral AI)
translation - Maintains similar performance levels.
Text generation,
Llama-2 - Offers enhancements in understanding and generating text.
conversational agents,
(Meta AI) - Aims for higher accuracy in diverse contexts.
content creation
Text generation, - Focuses on achieving high performance in language generation tasks.
Falcon 7B
conversational agents,
(TII)
complex task handling - Features enhanced understanding capabilities.

Based on the analysis presented in Table I, we have Kim and Min (2024) integrated a fine-tuned Mistral
summarized the capabilities and usage of commonly model within the QA-RAG framework and demonstrated
employed large language models (LLMs) to understand the significant improvements in accuracy, outperforming
current landscape of generative AI. Our project will conventional models in providing precise regulatory
primarily focus on utilizing Mistral-7B, Llama-2, and guidance (Kim and Min, 2024). In their paper, they studied
Falcon 7B for both experimentation and deployment the innovative adaptation of the QA-RAG model
phases. These models were selected because they are open (LangChain, 2024), leveraging the Mistral model
source and do not incur any tokenization fees. Their open- (Fernandex, 2024) to improve pharmaceutical regulatory
source nature not only reduces costs but also allows for compliance. Their research is grounded in addressing the
greater customization and control over the implementation intricate and voluminous guidelines that often burden
process. industry professionals (Kim and Min, 2024). Kim and
Min's work not only underscores the effectiveness of the
C. LLM Models and Techniques used In Generative AI Mistral model in navigating complex regulatory
Chatbot for Sales and Service Activity Related Works environments but also provides a promising avenue for
Tuan et al (2022) successfully showcased Mistral employing advanced AI in critical compliance domains,
model’s effectiveness in reducing both training time and offering a blueprint for future enhancements in AI-driven
computational expenses while delivering robust regulatory processes.
performance, making it a viable option for SMEs looking to
integrate advanced AI chatbot technologies without Bhattacharyya et al (2024) investigated the
substantial resource allocation (Ngoc, 2024). In their past enhancement of chatbot interfaces in educational
research, they have successfully enhanced the chatbot institutions. Their research is anchored on the
functionalities in smart city applications using generative implementation of Large Language Models (LLM) like
AI, specifically focusing on the Mistral model for small- Mistral-7B and Palm 2, focusing on custom information
and medium-sized enterprises (SMEs). Their research, integration to facilitate non-standard inquiries by users. The
which emphasized the capabilities of the Mistral model study demonstrates that AI-driven chatbots can
(Fernandex, 2024), a variant of the BLOOM language significantly reduce the need for human interaction by
model, showcased how it efficiently automates question- providing instant, accurate responses to institute-related
response interactions across multiple languages. Tuan et al queries, thus alleviating the workload on sales personnel
highlighted that this study not only underscores the and enhancing user satisfaction. The authors highlight the
adaptability and efficiency of the Mistral model but also seamless deployment of these technologies using platforms
illustrated its potential to significantly enhance customer like AWS and frameworks such as Flask, underscoring the
service and urban management within the smart city practical benefits of AI in improving administrative
framework. efficiency and decision-making processes in educational
settings (MoldStud, 2024). Their work not only showcases
the adaptability and efficiency of using advanced LLMs in
chatbot development but also illustrates its potential to
significantly enhance customer service and operational
management in educational contexts (Ali et al., 2024).

IJISRT24MAY2422 www.ijisrt.com 3264


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Dhake (2024) analyzed the transformative impact of Ding et al (2024) investigated the transformative
Generative AI (GenAI) and Large Language Models potential of AI in the educational sector, focusing on how
(LLM) within the banking sector, emphasizing their role in these technologies tailor learning experiences to meet
enhancing customer service and optimizing back-office individual student. The paper reviews a range of AI-
operations. The paper discusses the integration of these powered tools, from automated grading systems to AI-
technologies into banking infrastructures to automate tasks, driven tutoring that can adapt in real time to the learning
enhance security, and personalize customer interactions progress of students (Joadekar, 2024). It explores the
(Božić, 2023). It also addresses challenges such as ethical integration of AI in creating dynamic educational content
considerations, AI transparency, and data sensitivity that not only engages students but also supports diverse
(Elsaid, 2024). Dhake et al.'s (2024) study is significant for learning styles and speeds. Despite the promising
providing insights into responsibly deploying GenAI and applications, the authors critically address the challenges of
LLMs in financial services, highlighting the importance of relying heavily on AI, such as the potential loss of critical
robust regulatory frameworks to ensure fairness and human interaction and the risk of widening educational
privacy. disparities if access to these technologies is uneven
(OnFinance AI, 2024). The study calls for a balanced
Dhoni (2024) provided an in-depth analysis of approach to technology integration, where AI complements
artificial intelligence applications in the retail sector, with a traditional teaching methods, ensuring that educational
particular focus on how machine learning and generative technologies are inclusive and effectively enhance teaching
AI technologies are transforming the landscape of customer and learning processes.
experience and operational efficiency. The authors
comprehensively discuss various AI implementations, such Gao et al (2024) explored the enhancement of large
as the optimization of inventory management through language models (LLMs) for marketing analytics,
predictive algorithms and the personalization of marketing particularly focusing on the open-source LLM, Llama-2-
strategies via data-driven insights (Hypersonix & Becchetti, 70b. They investigate how techniques such as semantic
2024). Furthermore, the paper delves into the challenges search and fine-tuning can be applied to improve Llama-2-
associated with these technologies, including concerns over 70b's capabilities in complex tasks like SQL generation and
data privacy, the financial implications of AI deployment, tabular data analysis, crucial for precise marketing
and the requisite expertise needed to manage these decision-making. By embedding documents as numerical
sophisticated tools (Elsaid, 2024). A significant part of the vectors and aligning queries with relevant information,
study emphasizes the need for ethical considerations in AI semantic search significantly enhances Llama-2-70b's
deployment, highlighting the potential risks and mitigation contextual understanding. Further fine-tuning on domain-
strategies to prevent data misuse and ensure consumer specific datasets allows the model to excel in specialized
protection. Dhoni et al.'s work serves as a pivotal resource tasks traditionally challenging for LLMs (Pandey, 2023;
for retailers considering AI integration, offering a nuanced Rizvi, 2023). Gao et al.'s comparative analysis
view of the opportunities for enhancing service delivery demonstrates Llama-2-70b's competitive or even superior
alongside the operational hurdles that must be navigated. performance against proprietary models, highlighting its
potential to transform marketing analytics through
advanced, open-source AI technology.

D. Analysis of LLM Models and Techniques used in Generative AI Chatbot for Sales and Service Activity Related Works

Table 2: Generative AI Related Works Summary


Author Problems Techniques Used Contributions
- Reduced training time and costs with the
Utilization of the Mistral Mistral model.
Investigating AI's role in
model, a variant of the
retail from a managerial
Tuan et al. BLOOM language model, to - Enhanced chatbot functions in smart city
perspective, focusing on
(2022) automate question-response environments.
ethical and operational
interactions in multiple
aspects.
languages. - Showcased adaptability and benefits for
customer service and urban management.
- Highlighted Mistral model's superior
accuracy in providing precise regulatory
Challenges in navigating Integration of the fine-tuned guidance.
complex regulatory Mistral model within the QA-
Kim and Min
environments in the RAG framework to enhance - Emphasized its strategic role in AI
(2024)
pharmaceutical industry pharmaceutical regulatory compliance.
using conventional models. compliance.
- Suggested prospects for future advancements
in AI.

IJISRT24MAY2422 www.ijisrt.com 3265


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

- Demonstrated AI-driven chatbots' role in


reducing workload and enhancing user
Implementation of Large satisfaction.
Need to reduce human
Language Models (LLM) like
interaction in educational
Bhattacharyya Mistral 7B and Palm 2, - Highlighted efficient deployment using AWS
institutions and improve
et al. (2024) integration of custom and Flask.
response times for institute-
information to handle non-
related queries.
standard inquiries. - Showcased improvements in administrative
efficiency and decision-making in educational
settings.
Integration of Generative AI
Utilization of Generative AI
and Large Language Models - Analyzed the impact of generative AI and
for automation, Large
in the banking sector, large language models in banking.
Language Models for
Dhake, S. focusing on regulatory,
enhancing customer service,
(2024) ethical, and data security - Outlined strategies for ethical integration.
and the development of ethical
issues, along with the need
frameworks to guide AI
to balance automation with - Addressed regulatory compliance issues.
deployment.
personalized interactions.

Challenges in optimizing
retail operations and - Provided a comprehensive overview of AI
Machine learning algorithms
enhancing customer applications in retail.
for inventory management,
Dhoni, P. S. experiences with AI,
generative AI for marketing
(2024) focusing on data privacy, - Evaluated operational and ethical challenges.
personalization, ethical
cost, and the technical
frameworks for data protection.
expertise required for AI - Recommended strategies for AI deployment.
implementation.
Enhancing educational
- Offered insights on effective AI integration in
Ding, M., experiences through AI-driven adaptive learning
education.
Dong, S., & personalized learning and systems, automated grading
Grewal, R. the challenges of integrating tools, real-time feedback
- Discussed balancing AI tools with human
(2024) AI without diminishing the mechanisms.
teaching methods.
role of human educators.
Challenges in using standard
LLMs for SQL generation - Conducted a detailed evaluation of Llama-2-
Gao, Y., and tabular data analysis in Llama-2-70b and other Large 70b and other LLMs in marketing analytics.
Arava, S. K., marketing analytics, Language Models, semantic
Li, Y., & Jr, J. highlighting the need for search techniques, fine-tuning - Presented methodological advancements to
Ws. (2024) enhanced precision and on domain-specific datasets. enhance LLM functionality in complex
applicability for specialized analytical tasks.
tasks.

Table II provides a consolidated overview of recent III. METHODOLOGY


research on the deployment and effectiveness of large
language models and generative AI in various professional In this paper, we detail our research process for
domains. It highlights key findings from multiple studies utilizing Falcon7B and Llama2 models. Section A outlines
that explore the transformative potential of these the research flow, including data preparation, model
technologies in enhancing operational efficiencies, training and evaluation, and chatbot interactions. Sections
decision-making processes, and user satisfaction across B and C focus on the operational aspects and setup
sectors such as smart city management, banking, education, requirements of Falcon-7B and Llama2. Finally, Section D
and retail. offers a concise summary and evaluation of the chapter,
tying together all the key aspects of our research
methodology.

IJISRT24MAY2422 www.ijisrt.com 3266


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

A. Flow of Research Activities

Fig 1: Flow of Research Activites in the Project

In Fig. 1, the research activities for developing an AI Once the system is established, we proceed to the
chatbot are divided into six distinct phases, each crucial to System Evaluation phase. During this phase, we rigorously
the project's success. test the chatbot to assess its performance, accuracy, and
practicality. This evaluation helps us determine whether the
In the initial phase, Business and Problem system meets the desired standards and is ready for
Understanding, we conduct a thorough analysis of the deployment. It also allows us to identify and address any
challenges and needs within the Consumer Electronics potential issues before the system goes live.
Retail Industry. This phase is essential as it helps us align
our project objectives with the industry's demands. By The final phase, deployment, involves deploying the
understanding the specific problems faced by this sector, chatbot through user-friendly platforms such as Streamlit.
we can ensure our AI chatbot will provide meaningful and This step enables us to present and demonstrate the system
relevant solutions. to users, gather feedback, and make any necessary
adjustments to improve functionality and user experience.
The second phase, Model and Technique By following these structured phases, we ensure a
Experimentations, involves exploring various open-source comprehensive and methodical approach to developing an
Large Language Models (LLMs) and inference techniques. AI chatbot tailored to the needs of the Consumer
During this phase, we evaluate models such as Llama2, Electronics Retail Industry.
Falcon-7B, and Mistral-7B. Additionally, we assess
inference techniques like Retrieval Augmented Generation B. Flow of Falcon-7B
(RAG), Fine-Tuning using QLoRA, and LLM Chaining.
This experimentation is critical for identifying the most
effective models and techniques for our specific
application.

Following our experimentation, we move on to the


Model Selection and Data Preparation phase. Based on the
results of our evaluations, we select the final model and
techniques. Subsequently, we prepare the necessary data,
ensuring it is clean, relevant, and properly formatted to
support the chosen model. This phase is foundational, as it
lays the groundwork for the subsequent development
stages.

In the System and Model Development phase, we


create a robust pipeline to integrate the selected LLM with
any additional features required by the system. This
involves setting up processes for data input, model
inference, and output generation, ensuring seamless
operation. Proper pipeline development is crucial for
maintaining the system's efficiency and reliability.
Fig 2: Flowchart on the Preparation of Falcon-7B

IJISRT24MAY2422 www.ijisrt.com 3267


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

To fine-tune a conversational model using data from C. Flow of Llama2 + Langchain


Hugging Face with a base model like Sharded Falcon 7B, a
detailed and methodical approach is essential. Referring to
Fig. 2, the process begins with the acquisition of suitable
conversational data. For this purpose, the 'Dialogue Sum'
dataset available on Hugging Face is an excellent choice. It
is specifically tailored for dialogue systems and offers a
rich source of conversational exchanges.

Once the data is obtained, the crucial step of


preprocessing comes into play. This stage involves cleaning
and formatting the data to make it suitable for training the
model. This process includes removing irrelevant or
redundant information, fixing any errors in the format, and
possibly breaking down longer dialogues into smaller, more
manageable parts. The objective here is to ensure that the
dataset is consistent, relevant, and structured in a way that
the model can easily process and learn from.

With the dataset prepared, the focus shifts to the base


model, in this case, the Sharded Falcon 7B. This model is
known for its large scale, efficiency, and ability to handle
extensive datasets. Loading the Shared Falcon 7B involves
setting up the necessary computational resources and
initializing the model with its pre-trained parameters. This
step is critical as it lays the foundation for the fine-tuning
process. Fig 3: Flowchart on the Preparation of Llama2 + Langchain

The actual fine-tuning of the model is conducted with From Fig. 3 above, the first step in this process
the prepared dataset, which, in this scenario, includes about involves importing all the necessary libraries. This typically
5,000 rows of conversational data. This stage is where the includes libraries for handling PDF files, such as PyPDF2
model learns from the specific nuances and contexts of the or pdfplumber, which are used for reading and extracting
dataset, adapting its pre-trained knowledge to the text from PDF documents. Additionally, libraries for data
specificities of the conversational style and content in the processing and machine learning tasks, such as numpy for
'Dialogue Sum' data. This process is both resource- numerical operations, pandas for data manipulation, and
intensive and time-consuming, often taking around 8 hours torch for deep learning, might also be required. Importing
to complete. these libraries at the beginning ensures that all the
necessary functions and methods are readily available for
After fine-tuning, it's essential to evaluate the model's use in subsequent steps.
performance. This is achieved through a process called
inference, where new, unseen data is fed into the model to Once the libraries are imported, the next task is to load
assess how well it responds. The quality and relevance of the PDF data. This involves reading the PDF file and
the model's responses are key indicators of its learning and extracting the text contained within it. PDF files can be
adaptation capabilities. This evaluation helps in complex, with text distributed across multiple pages,
understanding how effectively the model can handle real- sometimes in non-linear formats. Therefore, careful
world conversational scenarios based on the training it handling is required to ensure that the text is extracted
received. accurately and comprehensively. The extracted text is then
typically split into manageable chunks. This is crucial for
Throughout this entire process, from data acquisition processing, as very long texts can be challenging to work
to model evaluation, it is vital to continuously monitor the with directly. Splitting the text into smaller parts makes it
model's performance and make necessary adjustments. This more manageable and allows for more efficient processing
iterative approach ensures that the model is fine-tuned to in later stages.
the highest efficiency, making it capable of handling
complex conversational tasks in a wide range of The following stage involves creating embeddings for
applications. each text chunk. This is where Pinecone, an embedding
database service, comes into play. Pinecone is initialized
and then used to convert the text chunks into embeddings.
These embeddings are numerical representations of the text
data, capturing the semantic meaning of the text in a format
that can be easily processed by machine learning models.
The creation of embeddings is a vital step, as it transforms

IJISRT24MAY2422 www.ijisrt.com 3268


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

the raw text into a form that is suitable for inference and application runs consistently across different computing
analysis. environments by encapsulating it along with its
dependencies. Containerization with Docker simplifies
The final step is to load the Llama2 model with deployment, scales seamlessly across different machines,
LangChain for performing inferences. LangChain is a and isolates the application, making it more secure.
toolkit that facilitates language model operations, making it
easier to work with models like Llama2. The Llama2 IV. DATA AND PRELIMIINARY WORKS
model, once loaded, is then used to perform inferences on
the text embeddings. This might involve tasks like text In this section, we delve into data preparation,
classification, sentiment analysis, or other forms of natural preprocessing, and experimentation methodologies in
language processing, depending on the specific conversational AI. Section A covers data preparation,
requirements of your project. detailing our data sources for the experiments, including
data size, type, and the preprocessing techniques employed.
D. Hardware and Software Used
This section outlines the software and tools integral to Section B examines the general architecture of
this project, which facilitate our experimentation and the conversational generative models. It provides an in-depth
development of the chatbot system. Through these analysis of the Falcon7B model and explores the
resources, we are equipped to advance our project architectures of Llama2 and Langchain.
objectives efficiently.
Section C documents the experimental processes,
 NVIDIA RTX 3090 GPU focusing on the experimentation with Falcon7B and the
This hardware component is critical for training and combined application of Llama2 and Langchain.
running large language models like the ones used in LLM
chatbots due to their ability to process large datasets and A. Data Preparation
perform complex computations rapidly. GPUs significantly
accelerate the training and inference phases of machine  Data Source
learning models. The dataset "knkarthick/dialogsum" from Hugging
Face is integral to the training of conversational and
 Jupyter Notebook generative AI. This repository encompasses a spectrum of
It is an interactive computing environment where we dialogues drawn from everyday scenarios, reflecting the
can write, test, and debug the chatbot’s code live. It is multifaceted nature of human interactions. The dialogues
particularly useful for experimenting with and fine-tuning span various sectors including education, healthcare, and
the LLM models within the notebook. commerce, and feature a range of social interactions, from
casual conversations to formal service encounters. This
 Hugging Face extensive and varied dataset is critical for the development
Hugging Face is a platform that offers downloading, of AI systems capable of replicating human conversational
configuring, and deploying state-of-the-art pre-trained patterns across a breadth of topics and situational contexts,
models, including LLMs. We have used it to access models which is essential for their application in diverse real-world
like Falcon-7B, Llama2 and Mistral 7B, enabling us to environments. The richness of the dataset provides a robust
access these open-source models easily. platform for AI to learn nuanced communication, thereby
enhancing their ability to engage in and sustain
 Docker contextually relevant and socially aware dialogues.
Docker is used to containerize the environment where
the LLM chatbot operates. This ensures that the chatbot

 Data Size

Fig 4: Details of “knkarthick/dialogsum” dataset

IJISRT24MAY2422 www.ijisrt.com 3269


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

The "knkarthick/dialogsum" dataset is composed of a By referring to Fig. 5, the model that is trained using
total of 14,460 dialogue entries, each accompanied by QLoRa prioritizes quantization, which is the process of
expertly crafted summaries and assigned topics as shown in constraining an input from a large set to output in a smaller
Fig. 4. The dataset is structured into three subsets: 12,460 set. In neural networks, quantization typically pertains to
entries for training purposes, 500 entries designated for reducing the precision of the numbers used to represent the
validation, and 1,500 entries reserved for testing. This model's parameters, which can drastically reduce the
organization supports the systematic training, validation, model's memory footprint and speed up computation.
and assessment of AI models in natural language
processing tasks. In this hierarchical setup, the topmost layer comprises
multiple 32-bit optimized state units, which represent a
 Data Type high-resolution state of the system's parameters or data
The "knkarthick/dialogsum” dataset consists of four handling units. These units could be responsible for initial
columns: id, dialogue, summary, and topic. A detailed data processing or retention of high-precision computations
explanation of each column is listed in Table III below. that are necessary before quantization. The connection to
CPU means that it is responsible for managing memory
Table 3: Data Description efficiently, an important aspect for high-performance
Column Description computing and real-time analytics.
Id Unique Identifier
Dialogue Conversation between two persons The middle tier consists of 16-bit adapters, which act
Summary A summary of conversation between as intermediaries. These adapters are used to downscale the
two persons data from a higher to a lower precision, making it more
Topic The topic of the conversation manageable for the model at the base of the architecture.
The use of adapters is a modular approach, where data or
 Data Preprocessing computational precision can be adjusted as needed,
For Falcon7B, we will have to preprocess the data to potentially allowing for dynamic scaling based on the
fine-tune it further with our desired dataset. However, for demands of the task or the limitations of the hardware.
Llama2, no fine-tuning is being performed hence we will
not need to preprocess any data for Llama2. We will refer The base of the architecture is a 4-bit model, which is
to Appendix A for an in-depth discussion of the code used considered extreme quantization. Models with such low bit-
to prepare the data. widths are highly unusual but might be employed in
extremely resource-constrained environments or for very
B. Architecture of Generative Models rapid processing where precision is less critical. This shows
that Falcon7B is highly optimized for speed and resource
 Falcon-7B efficiency, possibly at the expense of some accuracy or
resolution in its computations.

The flow from 32-bit to 4-bit is a gradual reduction


and refinement process, where data or computations are
streamlined and optimized at each level to achieve a
balance between performance and resource usage. This
could be particularly beneficial in applications like mobile
devices, embedded systems, or IoT devices, where
computational resources are limited, but a fast response
time is essential.

Fig 5: Architecture of Falcon-7B

IJISRT24MAY2422 www.ijisrt.com 3270


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

 Llama2 + Langchain

Fig 6: Architectural Flowchat of Llama2 + Langchain

Based on Fig. 6, the system begins with the input of algorithms to create a powerful tool for natural language
textual data, typically in the form of PDFs or digital text processing and generation. Falcon 7B, a part of the broader
documents. This data is meticulously segmented into Falcon series of language models, is known for its
smaller, manageable chunks by a dedicated Text Splitter. exceptional capabilities in understanding, interpreting, and
The segmentation is crucial to facilitate detailed analysis generating human-like text. It stands out due to its large-
and to ensure that the subsequent processes can handle the scale architecture, which allows it to process and analyze
data efficiently. vast amounts of data with remarkable accuracy and depth.

Each text chunk is then transformed into a vector Falcon 7B's design is geared towards handling a wide
representation through an Embedding Generator. This step array of language-related tasks. These include but are not
involves using sophisticated AI algorithms to translate text limited to generating coherent and contextually relevant
into numerical forms that capture the essence of the words text, answering complex queries, and providing insightful
and their contextual meanings. The generated embeddings analyses. Its ability to understand and generate natural
are indexed and stored in a specialized Vector Database, language makes it an invaluable asset in various
such as Pinecone, designed for high-performance similarity applications, such as automated content creation,
searches. conversational AI systems, and sophisticated data
interpretation tasks.
When a query is received, it is not processed in
isolation. Instead, it is enriched with context from the One of the key strengths of Falcon 7B is its versatility
Vector Database, ensuring that the system's understanding and adaptability. It can be fine-tuned for specific
is as nuanced and detailed as possible. The Llama2 model, applications, enabling it to deliver highly tailored responses
known for its advanced natural language processing and analyses. This customization makes it particularly
capabilities, leverages this rich context to analyze and useful in sectors where nuanced understanding and
interpret the query within the appropriate frame of specialized knowledge are crucial, such as in healthcare,
reference. finance, and legal industries.

The final step is where the Llama2 model synthesizes Moreover, Falcon 7B's advanced capabilities in
the insights gleaned from the query and its context to generative AI are complemented by its user-friendly
generate a precise and relevant answer. This model, being interface and integration potential. It can be seamlessly
at the cutting edge of AI technology, is adept at crafting incorporated into existing systems and workflows, making
responses that are not only accurate but also coherently it accessible not only to AI researchers and data scientists
structured, reflecting a deep understanding of the subject but also to businesses and organizations looking to leverage
matter at hand. the power of AI for enhancing their operations.

C. Experiments Carried Out In summary, the Falcon 7B model is a robust,


scalable, and versatile tool in the field of generative AI. Its
 Falcon-7B sophisticated architecture and advanced language
The Falcon 7B model represents a significant processing capabilities make it a cutting-edge solution for a
milestone in the advancement of generative AI, bringing range of applications, driving innovation and efficiency
together state-of-the-art technology and sophisticated across various industries. The Falcon 7B model stands as a

IJISRT24MAY2422 www.ijisrt.com 3271


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

testament to the rapid progress in AI technology, heralding From creating compelling and coherent narratives to
a new era of intelligent systems capable of understanding answering complex queries with nuanced understanding,
and interacting with human language in unprecedented this duo is well-equipped to tackle diverse challenges in the
ways. AI space. Their application extends across various domains,
including but not limited to, content creation,
In Appendix B of this paper, we discuss about how conversational AI, information extraction, and automated
data is being setup and preprocessed for fine-tuning. This is text summarization.
followed by Appendix C where we will demonstrate the
code used to inference the fine-tuned model together with The use of Llama2 with LangChain in generative AI
experimentation with RAG technique on pdf document. not only enhances the quality of the generated content but
also ensures a smoother and more efficient workflow for
 Llama2 + Langchain developers and AI practitioners. This integration marks a
Llama2 with LangChain represents a cutting-edge significant step forward in the journey towards more
advancement in the field of generative AI, combining the advanced, user-friendly, and capable AI systems, paving
power of a sophisticated language model with the the way for innovative applications that were once thought
efficiency and flexibility of a specialized toolkit. LLaMA2, to be beyond the reach of automated systems. We will refer
standing as a part of the Llama (Large Language Model - to Appendix D and E to explore the process of setting up
Atlas) family, is a highly advanced language model known Llama2 with Langchain together with performing RAG on
for its exceptional language understanding and generation the pdf document to observe the response.
capabilities. This model is designed to handle a wide range
of natural language processing tasks, making it an Overall, in comparison to Falcon7B, Llama2 will give
invaluable tool for generating human-like text, a better response as it is suitable for pdf querying tasks,
understanding context, and providing relevant, accurate however, if we wish to have a more human-like response
responses to a variety of prompts. like ChatGPT, Falcon7B holds the potential to achieve this
goal as long as we have sufficient and relevant data for the
LangChain, on the other hand, serves as a subject requirements.
complementary toolkit specifically designed to enhance the
performance and usability of large language models like V. TECHNIQUES CONSIDERATION &
LLaMA2. It simplifies the process of integrating these OVERALL MODEL DEVELOPMENT
models into applications, providing a streamlined and user-
friendly interface. LangChain allows for efficient handling A. Techniques Consideration
of model operations, including loading models, After experimenting with fine-tuning and RAG
preprocessing text data, and managing model inferences. techniques for the generation of the model responses, we
This integration significantly reduces the complexity and have concluded that using RAG is more efficient in contrast
technical overhead typically associated with deploying to fine-tuning due to our limited resources. Instead of fine-
large-scale language models, making it more accessible for tuning periodically, we will find quality data and update the
a broader range of users and applications. dataset used for RAG. This will not only save time but also
improve the model’s response generation overall.
The combination of Llama2 and LangChain in the
realm of generative AI opens a plethora of possibilities.

Fig 7: Model Performance Benchmark Table from mistral.ai

IJISRT24MAY2422 www.ijisrt.com 3272


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

We have chosen to use a pretrained Mistral-7B model To efficiently scrape the reviews without causing
as our final model for the chatbot system as it has the best undue strain on GSMArena’s servers, we implemented a
performance overall when compared to models like methodical scraping process. We incorporated the sleep()
Llama2, although it performs similar with Falcon7B, the function in our scraping script, introducing deliberate
data that has been trained on Mistral is more up to date. pauses between consecutive requests. This approach
Hence the selection on why we chose Mistral-7B. The minimized the risk of overwhelming the server with high-
comparison of results between the models can be shown in frequency requests, which can lead to IP bans or other
Fig. 7 above. restrictive measures against our scraping activities. The
code to the scraping implementation can be referred at
In the development of the Retrieval-Augmented Appendix F.
Generation (RAG) component of our LLM-based chatbot,
we specifically tailored the dataset to enhance the model's The scraping operation was conducted over a span of
ability to provide relevant and informed responses related approximately two hours, during which we systematically
to mobile phone reviews. Here is a detailed breakdown of collected reviews for all smartphones offered by a local
the data collection and preparation process: consumer electronic product chain store listed on their site.

 Data Collection Strategy  Data Storage and Preprocessing


Initially, we compiled a comprehensive list of Once collected, the review data was formatted and
smartphone offerings from a local consumer electronic stored in JSON Lines format (JSONL). This format was
product chain store. This list served as the foundation for chosen due to its efficacy in handling large datasets where
our targeted data scraping, ensuring that the reviews each new record is stored as a separate line. JSONL is
gathered were relevant to the current products in the particularly advantageous for NLP tasks as it facilitates
market. easy access to each data point without the need to load the
entire dataset into memory.
Subsequently, we turned to GSMArena to scrape
expert reviews for each smartphone listed. It was crucial to The stored JSONL files then underwent preprocessing
adhere to ethical scraping practices; hence, we strictly to structure the review data effectively for the RAG model.
complied with the directives outlined in GSMArena's This preprocessing involved cleaning the text data, such as
robots.txt file. This compliance ensured that our data removing unnecessary formatting, correcting typos, and
collection methods were respectful of the website’s terms standardizing expressions. This step was critical to ensure
of service and did not disrupt its normal operation. that the input data was clean, well-structured, and
conducive for training the model efficiently.
 Data Scraping Implementation

Fig 8: Example of Review Data

IJISRT24MAY2422 www.ijisrt.com 3273


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Here is an example of the data in a jsonl format shown This structured data format enhances the RAG
in Fig. 8. model's retrieval efficiency by allowing the retrieval
component to function effectively, matching queries against
The dataset for the RAG (Retrieval-Augmented product_name for relevance and using the corresponding
Generation) model is meticulously organized into three product_info as context for generating responses.
columns: id, product_name, and product_info. Each Additionally, the clear separation of product name and
element of this structure plays a critical role in optimizing information ensures that the generation process is informed
the model's functionality and performance. by comprehensive and specific data, leading to more
accurate and contextually appropriate outputs. Furthermore,
The id column assigns a unique identifier to each the organization of these columns supports scalability as
entry, ensuring that each product review can be distinctly the dataset grows, allowing new products to be added easily
referenced and accessed. In the context of RAG, where without disrupting the existing structure. This structured
retrieved content needs to be linked back to a source or approach not only streamlines the operation of the chatbot
used in a sequential process, having a unique id for each but also significantly boosts its performance in delivering
data point simplifies tracking and managing data user-relevant content.
throughout the retrieval and generation phases.
By adhering to these methodical and ethical data
The product_name column, which contains the name collection and preparation practices, we ensured that the
of the smartphone, acts as a crucial descriptor that aids the RAG model could leverage high-quality, relevant data to
RAG model in matching queries with the relevant product enhance its performance. This foundation allows the
reviews. By explicitly incorporating the product name, the chatbot to generate accurate and contextually appropriate
model can efficiently filter and retrieve information directly responses based on up-to-date mobile phone reviews,
related to specific user queries about products. This feature significantly improving the user experience and reliability
is pivotal in enhancing the user experience, as it ensures of the chatbot in real-world applications.
that the responses generated by the chatbot are pertinent
and tailored to inquiries about specific models. Refer to Appendix G on the code to setup Mistral 7B
Model. For a Retrieval-Augmented Generation (RAG)
Lastly, the product_info column provides a concise model to function effectively, it is essential to format and
description or review of the product. This column is the structure the input data meticulously. In Appendix F, we
primary source of content used by the RAG model during discuss about the process of preparing the data to perform
the generation phase. It typically includes key features, RAG.
performance metrics, and expert evaluations, providing
rich, detailed context that the RAG model can draw upon to
generate informative and accurate responses.

B. Overall Model System Development

Fig 9: Overall System View

Moving onto our frontliner chatbot assistant system, we have deployed it through Streamlit while implementing several
features to enhance user experience and model performance. The outlook of the system is shown in Fig. 9.

IJISRT24MAY2422 www.ijisrt.com 3274


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 10: Update Dataset Button

By clicking on this button, the scraping script will then run in the background to update the dataset. This lets user to
conveniently stay up to date with the chatbot according to Senheng’s offerings on their website. The update data button is shown
in Fig. 10.

Fig 11: Feedback Function

Fig 12: Feedback Dataset

Besides that, we have included the feedback feature Moving onto the chat function of the system, it can
for fine tuning purposes to improve the model’s relevancy output dual language which are English and Bahasa Melayu
and response generation in the future. User will be able to to improve accessibility among users. Besides that, LLM
select “good” or “bad”, submitting with the option “good” Chaining is being implemented to refine the answers of the
will then record the conversation and save it as pairs into chatbot. In Appendix I, we discuss how LLM Chaining is
the dataset. However, if “bad” is selected, a feedback box being performed and used and the text is being translated in
will appear to record the new preferred response by the the program.
user, and it will be saved subsequently into the json format
dataset. Fig. 11 shows the feedback function and Fig. 12
shows an example of how the feedback dataset looks like.

IJISRT24MAY2422 www.ijisrt.com 3275


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 13: Chat log history

An example of a chat log from the chatbot was chatbot's relevance and effectiveness in a rapidly evolving
demonstrated in Fig. 13. industry.

VI. DISCUSSION VII. CONCLUSION AND FUTURE WORKS

The primary objective of this project was to enhance While the current implementation of the chatbot has
the overall productivity of product advisors in the consumer met our initial objectives, there is always room for further
electronics retail industry. Through the successful enhancement. Future iterations could include more
implementation of a chatbot utilizing Mistral-7B and sophisticated natural language processing (NLP) techniques
Retrieval-Augmented Generation (RAG), we are one step to improve the chatbot's conversational abilities and context
closer toward this goal. The chatbot is designed to interact understanding. Additionally, integrating more advanced
with users and provide relevant, accurate responses to their machine learning algorithms could enable the chatbot to
queries, thereby increasing the efficiency and effectiveness offer predictive insights and personalized
of product advisors. recommendations, further boosting its utility for both
advisors and customers. Besides that, experts in this
The integration of the Mistral-7B model with RAG industry should be involved to vet the response generated
has proven to be highly effective. The chatbot's ability to by the chatbot to improve its accuracy and reliability.
understand and respond to a wide range of inquiries allows
product advisors to handle more customer interactions in In conclusion, the development and deployment of the
less time. This not only boosts their productivity but also chatbot using Mistral-7B and RAG have successfully
enhances the customer experience by providing timely and addressed our primary objective of improving the
accurate information. The chatbot serves as an invaluable productivity and efficiency of product advisors in the
tool for junior product advisors, offering them guidance and consumer electronics retail industry. The chatbot's ability to
support as they navigate customer inquiries. Its interactive provide accurate, timely responses and its capacity for
capabilities ensure that even less experienced advisors can continuous learning will be invaluable to businesses in this
perform their duties with confidence, reducing their ever-changing market. This project underscores the
reliance on senior staff. potential of AI-driven solutions like GenAI to transform
traditional retail operations and enhance the capabilities of
To ensure the chatbot remains up-to-date with the product advisors.
latest trends and products in the technology sector, we have
incorporated an automatic update function. This feature
enables the chatbot to crawl and retrieve relevant data from
various sources, continually expanding its knowledge base.
As a result, the chatbot can provide current and accurate
information, keeping both the advisors and customers
informed about new products and developments. This
dynamic updating mechanism is crucial for maintaining the

IJISRT24MAY2422 www.ijisrt.com 3276


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

REFERENCES [12]. Shankar, V. (2018). How Artificial Intelligence (AI)


is Reshaping Retailing. Journal of Retailing, 94(4),
[1]. Reinartz, W., Wiegand, N., & Imschloss, M. (2019). vi–xi. https://doi.org/10.1016/s0022-
The Impact of Digital Transformation on the 4359(18)30076-9
Retailing Value Chain. International Journal of [13]. Bhattacharyya, R., Chandra, S., Manikonda, K.,
Research in Marketing, 36(3), 350–366. Science Depuru, B., & Kumar, B. (2024). An AI-Driven
Direct. Interactive Chatbot: A Well-Trained Chatbot that
https://doi.org/10.1016/j.ijresmar.2018.12.002 Communicates with the Users and Reduces the
[2]. AIContentfy (2023) The role of customer education Manual Interaction. International Journal of
in customer acquisition and retention. (2023, Innovative Science and Research Technology, 9(2)
February 11). AIContentfy. [14]. Guha, A., Grewal, D., Kopalle, P. K., Haenlein, M.,
https://aicontentfy.com/en/blog/role-of-customer- Schneider, M. J., Jung, H., Moustafa, R., Hegde, D.
education-in-customer-acquisition-and-retention R., & Hawkins, G. (2021). How artificial
[3]. Kim, J.-H., Kim, M., Park, M., & Yoo, J. (2022). intelligence will affect the future of
Immersive Interactive Technologies and Virtual retailing. Journal of Retailing, 97(1), 28–41.
Shopping Experiences: Differences in Consumer https://doi.org/10.1016/j.jretai.2021.01.005
Perceptions between Augmented Reality (AR) and [15]. Kaur, V., Khullar, V., & Verma, N. (2020). Review
Virtual Reality (VR). Telematics and of Artificial Intelligence with retailing
Informatics, 77, 101936. sector. Journal of Computer Science Research, 2(1).
https://doi.org/10.1016/j.tele.2022.101936 https://doi.org/10.30564/jcsr.v2i1.1591
[4]. Hopkins, M. (2023, February 21). Building a [16]. Kim, J., & Min, M. (2024). From RAG to QA-RAG:
competitive advantage in retail with technology. Integrating Generative AI for Pharmaceutical
Planning and Analytics Blog – Board International. Regulatory Compliance Process.
https://blog.board.com/building-competitive- [17]. Moore, S., Bulmer, S., & Elms, J. (2022). The social
advantage-retail-technology-is-key/ significance of AI in retail on customer experience
[5]. Varnika Om (2022) Customer Service is a Key and shopping practices. Journal of Retailing and
Differentiator in Retail. (2022, May 27). Freshdesk Consumer Services, 64(1), 102755.
Blogs. https://doi.org/10.1016/j.jretconser.2021.102755
https://www.freshworks.com/freshdesk/customer- [18]. Seranmadevi, R., & Senthil Kumar, A. (2019).
support/customer-service-in-retail-a-differentiator- Experiencing the AI emergence in Indian retail –
blog/ Early adopters approach. Management Science
[6]. Netstock. (2023, June 13). Demand Forecasting for Letters, 33–42.
Supply Chains: How to Predict & Plan. Netstock. https://doi.org/10.5267/j.msl.2018.11.002
https://www.netstock.com/blog/demand-forecasting- [19]. Trivedi, S., & Patel, N. (2020). The Role of
for-supply-chains-how-to-predict-plan/ Automation and Artificial Intelligence in Increasing
[7]. Mahmoud, M. A., Tsetse, E. K. K., Tulasi, E. E., & the Sales Volume: Evidence from M, S, and, MM
Muddey, D. K. (2022). Green Packaging, Regressions. SSRN Electronic Journal.
Environmental Awareness, Willingness to Pay and
https://doi.org/10.2139/ssrn.4180379
Consumers’ Purchase Decisions. Sustainability,
[20]. Tuan, N. T., Moore, P., Thanh, D. H. V., & Pham,
14(23), 16091. https://doi.org/10.3390/su142316091 H. V. (2024). A Generative Artificial Intelligence
[8]. PROS, Inc. (2023, March 29). Competitive Pricing Using Multilingual Large Language Models for
Strategy: Benefits and Disadvantages. Pros.com. ChatGPT Applications. Applied Sciences, 14(7),
https://pros.com/learn/b2b-blog/competitive-pricing-
3036. https://doi.org/10.3390/app14073036
strategy
[21]. Dhake, S. (2024). Impacts and Implications of
[9]. Anchanto. (2022, May 1). 6 Struggles E-commerce
Generative AI and Large Language Models:
Businesses in Consumer Electronics Know Too
Redefining Banking Sector. Impacts and
Well + (Proven Solutions). Anchanto.
Implications of Generative AI and Large Language
https://anchanto.com/6-struggles-ecommerce-
businesses-in-consumer-electronics-know-too-well- Models: Redefining Banking Sector, 14(2).
proven-solutions/ [22]. Dhoni, P. S. (2024). From Data to Decisions:
[10]. Chong, T., Yu, T., Keeling, D. I., & de Ruyter, K. Enhancing Retail with AI and Machine
(2021). AI-chatbots on the services frontline Learning. International Journal of Computing and
addressing the challenges and opportunities of Engineering, 5(1), 38–51.
agency. Journal of Retailing and Consumer https://doi.org/10.47941/ijce.1660
Services, 63, 102735. [23]. Ding, M., Dong, S., & Grewal, R. (2024).
https://doi.org/10.1016/j.jretconser.2021.102735 Generative AI and Usage in Marketing
[11]. Pantano, E., & Pizzi, G. (2020). Forecasting Classroom. Customer Needs and Solutions, 11(1).
artificial intelligence on online customer assistance: https://doi.org/10.1007/s40547-024-00145-2
Evidence from chatbot patents analysis. Journal of
Retailing and Consumer Services, 55, 102096.
https://doi.org/10.1016/j.jretconser.2020.102096

IJISRT24MAY2422 www.ijisrt.com 3277


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

[24]. Gao, Y., Arava, S. K., Li, Y., & Jr, J. Ws. (2024). [35]. Stalmachova, K., Chinoracky, R., & Strenitzerova,
Improving the Capabilities of Large Language M. (2022). Changes in Business Models Caused by
Model based Marketing Analytics Copilots with Digital Transformation and the COVID-19
Semantic Search and Fine-Tuning. International Pandemic and Possibilities of Their Measurement—
Journal on Cybernetics & Informatics, 13(2), 15– Case Study. Sustainability, 14(1), 127. Mdpi.
31. https://doi.org/10.5121/ijci.2024.130202 https://doi.org/10.3390/su14010127
[25]. Expert Marketing Advisors. (2023, September 14). [36]. Buehler, T. Leigh. (2024, April 3). Artificial
Unlocking A Seamless Customer Experience With Intelligence in Retail and Improving Efficiency |
Omnichannel Marketing. Www.linkedin.com. American Public University. Www.apu.apus.edu.
https://www.linkedin.com/pulse/unlocking- https://www.apu.apus.edu/area-of-study/business-
seamless-customer-experience-omnichannel and-management/resources/artificial-intelligence-in-
[26]. Cook, B. (2023, August 22). Cost Reduction retail-and-improving-efficiency/
Process: Definition and Steps. Tipalti.com. [37]. Coherent Market Insights. (2023, December 26).
https://tipalti.com/expenses-hub/cost-reduction- The Future of Shopping: How AI is Reshaping
process/ Retail Dynamics. Www.linkedin.com.
[27]. Cohen, S. (2022, September 19). The Growing https://www.linkedin.com/pulse/future-shopping-
Awareness and Prominence of Environmental how-ai-reshaping-retail-dynamics-mkijf
Sustainability. State of the Planet. [38]. Grewal, D., Benoit, S., Noble, S., Guha, A., Carl-
https://news.climate.columbia.edu/2022/09/19/the- Philip Ahlbom, & Jens Nordfält. (2023). Leveraging
growing-awareness-and-prominence-of- In-Store Technology and AI: Increasing Customer
environmental-sustainability/ and Employee Efficiency and Enhancing their
[28]. Reddy, K. Pradeep. (2023). Consumers perception Experiences. Journal of Retailing, 99(4).
on green marketing towards eco-friendly fast https://doi.org/10.1016/j.jretai.2023.10.002
moving consumer goods. International Journal of [39]. Ruparelia, A. (2022, March 5). 8 Types of
Engineering Business Management, 15(15). Traditional Marketing Methods to Implement -
https://doi.org/10.1177/18479790231170962 Salespanel. Salespanel Blog.
[29]. Acxiom Technologies LLP. (2023, October 30). https://salespanel.io/blog/marketing/traditional-
Advantages Of Using AI chatbots to Strengthen IT marketing-methods/
Service Management. Www.linkedin.com. [40]. Hashemi-Pour, C. (2023, October). What Is CRM
https://www.linkedin.com/pulse/advantages-using- (Customer Relationship Management)? TechTarget.
ai-chatbots-strengthen-service-management-qwr1f https://www.techtarget.com/searchcustomerexperien
[30]. LaMorte, W. (2022). The Social Cognitive Theory. ce/definition/CRM-customer-relationship-
Boston University School of Public Health. management
https://sphweb.bumc.bu.edu/otlt/MPH- [41]. Susanti, Y., Pratiwi, H., Sri Sulistijowati, H., &
Modules/SB/BehavioralChangeTheories/Behavioral Liana, T. (2014). P A. M Estimation, S Estimation,
ChangeTheories5.html and MM Estimation in Robust Regression, Volume
[31]. Ostojić, I. (2024, May 14). Council Post: More 91(No. 3). https://doi.org/10.12732/ijpam.v91i3.7
Than Chatbots: AI Trends Driving Conversational [42]. Dwivedi, Y. K., Ismagilova, E., Hughes, D. L., &
Experiences For Customers. Forbes. Carlson, J. (2021). Setting the Future of Digital and
https://www.forbes.com/sites/forbesbusinesscouncil/ Social Media Marketing research: Perspectives and
2024/03/15/more-than-chatbots-ai-trends-driving- Research Propositions. International Journal of
conversational-experiences-for- Information Management, 59(1), 1–37.
customers/?sh=23b772bb29f7 Sciencedirect.
[32]. Mehta, J. (2023, November 18). The role of chatbots https://doi.org/10.1016/j.ijinfomgt.2020.102168
in personalized customer experiences. Abmatic.ai. [43]. Integration, T. (2023, August 16). 5 ways to
https://abmatic.ai/blog/role-of-chatbots-in- streamline & improve your supply chain process -
personalized-customer- 2023. Target Integration.
experiences#:~:text=Personalized%20interactions% https://targetintegration.com/5-ways-to-streamline-
3A%20Chatbots%20can%20use improve-your-supply-chain-process-2023
[33]. Trend Hunter. (2023, April 28). How AI is [44]. V-Count. (2024, January 26). The Impact of AI
Revolutionizing Retail. Www.linkedin.com. Technologies in Retail - V-Count. V-Count.com.
https://www.linkedin.com/pulse/how-ai- https://v-count.com/the-impact-of-ai-technologies-
revolutionizing-retail-trend-hunter on-retail-examining-benefits-and-transformations-
[34]. Fergus, S. (2024, January 17). Exponential Growth in-
of Data: Avoiding a Resource Allocation Paradox. shopping/#:~:text=AI%2C%20with%20its%20adva
Shipyard. nced%20algorithms
https://www.shipyardapp.com/blog/exponential- [45]. Ngoc, B. (2024, April 21). Why Affordable AI
data- Chatbots Can Revolutionize Your SME.
growth/#:~:text=As%20data%20volumes%20grow Www.linkedin.com.
%20exponentially

IJISRT24MAY2422 www.ijisrt.com 3278


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

[46]. https://www.linkedin.com/pulse/why-affordable-ai- [58]. Pandey, P. (2023, August 10). Exploring Semantic


chatbots-can-revolutionize-your-sme-bui-ngoc- Search Using Embeddings and Vector Databases
okr1c?trk=public_post with some popular Use Cases. Medium.
[47]. Fernandex, R. (2024, May 5). Mistral AI Launches https://medium.com/@pankaj_pandey/exploring-
Mistral Large LLM and “Le Chat”: Everything You semantic-search-using-embeddings-and-vector-
Need to Know. Techopedia. databases-with-some-popular-use-cases-
https://www.techopedia.com/mistral-ai-launches- 2543a79d3ba6
mistral-large-llm-and-le- [59]. Rizvi, M. (2023). Investigating AI-Powered
chat#:~:text=Mistral%20Large's%20capacities%20a Tutoring Systems that Adapt to Individual Student
re%20still,as%20a%20text%2Dbased%20model. Needs, Providing Personalized Guidance and
[48]. LangChain. (2024). Q&A with RAG | LangChain. Assessments. The Eurasia Proceedings of
Python.langchain.com. Educational and Social Sciences, 31, 67–73.
https://python.langchain.com/v0.1/docs/use_cases/q https://doi.org/10.55549/epess.1381518
uestion_answering/ [60]. Roy, M. (2022). Artificial Intelligence in
[49]. MoldStud. (2024, May 5). Benefits of using AI- Pharmaceutical Sales & Marketing -A Conceptual
driven chatbots in software applications. Overview.
Moldstud.com. https://moldstud.com/articles/p- [61]. Oosthuizen, K., Botha, E., Robertson, J., &
benefits-of-using-ai-driven-chatbots-in-software- Montecchi, M. (2020). Artificial intelligence in
applications retail: The AI-enabled value chain. Australasian
[50]. Ali, O., Murray, P. A., Momin, M., Dwivedi, Y. K., Marketing Journal (AMJ), 29(3).
& F. Tegwen Malik. (2024). The effects of artificial https://doi.org/10.1016/j.ausmj.2020.07.007
intelligence applications in educational settings:
Challenges and strategies. Technological
Forecasting and Social Change, 199, 123076–
123076.
https://doi.org/10.1016/j.techfore.2023.123076
[51]. Hackett, T. (2024, February 23). Competitive
Pricing Tactics: Stay Profitable in a Cutthroat
Market. Medium.
https://medium.com/@tony.hackett/competitive-
pricing-tactics-stay-profitable-in-a-cutthroat-market-
d3d0f4f43926
[52]. Walia, E. (2024, January 11). Cybersecurity
essentials for Retail business in 2024.
Www.linkedin.com.
https://www.linkedin.com/pulse/cybersecurity-
essentials-retail-business-2024-eshan-walia-wy3ef
[53]. Božić, V. (2023). RISKS OF DIGITAL DIVIDE IN
USING ARTIFICAL INTELLIGENCE (AI). RISKS
of DIGITAL DIVIDE in USING ARTIFICAL
INTELLIGENCE (AI).
https://doi.org/10.13140/RG.2.2.18156.13443
[54]. Elsaid, H. (2024, March 1). AI in banking: What will
it actually change? Trade Finance Global.
https://www.tradefinanceglobal.com/posts/ai-in-
banking-what-will-it-actually-change/
[55]. Hypersonix, & Becchetti, G. (2024, March 28).
Optimizing Retail Operations with Predictive
Analytics and AI. Hypersonix.
https://hypersonix.ai/blog/optimizing-retail-
operations-with-predictive-analytics-and-ai/
[56]. Joadekar, P. (2024). AI and Responsible Banking:
Balancing Efficiency with Ethics | Synechron.
Www.synechron.com.
https://www.synechron.com/insight/ai-and-
responsible-banking-balancing-efficiency-ethics
[57]. OnFinance AI. (2024, April 14). Unlocking
Precision: The Art of Fine-Tuning Language
Models. Www.linkedin.com.
https://www.linkedin.com/pulse/unlocking-
precision-art-fine-tuning-language-models-fwwfc

IJISRT24MAY2422 www.ijisrt.com 3279


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

APPENDICES

A. Data Preparation Code

Fig 14: Code for reformat_conversation

The dataset is first being reformatted so that it will be easier to preprocess the dataset and create conversational pairs which
is in a format that we need to fine-tune the Falcon7B model further down the line shown in Fig. 14.

Fig 15: Code to Form Conversation Pairs

The code above in Fig. 15 shows that we have successfully preprocessed the dataset and pre-processed it to a suitable format
for fine-tuning. The model Falcon7B requires a dataset that contains only columns “context” and “response” to be fine-tuned.

IJISRT24MAY2422 www.ijisrt.com 3280


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 16: Code to Select 5k Random Rows

However, due to computational resources and time constraints, we will not be able to fine-tune the model with the entire
dataset as it will take a very long time to complete the fine-tuning process. Hence 5 thousand rows have been randomly selected as
shown in Fig. 16 to test whether the model can properly generate responses.

B. Data Preparation for Falcon7B

Fig 17: Data Source from Hugging Face

To start, a suitable dataset is found from Hugging Face to fine-tune our model Falcon7B. The dataset that will be used in this
fine-tuning process would be the dialogsum dataset provided by knkarthick on Hugging Face in Fig. 17.

IJISRT24MAY2422 www.ijisrt.com 3281


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 18: Downloading Dataset using “Datasets” Library

The dataset is then downloaded using the datasets library using the code in Fig. 18.

Fig 19: Detailed Structure of Dataset

From the screenshot above in Fig. 19, we can observe the original structure of the dataset.

Fig 20: Importing Model

From the screenshot above in Fig. 20, the model is being imported.

C. Falcon7B Inferencing and RAG

IJISRT24MAY2422 www.ijisrt.com 3282


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 21: Initializing Tokenization

Next, as shown in Fig. 21, we downloaded the model and save the checkpoints using the HuggingFace API. In this case, we
have used the sharded version of the original Falcon7B because we want to finetune it.

After setting up the model (tokenizations, peft configs etc), we can now start to finetune the model using the train function.
This process took about 5.5 hours with the epoch being set to 3. This resulted in a training loss of 1.999603442382812. After
training, the model is then saved into a folder with files like adapter_config.json and adapter_model.bin present.

Fig 22: Responses Generation Code

IJISRT24MAY2422 www.ijisrt.com 3283


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 23: Responses from Model

After loading the finetuned model, we then set up a simple code that allows us to perform inferences and get some responses
from the model as shown in Fig.22 and Fig. 23.

Here we can observe that the model can provide normal responses when we ask it questions.

Fig 24: PDF Processing

IJISRT24MAY2422 www.ijisrt.com 3284


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Lastly for this experiment, we tried to use Retrieval Augmented Generation so that the model can perform pdf querying. First
up, we will use the chunk_text function to process the pdf in forms of chunks that is useful later for the model to provide relevant
responses according to the information in the pdf as shown in Fig. 24 above.

Fig 25: Code to Generate Responses from PDF

After the chunks have been processed, it is being used in this inference function that allows the model to reply with relevant
information related to the pdf that is being uploaded as shown in Fig. 25.

Fig 26: Simple Code to Test out Chatbot Feature

As we can observe from the response from the model above in Fig. 26, it is still acceptable but could be better. This
occurrence is because the model is not properly fine-tuned with the relevant dataset and is not suitable for pdf querying, hence a
future improvement would be to fine-tune it with the relevant dataset to get a more natural and accurate response without the need
for pdf or any external resources.

IJISRT24MAY2422 www.ijisrt.com 3285


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

D. Data Preparation for Llama2B + Langchain

Fig 27: Importing Required Libraries

First, in Fig. 27, we will import all necessary libraries to get this model running together with the use of langchain.

Fig 28: Loading PDF

The pdf is then loaded from the local storage as shown in Fig. 28.

Fig 29: PDF Processing

In Fig. 29, the code above will then process the PDF characters into chunks for embedding later.

Fig 30: Downloading Embeddings

The code in Fig. 30 above shows that we have to download the embeddings first which is “all-MiniLM-L6-v2”.

IJISRT24MAY2422 www.ijisrt.com 3286


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 31: Initialising Pinecone and setting up the environment

Then the pinecone is initialized so that we can create embeddings for each of the text chunks from the previous process as
shown in Fig. 31.

E. Llama2 + Langchain Inferencing and RAG

Fig 32: Testing Embeddings Function

Referring to Fig. 32, after the embeddings have been created, we can now try to provide a query and observe its response.
We will first test it by using the similarity search to validate if the docsearch is searching for relevant information from the
document based on the query that we have provided. In this case, it has succeeded.

Fig 33: Importing Llama2 Model

Now we will load the quantized Llama model for inferencing and pdf querying shown clearly in Fig. 33.

IJISRT24MAY2422 www.ijisrt.com 3287


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 34: Setting Parameters for Llama2

Fig. 34 above shows that the parameters are being set up to control how the response will be given by the model where the
n_ctx is the number of character inputs allowed into the model during inference. N_gpu_layers and n_batch determine how
complex the model can be processed to generate a more accurate answer according to the questions asked, but it will then require
more computational power.

Fig 35: Using Langchain for Inference

With the help of the langchain library, we can enter our input and observe that the model can provide a normal relevant
response to us as demonstrated in Fig. 35.

IJISRT24MAY2422 www.ijisrt.com 3288


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

F. Sraping Script
Fig. 36 below shows the code used for scrapping purposes.

Fig 36: Scrapping Script

G. Mistral7B Setup

Fig 37: Setting Up LLM Model

IJISRT24MAY2422 www.ijisrt.com 3289


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

By referring to Fig. 37, we configured the max_new_tokens and set it to 8000 to ensure the generation of comprehensive
responses without prematurely cutting off, thereby minimizing the risk of incomplete answers. The context window (n_ctx) is
extended to 2048 tokens, which allows the model to consider more extensive input for better-informed and contextually relevant
outputs. A temperature setting of 0.6 strikes a balance between predictability and creativity, producing responses that are reliable
yet nuanced. The inclusion of a callback_manager with a StreamingStdOutCallbackHandler facilitates real-time observation of
responses for debugging purposes. Lastly, verbose=True is enabled to provide detailed logs during operation, essential for
monitoring the model's internal processes and fine-tuning its performance for optimal interaction quality. These settings
collectively aim to enhance the user experience by ensuring that the chatbot can handle intricate queries with detailed and relevant
replies.

H. Data Preprocess for RAG

Fig 38: Data Preparation Code

Fig. 38 above shows the code used to prepare our data for RAG. This process begins with text splitting, where the data is
divided into manageable pieces or 'chunks' that the model can easily process. In the context of RAG, which combines retrieval
from a database with a generative language model, the ability to pinpoint relevant information rapidly is crucial. By breaking
down the text into smaller segments, we facilitate a more precise and efficient retrieval process. This granularity ensures that the
model can focus on the most relevant sections of text when generating a response to a query.

Once the text is split, chunking comes into play. Each chunk, often a paragraph or a set of sentences containing a complete
thought, is then encoded into vectors using embeddings. These embeddings capture the semantic meaning of the text and allow the
model to perform mathematical operations on the textual data. This step is vital because it transforms the text into a format that
the machine learning model can understand and manipulate. Embedding the chunks into a vector space creates a searchable index
that the RAG model can query to find the most relevant information for any given input. This process is critical for the model's
ability to generate accurate, informative, and contextually relevant responses based on the input data it retrieves.

I. LLM Chaining and Output Translation Code

Fig 39: Function to Create Concise Prompt for LLM Chaining

IJISRT24MAY2422 www.ijisrt.com 3290


Volume 9, Issue 5, May – 2024 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 https://doi.org/10.38124/ijisrt/IJISRT24MAY2422

Fig 40: Function to Create Dynamic Prompt for Final Output

After the user provides an input, the system will first classify the query before creating a custom prompt for generating the
first response. A token limit is imposed to prevent the response from exceeding the context window for LLM Chaining later. From
Fig. 39, after creating the first response using the template created by the create_concise_prompt() function, we then pass the
output as an input for the next response generation to further refine the final output. This is done using another prompt template
with the create_dynamic_prompt() function with minimal token limitation to ensure that it generates what is needed, shown in Fig.
40.

Fig 41: English to Bahasa Malayu Translation Code

Lastly, the final output is then displayed together with its translated version with the code snippet in Fig. 41.

IJISRT24MAY2422 www.ijisrt.com 3291

You might also like