Introduction
Just-In-Time Adaptive Interventions (JITAIs) are critical components of modern health applications, designed to provide timely nudges for behaviors such as physical activity or smoking cessation. Traditionally, these systems employ Reinforcement Learning (RL) to optimize intervention timing. However, RL agents in this domain suffer from severe data scarcity, often having fewer than 100 interaction opportunities per user. To maintain data efficiency, these models typically rely on a restricted state space (e.g., location, weather), creating a significant "blind spot" regarding the user's immediate physical or mental state. For instance, an app might nudge a user to walk despite them having a sprained ankle, leading to habituation or complete disengagement.
Methodology
To address these limitations, we introduce LLM4TS (Large Language Model for Thompson Sampling), a hybrid framework that integrates the reasoning capabilities of LLMs with the data efficiency of RL.
System Architecture
The LLM4TS framework consists of two primary components operating in tandem:
- Base RL Agent: A Thompson Sampler generates candidate actions based on a simplified state space.
- LLM Action Filter: An LLM reviews natural language descriptions provided by the user to determine the appropriateness of the candidate action.
As illustrated in Figure 1, the LLM acts as a high-level "judge" that can filter out inappropriate interventions before they reach the user. This allows the RL agent to remain simple and fast-learning while the LLM manages complex real-world context.
Prompt Engineering and Inference
The LLM's decision-making is guided by a structured prompt known as the BFQH structure:
- B (Behavioral Dynamics): The fundamental rules and goals of the intervention.
- F (Free-text): The user's current status in plain English.
- Q (Questions): Chain-of-Thought reasoning prompts to guide the LLM.
- H (History): A log of recent interactions and outcomes.
Simulation Environment
Due to the risks of testing unproven RL algorithms on human subjects, the system was evaluated using StepCountJITAI+LLM, a novel simulation environment. This simulator models latent user states, including habituation, disengagement risk, and physical capacity. We utilized 1,000 ChatGPT-generated state descriptions to simulate realistic user feedback. Evaluation was performed across multiple models, including Llama 3 (8B and 70B) and Gemma 2 (9B).
Results and Discussion
Our evaluation demonstrates that LLMs are highly effective at identifying barriers to exercise from text. Llama 3 70B achieved near-perfect inference accuracy (99.9%), while the smaller 8B model maintained a respectable 88% accuracy, suggesting feasibility for on-device deployment.
Key findings include:
- Performance Gains: LLM4TS significantly outperformed standard RL in scenarios where users frequently encountered physical barriers. By filtering inappropriate messages, the system allowed user habituation to decay, making subsequent nudges more effective.
- Engagement Preservation: The hybrid approach prevented user "dropout" by reducing annoyance, leading to higher cumulative step counts over time.
- Prompt Sensitivity: The inclusion of interaction history (H) and reasoning questions (Q) was critical for optimal performance compared to simpler prompt structures.
Conclusion and Future Work
LLM4TS demonstrates a viable path for creating "smarter" health apps that respect user context through natural language. While the current study relies on simulations, future work will focus on real-world human trials and the integration of speech-to-text interfaces to reduce user burden. The ability to bridge the gap between structured RL and unstructured human language represents a significant step forward for personalized digital health.
Summary updated