OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Rellm

Rellm is an MIT-licensed Python library that constrains language-model completions with regular expressions. It checks possible tokens against a partial pattern and masks logits for tokens that would violate it, supporting structured strings, semantic formats and sentence templates.

Independent OpenViST project profile, based on linked sources.

Rellm — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Rellm when a Transformers-based Python application needs generation constrained to a regex pattern, especially when downstream code expects a particular output shape.

Who it is for

  • Python developers building language-model applications that need pattern-shaped output.
  • Developers using Hugging Face Transformers who want to constrain generation before parsing results.

Documented uses

  • Constrain a completion to a JSON-like or other specified syntactic pattern.
  • Generate a value matching a regex shape, such as a date or number.
  • Fill a sentence template while limiting the completion to a pattern.
  • Restrict generated choices to a small set such as “Yes” or “No.”
Before you choose

Requirements & limits

The repository is public and identifies the project as MIT-licensed. The documented installation command is `pip install rellm`.

  • Rellm constrains token choices during generation by testing completions against a partial regex.
  • The README demonstrates use with Hugging Face Transformers and GPT-2.
  • Matching a pattern controls form, not whether the resulting value is factually correct or meaningful.
  • The README references a separate hosted API as an alternative delivery model.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install Rellm and prepare a Transformers example

Set up the documented Python example inputs for regex-constrained generation.

Before you start

  • Python environment
  • Hugging Face Transformers model and tokenizer
  • The regex package

Steps

  1. Install the library with the command below.

    Documented command
    pip install rellm
  2. Load a causal language model and tokenizer with Transformers.

  3. Write a prompt and compile the desired pattern with regex.compile.

  4. Import complete_re from rellm and provide the tokenizer, model, prompt and pattern.

Expected outcome

The documented example is prepared to call Rellm for a completion constrained by the supplied regex.

Guide limitations

  • The README's example includes generation parameters, but this guide does not verify execution.
  • A regex-conforming output does not by itself establish factual or semantic correctness.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
17 October 2026
Original website title
r2d4/rellm · Official homepage title · retained in its source language

Related options

Thiggle Regex Completion API — The Rellm README points to this separate hosted regex-completion API for readers seeking a hosted version.