aws-samples / aws-samples/amazon-bedrock-samples

Missing example: structured output with Custom Model Import (CMI)

Open
#711 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.5k
Forks
734
Avg merge
1d 6h
Merged PRs (30d)
4

Description

## Problem
The `custom-models/` directory has examples for fine-tuning, distillation, and importing models, but nothing showing how to use Bedrock's structured output (`response_format` with a JSON schema) against a CMI model.

CMI supports `OpenAIChatCompletion`, `OpenAICompletion`, and `BedrockCompletion` request shapes, and the `response_format` parameter varies between them — this is a common source of confusion when adapting foundation-model code to imported models.

## Proposal
Add a notebook under `custom-models/` that:
- Demonstrates schema-constrained generation against a CMI model via `InvokeModel` using `OpenAIChatCompletion`.
- Uses Pydantic to define the schema as a single source of truth for both the `response_format` constraint and downstream validation.
- Shows the contrast vs. prompted-JSON (baseline) so readers understand what schema enforcement buys them.

## References
- [Structured outputs for imported models](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-model-import-advanced-features.html#structured-outputs)
- [Invoke an imported model](https://docs.aws.amazon.com/bedrock/latest/userguide/invoke-imported-model.html)

PR #710 implements this.

Contributor guide

Open the contributing guide

Research direction

Start in the custom-models/ directory and read the linked AWS references on structured outputs for imported models and invoking an imported model. Add a notebook using InvokeModel with OpenAIChatCompletion, Pydantic, response_format, and a prompted-JSON baseline; done means it demonstrates schema-constrained generation and downstream validation against a CMI model.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, jupyter-notebook, python
Domain
ai, cloud, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.