AWS for Industries

Personalizing gamified diabetes education for children with Amazon Bedrock

Learning that your child will be impacted by diabetes for the rest of their life is hard, and teaching them how to manage the condition in a fun and productive way adds difficulty. Generative artificial intelligence (AI) now provides an opportunity to enhance educational games to be intuitive, informative, and engaging.

We’ll provide details on a proof-of-concept application that leverages the Amazon Titan large language model (LLM) through Amazon Bedrock to personalize the education of type 1 diabetes for children in a gamified setting. The intention is to integrate generative AI with serious games (games designed to teach a certain topic) to enhance available education for young children.

Diabetes, characterized by high blood sugar, affects about 1 in 9 people in the United States, including over 300,000 children with type 1 diabetes (T1D). Without proper blood sugar control, diabetes leads to significant health problems over time, such as heart disease and kidney disease.

Gamified learning experiences to teach diabetes management have been tried previously, but suffered from limitations. These included complex, action-packed gameplay that presented a high barrier for entry—especially for younger children of the ages 4-7, a peak age range for type 1 diabetes. Such games also lacked variety—with presentations of a fixed number of pre-programmed scenarios.

The T1D Learning Camp game addresses these issues by reducing the gameplay complexity and increasing the interactivity. In the game, the user plays as a dog character who has type 1 diabetes and who is going to a sleepaway camp. At the camp, they learn how to make healthy eating choices and the effects of different foods on individuals with type 1 diabetes. A character named “Dr. Robot” acts as a guide for the player throughout the camp experience.

The game is a combination of:

  • text-and-response-based conversing sections
  • minigame playing sections
  • island exploring sections

In conversing sections, the player engages in lessons to learn about concepts such as blood sugar and the difference between high-carbohydrate “rocket food” and low-carbohydrate “train food.” They also learn about symptoms of hyperglycemia (high blood sugar) and hypoglycemia (low blood sugar). The player converses with Dr. Robot about these topics and the foods they have been eating.

Rather than needing to manually map out hundreds of potential conversation pathways to match possible user inputs, the project leverages generative AI to create tailored responses in near real time (Figure 1).

A conversation between Dr. Robot and the player in a cafeteria setting. The user is asked to describe what they ate for breakfast and is able to type a response.Figure 1: Dr. Robot and the player discussing current diets in a conversing section.

In playing sections (Figure 2), the child plays minigames that include gameplay mechanics such as sorting food into “rocket” and “train” categories. They also blast away symptoms with the correct type of food (rocket or train). As users successfully sort items, they are awarded points. Future iterations of the game will include virtual medals that users will obtain when surpassing particular levels of points. This reinforces the concepts presented during conversing sections and encourages continued game play.

The player flies through space and encounters symptoms of high and low blood sugar. They will choose either a rocket icon (high-carbohydrate food) or train icon (low-carbohydrate food) to combat symptoms requiring different levels of carbohydrates.Figure 2: Symptom Space Destroyer minigame in a playing section.

In exploring sections, players can maneuver their character around the island and traverse between the various lessons and minigames (Figure 3). As they explore, they can also locate non-player characters who chat with them.

The player explores the island (walking along various paths) and encounters a non-player character (a cat) who chats with the user. A schoolhouse and Dr. Robot can also be seen on the island amidst a forest with a river.Figure 3: A non-player character on the island talking to the player in an exploring section.

High-Level Architecture Overview

The T1D Learning Camp game is created within the Godot game engine and calls Amazon Bedrock APIs to support the conversation between characters. Due to Godot’s use of a custom programming language, gdscript, SDKs such as Python’s Boto3 are not natively integrable.

To manually start the connection, Amazon API Gateway is configured to call an AWS Lambda function using Python to invoke Amazon Bedrock APIs and return results to Godot. This mechanism of using API Gateway enables an HTTP Request node in Godot to make these requests without needing to send a required signature (Figure 4).

High-level architecture used to build the T1D Learning Camp game. A user interacts through their desktop with the application leveraging Godot 4 as the game engine. Godot makes a call to Amazon API Gateway, triggering an AWS Lambda function to make API calls to the model in Amazon Bedrock.Figure 4: High-Level Architecture of the T1D Learning Camp game.

To achieve the personalized chats with Dr. Robot, a custom “conversation” resource in Godot stores an array of pre-written dialog, placeholders for user responses, and space for Amazon Bedrock replies.

Prompt engineering is used to allow characters to provide contextually appropriate responses with simplified language. Parameters are added to the Amazon API Gateway request module to allow LLM settings to be specified directly from Godot. The parameters length, temperature, and top-p are used to control the responses’ maximum token length, randomness, and diversity (Figure 5).

The conversation structure used within the application has pre-created dialog to prompt the user for information or respond. Examples include, “Does rocket food have a little energy or lots of energy” and placeholders for actions like “Call Amazon Bedrock.” These dialog prompts translate into calls to Amazon Bedrock.

Figure 5: Conversation structure.

Additionally, Amazon Bedrock Guardrails are used to control responses provided to the player to avoid medically inaccurate and unreliable information or medication advice, such as the quantity or timing of taking insulin. Amazon Bedrock Guardrails allow for customizable safeguards on top of the native LLM protections to accept and deliver safe prompts and responses. The conversation system in T1D Learning Camp, leveraging Amazon Titan with Guardrails, is a key example of how large language models can be used in games.

The game player’s character (a dog with a red bandana and continuous glucose monitor) and the doctor character (a robot wearing a white hat with a medical plus sign on it) engage in a lesson during a conversing section. The player asked, “Can I eat watermelon all the time?” and Dr. Robot generated a response using Amazon Titan that says, “Watermelon is rocket food, so you can eat it before you go out to play.”Figure 6: Dr. Robot giving a response generated with Amazon Titan. This is in reply to the player asking the question, “Can I eat watermelon all the time?”

Future Improvements

Besides using Amazon Bedrock in conversing sections, generative AI can be further leveraged to enhance the content, engagement, and accessibility of T1D Learning Camp, such as through the use of Amazon Bedrock Knowledge Bases. Amazon Bedrock Knowledge Bases is a fully-managed capability that helps you implement the entire retrieval augmented generation (RAG) workflow from ingestion to retrieval and prompt augmentation. RAG would allow the LLM to create responses that include additional details from provided type 1 diabetes resources. The application could use Amazon Simple Storage Service (Amazon S3) as a data source for the Amazon Bedrock Knowledge Base using Amazon OpenSearch Service as the vector database.

Future iterations will include the use of Amazon Transcribe, an automated speech recognition and speech-to-text machine learning service, to allow users to speak with the application rather than type. This feature would lower the barrier to entry for young children who are not proficient in writing or typing and also improve accessibility for the visually impaired.

Another planned improvement is to utilize the generative AI text-to-speech capabilities of Amazon Polly to equip game characters with more natural and understandable voices. Many currently computer built-in text-to-speech voices are robotic sounding and may be difficult for a child or the hearing impaired to understand.

Finally, improvements could be made to broaden application use to non-English speaking children. Amazon Translate could translate responses from Amazon Bedrock in conjunction with the ability to generate speech in a variety of languages through Amazon Polly. Also, the Amazon Titan Image Generator foundation model could help to dynamically generate stylized artwork of any food to personalize the experience based on user input. A child’s caregiver could create a list of food specific to the child’s diet or culture, and these generated foods could be added to or replace the base set of food items. These changes could make the game more accessible to both very young children and children of different languages, cultures, and diets (Figure 7).

A high-level architecture of planned future improvements to the application. The user would still interact through their desktop with the application leveraging Godot 4 as the game engine. Godot makes a call to Amazon API Gateway, triggering an AWS Lambda function to make API calls to the model in Amazon Bedrock. Future improvements would add Amazon S3 as the data source for an Amazon Bedrock Knowledge Base using Amazon OpenSearch Service as the vector database. Amazon Polly, Amazon Transcribe, and Amazon Translate would be leveraged for increased accessibility. Amazon Titan Image Generator is a foundation model within Amazon Bedrock and would allow for additional food artwork to be generated.

Figure 7: High-level architecture of planned future improvements. Amazon S3 is used as the data source for an Amazon Bedrock Knowledge Base using Amazon OpenSearch Service as the vector database. Amazon Titan Image Generator is a foundation model within Amazon Bedrock.

Conclusion

Generative AI has the potential to change the way games interact with players, including serious games for children with various medical conditions. Ultimately, the implementation of generative AI into projects like T1D Learning Camp may be able to help improve patient outcomes, providing a more personalized, engaging, and accessible experience for children with type 1 diabetes.

Contact an AWS Representative to know how we can help accelerate your business.

To learn more about AWS for Healthcare & Life Sciences—curated AWS services and AWS Partner Network solutions used by thousands of healthcare and life sciences customers globally—visit the AWS for Healthcare & Life Sciences and AWS Healthcare Solutions webpages. You can also read more blogs about AWS healthcare stories.

Steven C. Silvers

Steven C. Silvers

Steven C. Silvers is a senior at Thayer Academy in Braintree, MA, where he enjoys running school-wide initiatives as a Class Officer, Co-President of Sustainability Club, and Co-President of Coding Club. He loves to develop video games and create digital art, including having designed, developed, and illustrated T1D Learning Camp. Steven is passionate about making an impact through technology and is planning to major in Computer Science in college.

Maria Fassinger

Maria Fassinger

Maria Fassinger is a Solutions Architect for the Worldwide Public Sector organization at Amazon Web Services (AWS). She works primarily with higher education, healthcare, and research institutions to architect cloud-based solutions.

Isaac “Zak” Kohane, MD, PhD

Isaac “Zak” Kohane, MD, PhD

Isaac “Zak” Kohane, MD, PhD, is the inaugural chair of Harvard Medical School’s Department of Biomedical Informatics, whose mission is to develop the methods, tools, and infrastructure required for a new generation of scientists and care providers to move biomedicine rapidly forward by taking advantage of the insight and precision offered by big data. Kohane develops and applies computational techniques to address disease at multiple scales, from whole health care systems to the functional genomics of neurodevelopment. He also has worked on AI applications in medicine since the 1990’s, including automated ventilator control, pediatric growth monitoring, detection of domestic abuse, diagnosing autism from multimodal data and most recently assisting clinicians using whole genome sequence and clinical histories to diagnose rare or unknown disease patients. He is the inaugural Editor-in-Chief of NEJM AI and co-author of a recent book “The AI Revolution in Medicine." He is a member of the National Academy of Medicine, the American Society for Clinical Investigation and the American College of Medical Informatics.