Technology · Agentic → Structured Output · Open Source · wiki:deep

LMQL

LMQL (Language Model Query Language) is a programming language for LLMs — a Python superset where top-level query strings prompt models, template variables are completed under where constraints (stopping phrases, token/character rules, datatypes), and control flow/decoding (argmax, sample, beam, best_k) are first-class. Supports OpenAI/Azure and Hugging Face Transformers, async batching, playground IDE, and VS Code tooling. Apache-2.0 (ETH SRI). Primary map push ~2025-05 — treat as research-strong; verify maintenance before production lock.

Why it matters here

Useful when agents need declarative constraints and scripted prompting beyond simple JSON schemas. Prefer Instructor for day-to-day Pydantic extraction; prefer Outlines/Guidance for active structured-generation stacks with clearer recent momentum.

How it works

Author .lmql or embedded programs: prompt strings with [VARS], attach where constraints, branch with Python control flow, run via lmql run / playground / Python API. Local HF models may need lmql serve-model.

  1. Install (pip install lmql; GPU extras as needed).
  2. Write query programs with constraints.
  3. Execute via CLI, playground, or library.
  4. Consume constrained outputs in surrounding Python.

Related: guidance · instructor · outlines · topics/12-central-nervous-system

Flow

Scroll inside the canvas to pan

When to reach for it

  • Use when: researching constraint-guided LLM programming with rich decoding.
  • Skip when: you need a maintained app-default extractor (instructor) or engine grammars (outlines).
  • Prefer instead: Instructor/Outlines for production-shaped installs unless LMQL’s language is the point.

Limits

  • Ecosystem momentum: quieter than Instructor/Outlines — confirm release cadence.
  • Ops surface: playground/Node, serve-model, API creds.
  • Not the ledger or policy gate.
  • Python 3.10 focus in docs — pin carefully.

Linked from

What we checked

Claims below are backed by science sources on disk.

Language / constraints role

eth-sri/lmql · MODERATE

A language for constraint-guided and efficient LLM programming.

Paper / research framing

Prompting Is Programming: A Query Language for Large Language Models · MODERATE

LMQL is a programming language for large language models (LLMs) based on a superset of Python.

Contrast vs Outlines

Outlines contrast · MODERATE

LMQL offers a novel way of interweaving traditional programming with the ability to call LLMs in your code.

In this research stack

Features and peers linked from the catalog map — not a second product surface.

Features it supports

Same cell

Stack

Document management

No DM vendor crosswalk edges yet.

Source

Primary repo github.com/eth-sri/lmql · Open Source

technologies/lmql/README.md

Research inventory

9 tags · 7 out · 8 in · 3 artifacts · 1 gaps · 27 corpus docs

Catalog tags

landscape.layer
Agentic
landscape.subcategory
Structured Output
license_tag
Open Source
maps.dm
absent
maps.features
4
one_liner
Agentic
review.depth
science
slug
lmql
title
LMQL

Artifacts

  • dm_map · absent
  • features_map · present · technologies/lmql/features.md
  • readme · present · technologies/lmql/README.md

Out · alternative_to

Out · maps_to

In · alternative_to

In · in_stack

In · maps_to

Corpus tags

category
Agentic → Structured Output
dedication
open-source
feature
closed-execution-loop
outcome-verification
testing-debugging-optimization
wt-intelligence
kind
map_edge
tech_features
tech_quote
tech_readme
tech_science_source
tech_section
needs_deepen
false
quality
ok
section
Evidence
Features map
GitHub map
How it works
Limits & failure modes
Links
Scientific notes
What it is
When to use / skip
Why it matters here
slug
lmql
source_id
lmql-github
lmql-paper
outlines-contrast
technology
lmql

Corpus documents (27)

map_edge · 4

  • lmql → closed-execution-loop
  • lmql → outcome-verification
  • lmql → testing-debugging-optimization
  • lmql → wt-intelligence

tech_features · 1

  • LMQL · features

tech_quote · 8

  • LMQL · lmql-github
  • LMQL · lmql-github
  • LMQL · lmql-github
  • LMQL · lmql-paper
  • LMQL · lmql-paper
  • LMQL · lmql-paper
  • LMQL · outlines-contrast
  • LMQL · outlines-contrast

tech_readme · 1

  • LMQL

tech_science_source · 3

  • LMQL · lmql-github
  • LMQL · lmql-paper
  • LMQL · outlines-contrast

tech_section · 10

  • LMQL · Evidence
  • LMQL · Features map
  • LMQL · GitHub map
  • LMQL · How it works
  • LMQL · Limits & failure modes
  • LMQL · Links
  • LMQL · Scientific notes
  • LMQL · What it is
  • … +2 more