rellm logo

rellm

r2d4/rellm

Exact structure out of any language model completion

GraphCanon updated 5d · GitHub synced 5d

511 stars24 forksLast push 3y Python MIT

Decision brief

rellm is a Python tool that guarantees structured outputs from language model completions by leveraging the Hugging Face Transformers library.

Good fit when

  • - When you require precise and exact structure in output data generated from any language model, utilizing rellm can ensure consistency.
  • - If your application needs to process text through Hugging Face's models and demands that outputs strictly adhere to specific formats, rellm is ideal.

Avoid when

  • - Avoid using rellm if you are not working with the Hugging Face Transformers library or do not need structured output formats.
  • - If your project can tolerate some level of unstructured or less rigidly formatted outputs from language models, other solutions might be more appropriate.

Observed Jul 12, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Dormant (1100d since push)
As of 5d
Provenance
Not a fork · Personal account
As of 5d
Security (OSV)
No lockfile
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

pip install rellm
PyPI

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

rellm is a tool that ensures structured outputs from language model completions using the Hugging Face Transformers library.

Capability facts

Languages
python

Source: github.language+pyproject.toml · Aug 15, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

Python runtimePython

Source: README excerpt (regex_v1, Aug 15, 2026)

```python import regex
Source link

Tags

README

Installation

pip install rellm

The preliminary results are interesting -- even for small models, constraining the token space with ReLLM can improve the quality of the completions. Not to mention the ability to more easily parse the output programmatically. Take a look at some of the examples. For an example of parsing a context-free grammar (like JSON) with ReLLM, see r2d4/parserllm.

import regex
from transformers import AutoModelForCausalLM, AutoTokenizer

from rellm import complete_re

model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")

prompt = "ReLLM, the best way to get structured data out of LLMs, is an acronym for "
pattern = regex.compile(r'Re[a-z]+ L[a-z]+ L[a-z]+ M[a-z]+')
output = complete_re(tokenizer=tokenizer, 
                     model=model, 
                     prompt=prompt,
                     pattern=pattern,
                     do_sample=True,
                     max_new_tokens=80)
print(output)
> Realized Logistic Logistics Model

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.