Intro to NLP in Infermedica API

The platform offered by Infermedica includes an NLP engine, which takes on the burden of understanding typical chief complaints — symptoms — as expressed by the users in a conversational form.

This solution can support applications that communicate with users via a written text or voice (if a third party speech recognition service is used).

The design and implementation of conversational applications is up to each healthcare organization, but they can access and use the full capacities of the clinically validated medical content. In this article, we’ll share some experiences and observations that might improve the conversational applications that the client has, while also allowing them to keep a high level of accuracy during the medical interview, triage calculation, and for Infermedica’s recommendations. 

The below presented tips are based on the use of Infermedica's NLP engine and the /parse endpoint within Infermedica API. The endpoint focuses on collecting the initial evidence from users who are using the NLP engine.

What is the NLP engine suitable for? 

NLP services are typically used in conversational types of applications, such as chatbots. Infermedica’s NLP engine is a good choice for all those applications that assume that the users are going to be describing their symptoms using text messages or voice. It understands both medical and common terms that describe medical states. It may also be advantageous for understanding symptoms that are less obvious or difficult for patients to name (e.g. mental health issues, pediatrics).

NOTE: If the planned application has a rich user interface, displaying a traditional search box might be a more natural option. Such scenarios use our /search endpoint instead of /parse. The /parse endpoint is optimal when the communication is centered around text messages or a voice app.

The interview flow within a chatbot

To use our NLP engine in a symptom checking chatbot properly, the application should have the following interview flow:

  1. Age and sex, the information should be collected directly from the user or from their account (if logged in). The information regarding age and sex is strictly required for symptoms assessment (/diagnosis endpoint). 
  2. Initial symptoms, also called chief health complaints. These are symptoms and observations corresponding to one health issue reported by the user during the chat.
  3. AI-driven medical interview, a series of symptom-related questions generated by Infermedica’s Inference Engine (/diagnosis endpoint). Each question is dynamically chosen by the engine using the input from the user, which is updated with each answer. The Inference Engine will state when enough questions have been answered and the interview should end through the “should_stop” flag in the endpoint’s response. The application will then proceed to the next step: results.
  4. The Results screen,  the final step of Infermedica’s interview but not of the user journey. Depending on the use case, this screen can present the user with: triage level, most likely conditions, explanations of conditions, recommended physician or communication channel. At this stage we can also connect the user with medical services or information provided by a healthcare organization. 

These steps are the absolute minimum. We recommend asking even more questions, if they are relevant to the application (risk factor poll, related symptoms), before proceeding to the actual medical interview.

How to collect initial symptoms with NLP? 

The way an application asks for initial symptoms matters. The more of these that are collected at the beginning, the better the medical interview will be. You should avoid vague prompts such as “How is your health?” or “What ails you?”. We recommend asking users to mention their symptoms — for instance “What symptoms are you experiencing?”, “What symptoms would you like to share today?”, or “please mention your symptoms or health complaints.”

Why is this important? Generally speaking, solutions like chatbots focus on triaging new health problems.

Infermedica’s Inference Engine and NLP Engine are adjusted to fit those use cases. 

Initial complaints are ideally specific symptoms of medical conditions (such as swollen knee, sore throat, hurting ear). Simple injury concepts are also supported (such as knee injury), as  are crucial risk factors (diagnosed asthma, smoking). Our technology can handle basic mental or behavioral changes framed as symptoms too, such as anxiety, brain fog, or apathy.

How to ask for more initial symptoms?

After the first initial symptoms are added, ask the users again if there’s anything more they’d like to add. Usually there is. Our role is to mildly encourage the user to report more symptoms. If we learn more at this stage, we increase the likelihood of giving more accurate recommendations. Consider asking additional questions like “do you want to report any other symptoms?”; “are there any other symptoms you’d like to add?”; or “try to add more symptoms”.

Confirm every collected piece of information

Infermedica's NLP engine attempts to capture all of the symptoms that the user’s message conveys. To confirm the correct understanding, in response we ask users to confirm the mentioned symptoms. Each symptom or complaint that was captured from the user's message should be confirmed.


There are three scenarios possible after a user’s symptom-bearing message has been fed through the /parse endpoint:

  1. Certain understanding. This response contains at least one mention and “is_obvious” is true. The app should acknowledge that the symptom has been captured and move on. We suggest acknowledgement messages such as “I understood: Sore throat and Cough.”
  2. Uncertain understanding: we’re guessing, it’s safer to ask for confirmation. The response contains at least one mention but “is_obvious” is false. The app should keep the new evidence as temporary and ask something like: “I understood: Sore throat and Cough. Is that correct?”. If the user confirms that it’s correct, the evidence should then be memorized. Otherwise, this temporary evidence should be discarded with an acknowledgement (e.g. “Ok, I’m ignoring those symptoms.” and issue a new prompt.
  3. Lack of understanding. The response contains no mentions. This means that the NLP service has failed to capture any symptoms in the user's message. The app should ask the question again, possibly with some extra help. E.g., “Sorry, I didn’t get that. Could you rephrase it using simpler terms?”

When responding to the user, always use the “common_name” field rather than the “name” field. This guarantees that the name will be in plain language, making it easier to understand for patients.

The response also has a flag named “is_obvious”. Use it to decide if asking for confirmation is needed.

Please note that these scenarios apply every time the prompt for symptoms is repeated. The Inference Engine needs at least one symptom to start. If the user insists that there are no symptoms, the app may agree but there is no sense in running the inference engine for those cases.


ARa, AKw