Skip to main content
Prerequisites: Mellea installed (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:
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

A Requirement 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 a validation_fn that receives a Context and returns a ValidationResult:

LLM-as-a-Judge requirement

Omit validation_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

Supply output_to_bool to change how the model’s response is interpreted:
For deeper validation patterns, see Write Custom Verifiers.

Custom components

A Component is a composite data structure that an LLM can read and write. Implement the Component protocol by providing parts, format_for_llm, and _parse:
For a full walkthrough of the Component protocol and templating system, see Custom Components.

Custom sampling strategies

A SamplingStrategy controls how Mellea generates and validates outputs — for example, rejection sampling, best-of-n, or beam search. Subclass SamplingStrategy and implement sample:
For built-in strategies and advanced patterns, see Inference-Time Scaling.

Custom backends

A Backend connects Mellea to an inference provider. Subclass the abstract Backend class from mellea.core.backend and implement the two abstract methods:
The full 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
To contribute:
  1. Open an issue on mellea-contribs describing your extension.
  2. Fork the repository and create a branch.
  3. Follow the coding standards from the contributing guide.
  4. Open a pull request referencing the issue.
If a contribution in mellea-contribs matures and proves broadly useful, it can graduate to the standard library via an issue in the core repository.
See also: Custom Components, Write Custom Verifiers, Inference-Time Scaling