eth-sri

lmql: Program Large Language Models with Python

LMQL is a Python-superset programming language for combining ordinary code with large language model queries. It adds constrained generation, decoding strategies, and runtime optimizations, with support for OpenAI, Azure OpenAI, and Hugging Face Transformers models.

InactivePythonApache-2.0LLMProgrammingGenerative AI
Stars
4.2k
Forks
222
Stars, last 30 days
+5
Last commit
1.4 years ago
Contributors
35

Our take

Inactiveno commits in over a year

Health score

26/100

How it is scored
Activity
19
Community
45
Issues
21
Pull requests
20

+5 stars in the last 30 days

LMQL offers a distinctive Python-like way to write controlled LLM programs, but its inactive maintenance and concentrated contributor activity make it a cautious choice for new production dependencies.

Good fit if

  • You want to prototype or study constrained LLM programming with Python syntax.
  • Your workflow can use OpenAI, Azure OpenAI, or Hugging Face Transformers models, and you can validate the project against your needs.
  • You are comfortable assessing an Apache-2.0 project whose latest release is more than a year old and whose recent repository activity has stopped.

Look elsewhere if

  • You need an actively maintained dependency: the repository reports no commits or releases in over a year, and no recent issue closures or merged pull requests.
  • Your team needs broad, distributed maintainer ownership, since most measured contributor activity is concentrated in one person.
  • You need a lightweight setup without Python, or expect to use the Playground without installing its Node.js requirement.
All health signals
Last commit2025-05-22 (1.4 years ago)
Commits, last 90 days0
Releases, last 12 months0 (latest v0.7.3, 2023-10-14)
Contributors35 (top contributor: 85% of commits)
Issues closed, last 90 days0
Pull requests merged, last 90 days0
Project age3 years

Checked on 2026-11-02 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

4,228

Forks

223

Change since Nov 17, 2026: 0 stars·0 forks

Overview

LMQL is a programming language built on a superset of Python for combining ordinary program logic with large language model queries. Rather than treating prompts as separate templates, it lets developers place model calls in Python-like code and apply constraints to generated text. It supports OpenAI and Azure OpenAI services as well as Hugging Face Transformers models.

The approach is aimed at developers building LLM workflows that need more control than a basic prompt-and-response call provides. Constraints, branching logic, and decoding strategies can help shape outputs and coordinate multiple model interactions in one program.

Key Features

  • Write model queries as top-level strings within Python-like programs, with variables captured from generated text.
  • Apply constraints to outputs, including stopping conditions, length, and datatype-related constraints.
  • Combine LLM calls with Python control flow, including conditionals and loops.
  • Choose decoding approaches such as sampling, argmax, beam search, and best_k.
  • Run queries synchronously or asynchronously, with cross-query batching support.
  • Use OpenAI, Azure OpenAI, or Hugging Face Transformers models.
  • Access a browser-based Playground IDE, command-line execution, and streaming output interfaces.

Use Cases

  • LLM application developers can build multi-step prompting workflows with ordinary program logic and model-generated intermediate results.
  • Teams needing structured or constrained responses can express output rules as part of the query rather than relying only on prompt instructions.
  • Researchers can experiment with alternative decoding strategies and branching generation in language-model programs.
  • Developers already using OpenAI or Hugging Face models can use LMQL to organize model interactions and run concurrent queries.

What you need

Detected in the repository

  • Python (from setup.py)
  • Automated checks on GitHub Actions

License in plain words

Apache-2.0permissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the license, the NOTICE file and a note of your changes
  • Share your changes: no
  • Includes an explicit patent grant from the contributors:

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install with Python 3.10:

pip install lmql

See the README and documentation for model configuration and usage details. Local Hugging Face model support requires a GPU-enabled PyTorch setup; the Playground also requires Node.js.

Considerations

Repository health is marked inactive: there have been no commits in over a year, no releases in over a year, and no measured recent issue closures or pull-request merges. Although the project has multiple contributors, measured contribution is heavily concentrated in one person, which may affect maintenance continuity. The README also notes that the development branch is not continuously tested and may be less stable than the PyPI release. Local Hugging Face inference adds GPU-enabled PyTorch setup requirements, while running the Playground requires Node.js. The project uses the Apache-2.0 license, so review its terms when incorporating or distributing it.

Found this useful?

Share it with someone who would like lmql.

Comparisons