Natural Language based Context Modeling and Reasoning with LLMs: A Tutorial

Haoyi Xiong, Jiang Bian, Sijia Yang, Xiaofei Zhang, Linghe Kong, Daqing ZhangarXiv 2023

Abstract

Large language models (LLMs) have surged in popularity since 2018, two decades after the introduction of context-awareness into computing systems. By considering the situations of ubiquitous devices, users, and societies, context-aware computing has enabled innovative applications like assisted living and location-based services. Traditionally, technologies like Ontology and OWL were used for context modeling and reasoning. Recently, LLMs have enabled a new paradigm: modeling contexts using natural language and performing reasoning through interaction with models like GPT-4. This tutorial introduces LLM-driven Context-aware Computing (LCaC), utilizing text, prompts, and autonomous agents (AutoAgents) to foster context-awareness without model fine-tuning.

The Evolution of Context-Aware Computing

For over two decades, the primary challenge in context-aware computing has been creating systems that sense and respond to user situations (location, time, activity) effectively. Historically, the field relied on "Widget-centric" or "Ontology-based" models. These traditional methods, while foundational, often depend on rigid data structures and complex Web Ontology Languages (OWL) that are difficult to scale and require significant manual engineering.

Comparison of context-aware computing paradigms across interfacing, reasoning, and modeling layers.

The LCaC paradigm addresses these limitations by leveraging the massive world knowledge and reasoning capabilities of LLMs to understand sensor data and plan complex actions without hard-coded rules.

The LCaC Architecture

The core of the LCaC paradigm is a loop between the digital and physical worlds, facilitated by AutoAgents and frameworks like LangChain.

The LCaC architecture showing the interaction between users, sensors, AutoAgents, and LLMs.

The architecture operates through four main stages:

  1. Context Modeling: Sensor data is translated into descriptive natural language text (e.g., "The temperature is 15°C").
  2. AutoAgents: These act as the system's "brain," wrapping textual context and user requests into prompt templates.
  3. Context Reasoning: LLMs like GPT-4 generate multi-step action plans based on the prompts.
  4. Interfacing & Execution: The AutoAgent executes the plan, often using Just-in-Time (JIT) code to command physical actuators.

Key Insights and Showcases

The tutorial demonstrates LCaC through two qualitative showcases:

  • Assisted Living: A mobile robot correctly identifies sequences of rooms and objects (e.g., aspirin, water) to deliver medication based on text descriptions of an apartment layout.
  • Personalized Trip Planning: A system integrates "soft" user preferences (e.g., a love for soccer) with "hard" constraints like flight schedules to create a custom itinerary.

A significant insight is that Natural Language serves as a Universal Interface, acting as flexible middleware between raw sensors and complex social preferences. Furthermore, LLMs can act as Zero-Shot Planners, generating logically sound sequences without specific robotics training. For these applications, a low "temperature" setting is crucial to ensure deterministic and predictable behavior when controlling physical hardware.

Challenges and Future Directions

Despite its promise, LCaC faces several hurdles:

  • The Token Crisis: Long-term sensor data can exceed the context window limits of current LLMs, necessitating better memory management strategies.
  • Non-Determinism: LLMs may produce inconsistent results even at low temperature settings, which is a concern for physical hardware control.
  • Safety and Hallucinations: The risk of an LLM hallucinating impossible or dangerous physical actions remains a hurdle for safety-critical applications like healthcare.

Future work points toward Multi-modal Foundation Models that can process vision and audio context directly, further reducing the reliance on intermediate text descriptions of sensor data.

Summary updated

BibTeX
@misc{xiong2023natural,
  author = {Haoyi Xiong and Jiang Bian and Sijia Yang and Xiaofei Zhang and Linghe Kong and Daqing Zhang},
  title = {{Natural Language based Context Modeling and Reasoning with LLMs: A Tutorial}},
  year = {2023},
  eprint = {2309.15074},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.15074},
}
Figure