Published2025LLMs · NLP · Time-series databases · Llama 3.1
Natural-Language Queries for InfluxDB
A hybrid natural-language interface to a time-series database: deterministic rule-based query generation, with a large language model only for interpreting results.
Time-series databases such as InfluxDB require specialised query languages, which keeps non-specialists away from their data. Large language models can translate questions into queries, but may hallucinate — unacceptable when generating database commands.
The architecture therefore separates two tasks. For query generation, a SpaCy rule-based Matcher extracts measurement and field entities into a JSON "semantic contract", which a template-based generator turns into a valid Flux query — deterministic and protected against Flux injection. For interpretation, query results are converted from CSV into a Pandas DataFrame, summarised statistically and passed with the original question to Llama 3.1 running locally via Ollama, which writes the natural-language answer. The prototype runs as FastAPI, InfluxDB and Ollama services in Docker.
The prototype handled differently phrased questions about the same metrics and, by design, rejected questions outside its vocabulary with a clear error rather than guessing — a property valued in critical monitoring. Future work adds synonym handling, aggregation functions and dialogue context. Published in the ICEEECS 2025 proceedings (SCITEPRESS).
0
LLM involvement in query generation
Llama 3.1
local result interpretation
Further questions
KAYAI can explain this project in more detail, from motivation to methodology.
Ask KAYAINext project
Resilient Sensor Fusion via Hybrid Trust