1 Introduction

Conversational applications, such as Google Assistant and Amazon Alexa, are widely used worldwide because of their advancements and advantages [1]. This application provides services to the user by assisting or providing them with the most suitable answers relevant to the questions [2]. It is used in different sectors like education, engineering, medicine, etc. [3]. However, it is very useful in the medical field for providing healthcare suggestions to users [4]. The advancement in digital healthcare aims at offering personalized health services and helping patients manage their health conditions [5]. The Chatbot is one of the applications which delivers cost-effective services to people [6]. The main objective of the Chatbot in the medical field is to assist users related to medical queries [7], providing users convenience through mobile messaging apps [8], thus minimizing the time and cost for the user [9]. Moreover, advanced Chatbot applications help monitor the patient’s health [10]. The Chatbot conversation block diagram is illustrated in Fig. 1.

Fig. 1
figure 1

Chatbot conversation

The Chatbot conversation technique is based on machine learning or deep learning concepts like convolutional neural networks (CNN) [11], recurrent neural networks (RNN) [12], support vector machine (SVM) [13], decision tree [14], and random forest [15]. These concepts are integrated into the general Chatbot model to provide advanced services to the users. In an intelligent Chatbot framework, the user interacts with the automated program to retrieve the answers to their queries [16]. An intelligent Chatbot conversation is conceptualized as a set of interconnected layers [17]. The knowledge layer of the automated Chatbot conversation consists of the user’s databases and domain [18]. The data from this layer acts as the input for the service layer of healthcare provision. Moreover, this layer is responsible for the healthcare decision-making processes. Once the decision is created, it is communicated to the dialog layer. The dialog layer extracts the user’s intentions and creates responses by consulting the service layer. Further, it communicates them to the presentation layer.

In Chatbot conversations, retrieving accurate data following the queries is very complex. Different Chatbot models, like the AI conversation framework for the Twitter environment [19] and AI chat for the medical field [20], were designed to offer healthcare assistance to patients/users. However, these approaches provide less accuracy in the answer retrieval process. Moreover, it requires huge data to train the system. Hence, to overcome these issues, the AI conversation system, a speaker identification model [21], and a privacy range for the medical AI bot [22] are implemented to provide highly accurate conversation and better services to the users. However, the processing time of these models is high because of the highly complicated AI network. Therefore, researchers move towards developing an approach with less system complexity. The approaches include Chabot for classification based on entropy [28], Chatbot with double feature extraction [29], intelligent knowledge–based Chatbot [30], user interactions with Chatbot interfaces [31], Chatbot to provide continuous service [32], appropriation of conversational AI [33], Chatbot conversation for future directions [34], Chatbot with perception, and interaction [35], etc., which were developed to provide highly accurate healthcare services to the users in an effective manner. However, cost, processing time, and implementation are complex. Hence, to overcome the demerits of the existing Chatbot models, the novel hybrid optimized intelligent Chatbot framework is developed in this article. This approach incorporates two approaches and provides fast and accurate answers to user queries. In addition, the time and system complexity in this model are low. The optimal function in the answer retrieval phase helps provide highly relevant answers to the users. Moreover, the approach’s effectiveness is validated by comparing its performance with the existing techniques.

The key contribution of this presented model is described as follows:

  • Initially, the medical QA dataset is gathered from the standard site and imported into the system.

  • Consequently, the novel LbDBC is designed in the system to search for answers relevant to the user’s queries.

  • In the tokenization and stemming process, the connective and repeated words are removed from the input text data, and the root word is extracted.

  • Moreover, incorporating lion fitness to the designed model provides finest answer retrieval rate.

  • Finally, the performance of the QA functions was calculated and compared with other models, and then, the improvement score is described in terms of accuracy, precision, error rate, recall, and f-measure.

The presented article is arranged as follows: the recent research articles related to Chatbot conversion are described in section 2; the existing approach along with its demerits are illustrated in section 3; the designed Chatbot model for medical application is detailed in section 4, the case study, performance, and assessment are explained in section 5; and in section 6, the conclusion of the article is presented.

2 Related works

Few recent kinds of literature are described as follows.

The AI conversation framework has been designed for the Twitter application by Gutierrez et al. [18]. Here, the designed Chatbot answered the queries in the Twitter environment. Hence, several likes have been gained from the users using the Twitter application. However, this model requires more resources to address each query. Also, if the asked query keyword is not present in the stored keyword set, it gains less accuracy in answer matching.

Saba et al. [19] have developed an AI chat for the medical field. The aim of this AI in the medical area is to offer accurate answers to the user’s medical questions. This model supports the rural people living in undeveloped areas with fewer hospital facilities. In addition, the deep neural model has been employed to analyze user queries. However, it required more time to execute.

In another case, AI is utilized for emotion recognition; the emotion features were trained as the dataset. Poria et al. [20] have introduced dual models to design the emotion classification AI conversation system: a speaker identification model and a listening module. By incorporating this model, the designed AI system classifies the emotion types. However, it has recorded high design complexity and requires more resources.

To improve the privacy range for the medical AI bot, Gille et al. [21] have introduced a trustworthy scheme in the AI bot conversation system by recognizing authenticated users. After identifying the authenticated users, the answers were retrieved for the medical queries asked by the specific users. If the users are not authenticated, then communication is blocked. It has recorded the maximum time duration to complete the process.

Yang et al. [22] have implemented the Chatbot system for a recommendation system to find the influencer within a short duration. Hence, the designed Chatbot was checked with multi-turn QA datasets. The developed QA Chatbot has gained the finest accuracy for the required information retrieval process in a short duration. However, more resources were required to implement this process.

3 System model with problem

The main concern in AI chat conversation applications is understanding the present features in the asked questions. The normal classification model has failed to recognize the present features in the questions and relevant answer-retrieving process. The users ask about their medical issues in the existing Chatbot model [23]. Initially, the system identifies the key feature in the question and uses it in the answer-retrieving process. Nevertheless, it is not easy to recognize the key feature in the existing model. Thus, the answers are irrelevant to the questions.

Moreover, the computation expansive has been raised in the present system, and more resources are required. Thus, adding specific features for different QA types of data is a complicated task in the NLP environment [36]. These issues have motivated this research toward the optimized deep learning model. The system model with the problem statement is depicted in Fig. 2.

Fig. 2
figure 2

System model with a problem statement

4 Proposed LbDBC for smart medical applications

The medical Chatbot is the most required model for digital applications and to enhance smart applications. The novel Lion-based Deep Belief Chatbot (LbDBC) model has been planned to develop in this research study. The Chatbot is an artificial intelligence approach applied in messaging applications. It is a medical-based messenger application that helps users by providing interaction between the users and the automated programs [37]. The designed Chatbot model hybrids the lion optimization technique [24] and the deep belief neural network [25]. The medical-related QA database has been collected from the standard site to validate the designed model. Initially, the data was imported and initialized in the system. Here, the fitness of the lion is upgraded in the classification layer of the deep belief model, so it is called LbDBC.

Then, the raw text in the dataset is tokenized using Natural Language Toolkit. Moreover, the stemming process extracts the root words and removes the text’s prefixes and suffixes. Then, the QA dataset is trained using the proposed LbDBC approach to provide relevant answers to the users based on their queries. Finally, the performance metrics have been measured and validated with other models. The proposed architecture is described in Fig. 3.

Fig. 3
figure 3

LbDBC framework

4.1 Design of LbDBC

The proposed LbDBC approach incorporates features like tokenization, stemming, and answer retrieval to attain the finest Chatbot conversation. Initially, the medical QA dataset is collected from the standard site and imported into the system. The gathered dataset contains medical and emotional-based questions and answers. To process the dataset, it must be initialized. Here, the initialization is done based on the concept of the lion optimization approach. The lion optimization algorithm (LOA) is a nature-inspired approach based on the behavior of lions. Generally, lions are noticed for their high level of aggression and collaboration, and it is divided into two groups: nomad lions (NL) and resident lions (RL). The NL type infrequently moves either individually or in pairs. Nevertheless, the RL live in groups called pride. Usually, the lions hunt the prey in groups in which some female lions work collectively and surround the prey from multiple points to catch it. Meanwhile, the other male and female lions wait for the female hunter lions. In LOA, the habits of the lion are mathematically modeled to solve optimization problems. Initially, the population is created by collaborating with randomly generated solutions named lions. Similarly, in the developed model, the dataset is initialized using the initialization function of LOA. The equation for dataset initialization is expressed in Eq. (1).

$$F(M_{QA} ) = \left( {tx_{1} ,tx_{2} ,tx_{3} , \ldots ,tx_{m} } \right)$$
(1)

Here, F denotes the initialization function, MQA indicates the input medical dataset, tx refers to text data present in the dataset, and m indicates the total count of data present in the dataset.

4.1.1 Tokenization

Tokenization is the foremost step in natural language processing (NLP). It involves splitting whole input text data into individual subwords called tokens. In this process, the input queries are tokenized into subwords [38]. This process helps in detecting the feature and improves the retrieval rate. The tokenization equation is represented in Eq. (2).

$$T\left( {M_{QA} } \right) = \mathop \prod \limits_{i = 1}^{m} \Gamma \left( {tx_{i} } \right)$$
(2)

where T indicates the function for tokenization, and txi indicates the subword. After tokenization, the next step in NLP is stemming.

4.1.2 Stemming

Stemming is one of the important processes in the pipelining process of natural language processing (NLP). Generating morphological variants of a base word is known as the stemming mechanism. This is generally referred to as stemmers or stemming algorithms. The stemming approach minimizes the word to the stem. For example, “retrieval”, “retrieves”, and “retrieves” are reduced to the root word “retrieve” [39]. In NLP, stemming is extracting the root work from tokenized text data. The input for the stemming process is tokenized data. It is usually done by removing the prefixes and suffixes of subwords. The presented model uses a Lancaster stemmer to find the root word. One of the most aggressive stemmers is the Lancaster, which tends to over stem many words. Like the Porter stemmer, the Lancaster stemmer contains a set of rules where each rule specifies either the replacement or deletion of an ending. Several rules are restricted to intact words, and certain rules are applied iteratively as the word goes through them. The Lancaster stemmer has more than 100 rules [40]. The stemming equation is expressed in Eq. (3).

$$S\left( {M\;_{OA} } \right) = \frac{1}{\delta }\sum\limits_{i = 1}^{m} {\left( {tx_{i} - psx_{i} } \right) = \Re_{W} }$$
(3)

Here, S denotes the stemming function, psxi the prefixes and suffixes present in the tokenized text data, and ℜW the extracted root word. After the stemming process, the dataset is trained using the designed model to answer the user’s queries.

4.1.3 Answer retrieval phase

In Chatbot conversation, the user asks medical-related queries by typing on the screen. Once the user enters their queries, the answers related to the question appear on the screen. In this system, the user can ask n number of queries. Moreover, on typing “quit,” the Chatbot conversation stops. Initially, the system processes the input and removes the connective and repeated words from the text data. Then, the system searches for answers relevant to the extracted keyword. In LOA, during the hunting process, the hunter-lions and lionesses follow some strategies to catch the prey. In this process, the hunters are divided into three wings. The center hunter has the highest fitness value, and the left and right wings are randomly fixed. The center hunter has a specific function to create the new location. In the presented model, this center new location creation function is applied to retrieve the most relevant answer for the query. The searching function is expressed in Eq. (4).

$$\beta({\Re}_{\mathrm w})=\left\{\begin{array}{ll}\mathrm{if}\;\,\left(\Re_{\mathrm w}={\mathrm T}_{\mathrm F}\right)\;&;\,\,A_N\\else&\,;{\overline A}_N\end{array}\right.$$
(4)

where β indicates the searching function, TF refers to the trained features, AN denotes the relevant answers to the input query, and \(\overline{A}_{N}\) denotes the statement that occurs when the root word does not match the trained features.

Algorithm 1
figure a

LbDBC

Thus, the system provides the most relevant answers to the queries entered by the user. Algorithm 1 represents the process of the presented approach in pseudo-code format. The workflow of the presented approach is shown in Fig. 4. In the presented approach, once the user enters “quit,” the Chatbot conversation stops.

Fig. 4
figure 4

LbDBC workflow

5 Results and discussion

The designed LbDBC model was developed to retrieve relevant answers related to medical issues. A medical QA dataset is collected and imported into the system to validate the developed Chatbot framework. The medical QA database contains questions and answers related to health issues. Then, tokenization and stemming processes are performed on the dataset to extract the root word. In this process, the repeated words, connective words, are neglected from the input data. Then, the dataset is trained using the presented approach.

After training, the Chatbot appears, in which the user can ask queries related to health issues. The presented model is implemented in Python software version 3.10. The designation of implementation parameters is listed in Table 1. Finally, the results are obtained as accuracy, recall, precision, and f-score. In addition, a comparative assessment was performed to verify the results of the presented approach.

Table 1 Designation of implementation parameters

5.1 Case study

A case study was made to describe the working of the developed Chatbot model. Initially, a medical QA dataset was collected from the standard site and imported into the system. Then, the dataset is initialized in the system, and the novel LbDBC model is designed with different features like tokenization and stemming. Tokenization is performed to split the text data into subwords so that identifying key features in the text data becomes easy. Moreover, in the tokenization process, the repeated words and connective words are removed. After tokenization, the next step is the stemming process. In stemming, the prefixes and suffixes of the key feature are removed. In this process, the root word is extracted. Then, the dataset is trained using the developed model to provide relevant answers to users based on the query. The sample dataset description is shown in Table 2.

Table 2 Sample dataset description

For example, if the user enters the question “How to deal with loneliness?” the system considers the question as input and processes the text data.

$$T(tx)\rightarrow''how\;'',''is\;'',''deal\;'',''with\;'',''loneliness\;''$$
(5)

Then, the input text data is tokenized as “How,” “is,” “deal,andloneliness”. The tokenization process is expressed in Eq. (5). Then, the connective and repeated words are removed from the text data. Then, stemming is performed to remove the words like “how,” “is,” “with,anddeal” from the text data. Moreover, the root word of the text is extracted through the stemming process. The root word in the presented sentence is “loneliness.” The stemming process is expressed in Eq. (6).

$$S(tx) \to \,\,{\text{loneliness}} = \Re_{W}$$
(6)

Then, the system searches for the answers relevant to the root word and displays them on the screen. The answer to the question entered by the user is “1) Loneliness is the state of being alone and feeling sad about it. 2) A first step to overcoming loneliness is realizing how you feel and how it impacts your life. Try talking to a counselor or therapist”. Then, on entering “quit,” the Chatbot conversation stops. Finally, the performances are estimated as accuracy, recall, error rate, and precision.

5.2 Comparative analysis

A comparative assessment was performed to manifest that the outputs of the developed Chatbot model were better than the existing approaches. The existing approaches, such as the Supervised Ensemble Model with Original Label for Chatbot Application (SEMO_CA) [26], Supervised Ensemble Model with Sentiment Label for Chatbot Application (SEMS_CA) [26], Supervised Ensemble Model with Sentiment and Context Label for Chatbot Application (SEMC_CA) [26], and Decision Tree based Chatbot Application (DTbCBA) [27], were considered.

5.2.1 Precision

Precision is estimated to determine how many exact answers are retrieved in a Chatbot conversation. It is calculated by evaluating the total true positives obtained in the process to the total true and false positives. The precision of the system is expressed in Eq. (7).

$$P_{R}^{^{\prime}} = \frac{{X^{ + } }}{{X^{ + } + Y^{ + } }}$$
(7)

where \(P_{R}^{^{\prime}}\) denotes the system’s precision X+Y+ and indicates true and false positives, respectively.

To manifest that the presented system attained a high precision value than existing approaches, it is compared with existing techniques like SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA. A comparison of the precision value of different techniques is shown in Fig. 5. The precision value attained by existing models such as SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA is 77.77%, 79%, 75%, and 80.7%, respectively. But, the presented LbDBC attained a high precision percentage of 96.42%. In the presented approach, the precision value is higher because the answers retrieved are more accurate and relevant to the queries.

Fig. 5
figure 5

Comparison of precision of different approaches

5.2.2 Accuracy

The answer retrieval rate is the percentage of correct answers retrieved from the system related to the input question. The accuracy calculation includes both true and false positives and negatives. It is expressed in Eq. (8).

$$A_{U}^{^{\prime}} = \frac{{X^{ + } + X^{ - } }}{{X^{ + } + X^{ - } + Y^{ + } + Y^{ - } }}$$
(8)

where \(A_{U}^{^{\prime}}\) refers to the system’s accuracy, and Y+ and Y denote false positives and negatives, respectively.

The accuracy comparison is shown in Fig. 6. Here, the accuracy of the presented approach is compared with existing techniques like SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA. The accuracy percentage earned by the designed model is high, 99.57%. But, the existing methods, such as SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA, obtained low accuracy percentages of 57%, 83%, 85%, and 80%, respectively. The improved accuracy in the presented approach shows that the answer retrieved is highly accurate and relevant to the question entered by the user. This shows that the developed model is more effective in retrieving the answers related to medical queries.

Fig. 6
figure 6

Comparison of accuracy

5.2.3 f-score

F-measure is a performance metric obtained by dividing the product of recall and precision value by their sum. The calculation function for the f-score is expressed in Eq. (9).

$$f - {\text{score}} = 2 \times \frac{{P^{\prime}_{R} \times R^{\prime}_{CL} }}{{P^{\prime}_{R} + R^{\prime}_{CL} }}$$
(9)

It is compared with other approaches to validate that the system attained a better f-score than existing approaches. The f-score percentage obtained by existing approaches like SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA are 70%, 88%, 90%, and 79.7%. The f-score percentage gained by the presented approach is 97.90%. The high f-measure represents that the solutions provided by the system are correct and exactly match the query. The validation of the f-score is shown in Fig. 7. In addition, the comparative performance shows that the existing models attained less f-measure than the presented model.

Fig. 7
figure 7

Comparison of f-measure

5.2.4 Recall

Recall determines the percentage of exact answers retrieved in Chatbot conversation. It is estimated by evaluating true-positive values attained by the system to the true positives and negatives. The equation for the recall is expressed in Eq. (10).

$$R^{\prime}_{CL} = \frac{{X^{ + } }}{{X^{ + } + X^{ - } }}$$
(10)

The percentage of recall value attained in the designed approach is 99.42%. But the existing approaches like SEMO_CA, SEMS_CA, SEMC_CA, and DTbCBA attained low recall-score of 64%, 79%, 75%, and 79.8%, respectively. The comparison of recall value is shown in Fig. 8, which shows that the recall score is more in the designed Chatbot model than in the existing techniques. The high recall percentage illustrates that the developed algorithm returns the most relevant results.

Fig. 8
figure 8

Comparison of recall value

The comparative assessment verified that the designed system attained high recall value, accuracy, f-score, and precision value. Thus, the presented approach earned better outcomes than the existing approaches. Also, the answer retrieved in the Chatbot conversation is more relevant to the question. The comparative performance of the developed model with the existing methods like DTbCBA, SEMSC_CA, SEMS_CA, and SEMO_CA proves that the presented model is more effective and suitable for answer retrieval related to medical questions. Furthermore, the parameter enhancement score was estimated from the comparative analysis. The overall comparative assessment is tabulated in Table 3.

Table 3 Comparative assessment

The overall comparative analysis of the proposed approaches is shown in Fig. 9. The performance and comparative analyses verify that the presented approach earned better results than the existing applications.

Fig. 9
figure 9

Overall comparative analyses

5.3 Discussion

The major objective of the designed Chatbot conversation model is to provide relevant answers to the question asked by the user. The medical QA dataset containing emotional, sentimental, and health features is gathered and imported into the system. The imported dataset is initialized and trained in the system using the presented LbDBC approach. Moreover, the tokenization and stemming mechanism in the designed approach removes the unwanted text data and helps identify the root word. The integration of the lion optimization function in the answer retrieval phase of the developed Chatbot provides the most optimal solution for the input query. The deep belief features are applied to the presented Chatbot model for intelligently tokenizing and stemming the dataset. Then, the Chatbot conversation starts when the user asks for a query. The developed model extracts the root word of the query and then matches it with the dataset root words. Finally, based on the extracted root words, the relevant answer displays on the screen. Furthermore, the effectiveness of the developed model is validated by implementing the existing approaches like SEMO_CA, SEMS_CA, SEMSC_CA, and DTbCBA on the same platform, and the results are estimated for the same medical QA dataset. Moreover, the estimated results are compared with the presented model. The comparative analysis proves that the developed model results are better than the existing approaches.

The presented model is implemented in a Python environment, and the results are determined. In addition, comparative and performance analyses are done to prove that the designed model earned better outcomes. The statistical analysis of the LbDBC model is tabulated in Table 4.

Table 4 Statistical performance analysis of the LbDBC model

The outcomes of the presented approach are determined by precision, recall value, accuracy, and f-score. The performance analysis of LbDBC is shown in Fig. 10. The presented approach earned a greater recall value of 99.42%, a high f-score of 97.90%, less error rate of 0.42%, high accuracy of 99.57%, and huge precision value of 96.42%.

Fig. 10
figure 10

Overall comparative analysis

6 Conclusion

The presented LbDBC Chatbot conservation model was developed to answer the question asked by the user accurately. This technique incorporates the attributes of lion optimization and a deep belief network. Moreover, tokenization and stemming were performed to extract the root word by removing unwanted subwords (prefixes and suffixes). In addition, the lion fitness in the designed approach provides the finest answer retrieval rate. A medical QD dataset was collected and imported into the system to validate the process. The developed model was executed in a Python environment, and results were determined. Moreover, a comparative assessment was performed to estimate the improvement score by comparing the results of the presented approach with existing techniques. The statistical analysis of the presented model states that it gained a greater f-score value as 97.9 %, high precision of 99%, huge accuracy percentage of 99.55%, and a minimum error rate of 0.0042. In addition, the comparative statistical analysis shows that the accuracy was enhanced by 1.16%, the recall score was increased by 9.5%, the f-measure was improved by 1.1%, and the precision value was magnified by 1.0%.