mellea.backends.formatter
Abstract interfaces for Formatters.
Classes
Formatter
A Formatter converts Component
s into strings and parses ModelOutputThunk
s into Component
s (or CBlock
s).
Methods:
print
parse
to_chat_messages
TemplateFormatter
Formatter that uses jinja2 templates.
Methods:
parse
print
FormatterBackend
FormatterBackend
s support legacy model types.
The mellea
library was designed to support generative computing with spanned attention over generative programming primitives.
In the ideal world, context management is handled via span scope-relations and all generative programming primitives are baked into the model via fine-tuning.
I.e., the model’s instruction tuning is done in terms of generative programming primitives, and the model is then prompted with the same set of templates that were used for that tuning.
Today, most models do not yet support spans and even those that do are not properly tuned to leverage generative programming primitives.
The mellea
library supports these legacy models primarily through prompt engineering surfaced via FormatterBackends
.
A FormatterBackend
is a backend that uses hand-engineered prompts for rendering generative programming primitives to a model and parsing responses from the model back into mellea
.
By default, a FormatterBackend
uses jinja2 templates for pretty-printing, and relies on the user’s ad-hoc logic for parsing.