uv sync --all-extras --all-groups), familiarity with the core concepts.
Mellea is designed to be extended at every layer. You can add new Requirements,
Components, Sampling Strategies, and Backends without modifying the core library.
Three contribution pathways
Choose the pathway that fits the scope of your work:| Pathway | When to use |
|---|---|
| Core repository | General-purpose additions that benefit all users — open an issue first to discuss placement |
Your own repo (mellea- prefix) | Application-specific or domain-specific libraries |
| mellea-contribs | Experimental or specialized components not yet ready for the standard library |
Note: For general-purpose Components, Requirements, or Sampling Strategies, open an issue before submitting a PR. This avoids duplication and ensures the addition lands in the right place (standard library vs. mellea-contribs).
Custom requirements
ARequirement validates a generation against a
criterion. You can provide a Python function for deterministic checks, or rely on
LLM-as-a-Judge for semantic validation.
Deterministic requirement
Pass avalidation_fn that receives a Context and returns a ValidationResult:
LLM-as-a-Judge requirement
Omitvalidation_fn to use LLM-as-a-Judge. Mellea sends the requirement
description to the model and interprets a “yes”/“no” answer:
Custom output-to-bool mapping
Supplyoutput_to_bool to change how the model’s response is interpreted:
Custom components
AComponent is a composite data structure that an LLM
can read and write. Implement the Component protocol by providing parts,
format_for_llm, and _parse:
Custom sampling strategies
ASamplingStrategy controls how Mellea
generates and validates outputs — for example, rejection sampling, best-of-n, or
beam search. Subclass SamplingStrategy and implement sample:
Custom backends
ABackend connects Mellea to an inference provider.
Subclass the abstract Backend class from mellea.core.backend and implement
the two abstract methods:
Backend abstract interface is documented in the
API reference.
Note: Production backends handle async streaming, tokenization, and error
recovery. Study an existing backend in mellea/backends/ before implementing
a provider integration.
Community contributions via mellea-contribs
mellea-contribs is the home for experimental and specialized extensions that are not yet part of the standard library. It is the right place for:- Domain-specific Components (legal, medical, code review, etc.)
- Experimental Sampling Strategies under active research
- Backend integrations for niche or self-hosted providers
- Open an issue on mellea-contribs describing your extension.
- Fork the repository and create a branch.
- Follow the coding standards from the contributing guide.
- Open a pull request referencing the issue.
See also: Custom Components, Write Custom Verifiers, Inference-Time Scaling