Metadata-Constrained Generation: A Neurosymbolic Architecture for Reliable Natural Language Queries over Statistical Microdata
Conference
66th ISI World Statistics Congress
Format: WSC 2027: IPS Abstract
Keywords: chatbots, generative ai, large language models, metadata, microdata
Abstract
AI agents that query statistical microdata through natural language can generate plausible but incorrect results by inventing variables or categories, misinterpreting geographic references, misusing variables, or incorrectly reproducing query outputs. Such errors undermine the reliability and trustworthiness of official statistics, particularly when users cannot identify or trace their origin.
We propose Metadata-Constrained Generation (MCG), a neurosymbolic architecture that combines the semantic interpretation capabilities of large language models with explicit, metadata-driven constraints and deterministic statistical processing. Rather than relying on metadata solely as contextual information, MCG uses them to define and validate the permissible outputs of the language model.
The proposed method decomposes natural language queries into bounded tasks with predefined output types. These tasks progressively narrow the space of valid operations by addressing three fundamental questions: where (geographic scope), who (target population), and what (statistical computation). Based on these decisions, the model constructs a structured query specification using a domain-specific language (DSL) designed to represent statistical tabulations. A metadata-based validator verifies the specification, while a separate reviewer assesses its semantic consistency with the original question. A deterministic translator subsequently converts the validated specification into SQL, consistently applying source-specific statistical rules, including expansion factors, population universes, and missing-value treatment.
We implement MCG in Censobot, an AI agent that queries sample microdata from Mexico's 2020 Population and Housing Census. The implementation uses locally deployable language models and distinguishes the architectural requirements of the proposed method from practical adaptations to model capabilities.
Beyond the architecture itself, the implementation reveals important limitations in statistical metadata originally designed for human experts. These include implicit geographic assumptions, insufficient distinctions between quantitative and categorical variables, ambiguous variable definitions across tables, and undocumented relationships between variables. Addressing these limitations requires explicitly representing knowledge traditionally supplied by statistical specialists.
The proposed approach provides a framework for developing more reliable, traceable, and reproducible natural language interfaces to statistical microdata. It also highlights a broader implication for AI-readiness in official statistics: enabling trustworthy AI-based access to statistical information requires not only capable language models, but also metadata sufficiently explicit and structured to support automated interpretation, validation, and execution.
Figures/Tables
MCG_workflow_EN