Abstract: Accurately measuring building occupancy is essential for optimizing Heating, Ventilation, and Air Conditioning control and enhancing energy efficiency in smart buildings. However, existing machine learning models often struggle to generalize across diverse occupancy patterns with limited data. Recent advances in large language models present new opportunities by leveraging contextual reasoning and few-shot learning to enhance performance in smart building systems. This study proposes an LLM-based framework for real-time indoor occupancy measurement, incorporating few-shot learning, chain-of-thought reasoning, and in-context learning techniques. This study explores how LLMs can enable accurate and data-efficient occupancy measurement for indoor occupant-centric control and energy optimization. We evaluate LLMs’ performance against traditional models across two case studies: binary occupancy detection and multi-level occupancy estimation. Experiments are conducted using two real-world datasets collected from office buildings in China and Singapore. Results indicate that LLMs consistently outperform traditional models across various time intervals and training/testing configurations. Under a 4-day training/1-day testing setup, DeepSeek-R1 achieves 95.92% accuracy and a 96.1% F1-score, while Gemini-Pro attains 94.14% accuracy in multi-level estimation with only 1 day of training. An occupant-centric control (OCC) simulation and ablation study were implemented in EnergyPlus with real data to improve energy efficiency and comfort. These findings highlight the adaptability and robustness of LLMs, positioning them as promising tools for real-time occupancy measurement in smart office environments. Code and implementation details are available at: https://github.com/kailaisun/LLM-occupancy.
Loading