How to Generate Structured Outputs of JSON with Lists And Dictionaries with LangChain
How to generate complicated structured outputs with LangChain
5 min readAug 3, 2023
The output of the LLMs is plain text. However, many times we want to get structured responses in order to be able to analyze them better. The LangChain library contains several output parser classes that can structure the responses of the LLMs. The two main methods of the output parsers classes are:
- “Get format instructions”: A method that returns a string with instructions about the format of the LLM output
- “Parse”: A method that parses the unstructured response from the LLM into a structured format
You can find an explanation of the output parses with examples in LangChain documentation. In this tutorial, we will show you something that is not covered in the documentation, and this is how to generate a list of different objects as structured outputs.