Tutorial #5: Strict JSON LLM Framework - Get LLM to output JSON exactly the way you want it!

preview_player
Показать описание
I'm creating a framework that can generate the output of an LLM as a JSON, and ensures that all output fields are generated. This is done using iterative prompting of the error messages to the LLM should the LLM generate the output incorrectly.

Features:
- Free-text generation for output fields
- Constrained generation from one element of the list
- Constrained generation of the label from "label:description" elements of a list
- Flexible header/value generation using angle brackets
- Chain of thought prompting by ordering the output fields of the JSON
- Multiple input processing using a list as input and outputting a list of JSON

Future work:
- LLM + Rules-based Adaptive Functions
Dynamic Tool Use
Agents with Tool Use

~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~

0:00 Introduction
1:48 Overall Open-ended Generation
3:35 List-based constraining of output
6:06 List-based label constraining of ouput
8:06 Dynamic output format with angle brackets
10:18 Chain-of-thought prompting via JSON
15:05 List Input for Multiple Processing
18:55 The Magic Revealed: How it works

~~~~~~~~~~~~~~~~~~~~~~~

AI and ML enthusiast. Likes to think about the essences behind breakthroughs of AI and explain it in a simple and relatable way. Also, I am an avid game creator.

Рекомендации по теме
Комментарии
Автор

Very valuable stuff, thank you for uploading!

yanivben-malka
Автор

Great stuff! I've been looking for ways to generate output in JSON, and this helps me a lot. Thank you

FahmiFauzi-kfwl
Автор

12:10 is my proudest use case of this framework. By using JSON, I can do ReAct and RefleXion at the same time, with just a for loop over the strict_output() function. It manages to do something similar to SayCan (high level planning with LLMs)!

johntanchongmin
Автор

Update: StrictJSON is now a python package
Simply "pip install strictjson"

johntanchongmin
Автор

Great work! Have you tried experimenting with few-shot training by adding a few 'request -> desired outcome' pairs to the prompt? I'm curious to know if this approach can further enhance the quality of GPT's responses.

dmitrivillevald
Автор

Can i use the same thing with Gemini ?! Or the mistral?

doctor
Автор

Sir i need your help ! How can i contact you ! Please sir its urgent

_Shash_Music