mudler/LocalAI · error · ValueError
Unknown builtin reward function '{name}'. Available: {availa
Error message
Unknown builtin reward function '{name}'. Available: {available} What it means
Reward specs with type 'builtin' must name a function in BUILTIN_REGISTRY (format_reward, reasoning_accuracy_reward, length_reward, etc.). Unknown names get a ValueError enumerating the available builtins, which acts as discoverable inline documentation of the registry.
Source
Thrown at backend/python/trl/reward_functions.py:222
"""
if isinstance(specs_json, str):
specs = json.loads(specs_json)
else:
specs = specs_json
if not isinstance(specs, list):
raise ValueError("reward_funcs must be a JSON array of reward function specs")
reward_funcs = []
for spec in specs:
spec_type = spec.get("type", "builtin")
name = spec.get("name", "")
params = spec.get("params", {})
if spec_type == "builtin":
if name not in BUILTIN_REGISTRY:
available = ", ".join(sorted(BUILTIN_REGISTRY.keys()))
raise ValueError(
f"Unknown builtin reward function '{name}'. Available: {available}"
)
func = BUILTIN_REGISTRY[name]
if params:
# Convert string params to appropriate types
typed_params = {}
for k, v in params.items():
try:
typed_params[k] = int(v)
except (ValueError, TypeError):
try:
typed_params[k] = float(v)
except (ValueError, TypeError):
typed_params[k] = v
func = functools.partial(func, **typed_params)
reward_funcs.append(func)
elif spec_type == "inline":View on GitHub (pinned to 44413a9d06)
Solutions
- Read the 'Available: ...' list in the error message and use one of those exact names.
- Fix casing/underscores to match the registry (e.g. 'format_reward').
- If you truly need custom logic, switch the spec to type 'inline' (requires the opt-in env var) instead of a nonexistent builtin.
Example fix
# before
{"type": "builtin", "name": "format-reward"}
# after
{"type": "builtin", "name": "format_reward"} Defensive patterns
Strategy: validation
Validate before calling
BUILTIN_NAMES = {"format_reward", "reasoning_accuracy_reward", "length_reward"} # sync with registry
def builtin_known(name: str) -> bool:
return name in BUILTIN_NAMES Try / catch
try:
build_reward_functions(specs)
except ValueError as e:
if "Available:" in str(e):
# parse the names from the message and suggest the closest
raise ConfigError(str(e)) from e
raise Prevention
- Fetch/track BUILTIN_REGISTRY keys as part of client configuration.
- Use difflib.get_close_matches client-side to catch typos before sending.
- Pin backend and client versions together.
When it happens
Trigger: spec name='accuracy' (not registered); typos like 'format-reward' or 'Format_Reward'; referencing a builtin added in a newer backend version.
Common situations: Guessing builtin names instead of checking the registry; version skew between backend and client docs; renaming drift after upgrading.
Related errors
- reward_funcs must be a JSON array of reward function specs
- Inline reward function '{name}' has no code
- Unknown reward function type '{spec_type}'. Use 'builtin' or
- GRPO requires at least one reward function. Specify reward_f
- Unsupported training method: {training_method}. Supported: s
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/9d9ae0d02434fd68.
Report an issue: GitHub.