The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
ConstraintDSL
A lightweight domain-specific language for representing JSON Schema constraints, optimized for small language model consumption.
Why ConstraintDSL?
Raw JSON Schema is a hierarchical, nested format designed for validation — not for language model reasoning. ConstraintDSL flattens schema constraints into explicit, line-oriented statements that small models (200M–1.5B parameters) can parse and follow reliably.
Empirical evidence
| Schema representation | Schema success (unseen schemas) |
|---|---|
| Raw JSON Schema | 55.0% |
| ConstraintDSL | 96.3% |
| ConstraintDSL (random field names) | 91.9% |
Same model (CodeT5+ 220M), same training procedure, same data volume. Only the schema representation changed.
Specification v1
Field declaration
FIELD <path> TYPE <type> [VALUES <v1|v2|...>] REQUIRED <yes|no>
Path notation
- Flat:
FIELD priority TYPE string REQUIRED yes - Nested:
FIELD customer.name TYPE string REQUIRED yes - Array of primitives:
FIELD tags[] TYPE string REQUIRED no - Array of objects:
FIELD items[].sku TYPE string REQUIRED yes
Types
string,integer,number,boolean,nullstring_email,string_date-time,string_uri(format variants)stringwithVALUESclause for enums
Tool declaration
TOOL <name>
ARG <path> TYPE <type> [VALUES <v1|v2|...>] REQUIRED <yes|no>
Examples
Simple object
JSON Schema:
{"type":"object","properties":{"priority":{"type":"string","enum":["low","medium","high"]},"description":{"type":"string"}},"required":["priority"]}
ConstraintDSL:
FIELD priority TYPE string VALUES low|medium|high REQUIRED yes
FIELD description TYPE string REQUIRED no
Nested object
FIELD customer.name TYPE string REQUIRED yes
FIELD customer.age TYPE integer REQUIRED no
FIELD ticket.priority TYPE string VALUES low|medium|high REQUIRED yes
OpenAI tool
TOOL create_ticket
ARG priority TYPE string VALUES low|medium|high REQUIRED yes
ARG description TYPE string REQUIRED yes
ARG customer_id TYPE integer REQUIRED no
MCP tool
TOOL read_sensor
ARG sensor_id TYPE string REQUIRED yes
ARG metric TYPE string VALUES temperature|humidity|pressure REQUIRED yes
Input format for models
TASK repair_structured_output
SPEC
FIELD priority TYPE string VALUES low|medium|high REQUIRED yes
FIELD description TYPE string REQUIRED yes
BROKEN_OUTPUT
{"priority":"urgent"}
Target output:
{"priority":"high","description":""}
Source compilers
Compilers are provided for:
- JSON Schema → ConstraintDSL
- OpenAI function/tool definitions → ConstraintDSL
- Anthropic tool definitions → ConstraintDSL
- MCP tool definitions → ConstraintDSL
See schema_compiler.py for the reference implementation.
Ablation results
| DSL variant | Schema success |
|---|---|
| Full DSL | 96.3% |
| Shuffled field names | 73.4% |
| Shuffled enum values | 89.8% |
| Shuffled required flags | 93.2% |
| Field names only | 72.2% |
| No DSL | 78.4% |
Field names are the most critical component (-22.9pp when shuffled), followed by enum values (-6.5pp) and required flags (-3.1pp).
Known limitations
ConstraintDSL significantly improves structural reasoning in small models, but does not fully eliminate lexical bias. Models trained with ConstraintDSL may still substitute field names with semantically similar alternatives from their training vocabulary (e.g., action → active). This is a model-level limitation, not a DSL limitation — the DSL provides correct field names, but the model may not faithfully reproduce them.
License
Apache-2.0
Citation
@software{structfix_constraint_dsl,
title = {ConstraintDSL: Schema Representation for Small Language Models},
author = {Ottema},
year = {2026},
url = {https://huggingface.co/datasets/ottema/constraint-dsl}
}
- Downloads last month
- 26