DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to force model output to match a JSON schema with Deep Infer

Use structured outputs to limit generation to a regex, JSON schema, or EBNF grammar.

Who it is forA developer building a pipeline that needs the model to return machine-readable JSON with a fixed shape.

The problemFree-form model text is hard to parse, and retries on malformed output waste time.

The outcomeGenerated text that follows the schema you pass in, ready for a parser.

What you need first

  • Linux with GCC 13.0 or newer and Python 3.12
  • NVIDIA SM100 GPU with CUDA 13, or Huawei Ascend 950 NPU with CANN 9.2
  • Access to the deepseek-ai/DeepSeek-V4.1-Flash-1017 checkpoint on Hugging Face, or a local copy
  • Enough disk space and memory for the checkpoint and the build

Steps

  1. Open examples/_structured_output.py and read how it builds the constraint.
  2. Define your JSON schema as a Python dict.
  3. Pass so_args={"schema_type": ..., "schema": ...} to SamplingParams with your schema type and schema.
  4. Run the offline example with your prompt and parse the returned text as JSON.

Prompt for your agent

In the DeepInfer repo, follow examples/_structured_output.py to constrain generation with so_args for the schema in <schema file>. Output the generated JSON for the prompt <prompt>. Verify that the output parses with json.loads and matches the schema's required keys.

Caveat. The README does not list which schema types are supported beyond regex, JSON schema, and EBNF grammar, so check the example file before you rely on a specific type.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for deepseek-ai/DeepInfer and "Force model output to match a JSON schema"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer