Skip to content

Generative stub prompt template underperforms on smaller models #1476

Closed

Description

@psschwei

Summary

The default prompt template for @generative stubs uses a "pretend you are a function" framing (imitate the output of this Python function). Smaller Granite models (4.1-3B and below) have trouble following it. In hands-on use, rewriting the template to a plain "reply in JSON formatted as {X}" instruction produced markedly better results at those sizes.

We should benchmark the current template against simpler variants across model sizes and update the default if the results hold, likely as a per-model-family template rather than one global default (the template system already supports per-family overrides).

Note: the output schema is already enforced via structured output, so this isabout prompt framing helping smaller models produce the right content, not about malformed JSON.

Encountered while using @generative to extract a list of requirements that were then verified with the requirement-check adapter (aLoRA).

Open question: per-call template arg?

We could expose a template override on the stub, but making that the primary fix cuts against the @generative premise of "write a normal function, we handle the prompting." Better default (or per-family default) is the real fix; a per-call override, if added, should be a documented escape hatch only.

Acceptance criteria

  • Eval comparing the current template against direct variants across at least two model sizes.
  • Default template updated (globally or per family) based on results.
  • Any per-call override documented as an advanced escape hatch, not the recommended path.

Starting points

  • mellea/stdlib/components/genstub.py (@generative)
  • mellea/templates/prompts/default/GenerativeStub.jinja2

Activity

  1. added this to the Release v0.8.0 milestone on Jul 30, 2026
  2. added
    enhancement
    p1
    needs-design
    area/component
    on Jul 30, 2026
  3. planetf1 commented on Aug 11, 2026

    @planetf1
    Contributor

    One prompt-legibility detail for whoever picks up the template redesign, since it interacts with small-model behaviour specifically.

    #1509 fixes #1529, where a @generative stub with a TYPE_CHECKING-only return annotation failed at decoration time. The fix leaves an unresolvable return annotation as its postponed string, so describe_function renders it quoted:

    def estimate_price(item: str) -> 'Decimal':
    

    That was a deliberate choice over the alternative of omitting the return type entirely — a quoted type still names it, and the pre-#1504 behaviour had quotes on every annotation, so this is a strict subset of a state the project shipped for a long time.

    The residual risk belongs here rather than in #1509: a smaller model may read -> 'Decimal' as "returns a string containing Decimal" rather than as a forward reference. Larger models handle the distinction; that gap is exactly this issue's subject.

    Worth noting it only affects stubs whose return type is TYPE_CHECKING-only or forward-referenced, not the common case. Rendering it unquoted is not cleanly reachable — inspect.formatannotation always quotes a string annotation, and forcing a bare name needs a synthetic type that falsely claims __module__ = "builtins". If the redesign moves to building the signature text explicitly rather than via str(inspect.Signature), that constraint disappears and the return type could be rendered bare.

  4. added
    triage/accepted
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/componentenhancementneeds-designp1triage/accepted

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions