r/Rag • u/Wonderful-Switch3107 • 3d ago
Discussion Ling-3.2-flash's structured-output docs include nested objects and arrays
Ant Ling documents nested JSON Schema output for Ling-3.2-flash, including typed fields, required properties and arrays.
For document extraction before retrieval, that allows an output contract richer than one block of text. An illustrative structure could carry a document identifier and an array of sections, each with a heading and its extracted text.
The application defines that structure through response_format and supplies the extraction instructions in the prompt.
Would you retain those section objects through indexing, or flatten them early and keep the hierarchy in metadata? The model's documented schema support gives an extraction pipeline a way to request the structured representation first.
1
u/MongooseWonderful198 2d ago
I'd keep the section tree as the source of truth and build a separate text-chunk index. Give each chunk its parent section ID, document version and source span, then fetch the parent section when a match needs more context. That preserves a route back to the source and lets you identify which chunks need replacing when a document changes.
LangChain's parent-document retriever uses the core pattern: search small child chunks, then fetch their parents from a document store. The version and source-span fields would be additions in your pipeline.
1
u/AbdidheereKeups73 2d ago
flatten it for the index, keep the hierarchy in metadata. vector stores arent really built to traverse nested JSON arrays efficiently anyway, so youre better off turning each section object into its own record with a parent_id field
2
u/CornerStrict7641 2d ago
Keep the original JSON around either way. you can always flatten it for retrieval without losing the source structure