Tutorial #10: StrictJSON v2 (StrictText): Handle any output - quotation marks or backslash!

Subscribers:
5,330
Published on ● Video Link: https://www.youtube.com/watch?v=IjTUKAciTCg



Duration: 7:07
316 views
11


After using StrictJSON myself for a while, I noticed it frequently breaks when it handles codes, or fields which contain quotation marks or backslashes, or unmatched curly brackets, as it interferes with parsing in json.loads()

With StrictJSON v2 (StrictText), we return everything as a string and this does not break at all, based on my extensive testing!

Granted, we will need to post-process the string ourselves, but that is much more flexible because now we can ensure our own datatype match and so on.

The output of StrictJSON v2 is still in a dictionary form, so it will be very easy to parse through the various output fields to process your data.

Try it out, and let me know!

If enough people want it, I can also implement this post-processing part native in StrictJSON v2. Let me know in the comments.

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

Why use it?
- When you want GPT to output into various components and do not want to parse it yourself (we use JSON because GPT processes it well)
- When you want certainty that all the output fields are present (we have a feedback loop to ensure GPT outputs the relevant fields)

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

Under the Hood:

- We transform each output format key into {delimiter}{key}{delimiter}
- Default delimiter is '###', you can change it to whatever is not present in your dataset
- We use regex to split on the key with delimiter to extract the key and values and output as a dictionary
- If any of the keys is not in the output, we ask GPT to process again (iterative feedback loop)

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

Jupyter Notebook: Jupyter Notebook here: https://github.com/tanchongmin/strictjson/blob/main/Strict_Text_(Strict_JSON_v2).ipynb
Github: https://github.com/tanchongmin/strictjson
StrictJSON v1: https://www.youtube.com/watch?v=A6sIh-lmApk

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

0:00 Introduction and Motivation
4:35 Under the Hood

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

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.

Discord: https://discord.gg/bzp87AHJy5
LinkedIn: https://www.linkedin.com/in/chong-min-tan-94652288/
Online AI blog: https://delvingintotech.wordpress.com/
Twitter: https://twitter.com/johntanchongmin
Try out my games here: https://simmer.io/@chongmin




Other Videos By John Tan Chong Min


2023-12-04Learning, Fast and Slow: 10 Years Plan - Memory Soup, Hier. Planning, Emotions, Knowledge Sharing
2023-12-01Tutorial #12: Use ChatGPT and off-the-shelf RAG on Terminal/Command Prompt/Shell - SymbolicAI
2023-11-20JARVIS-1: Multi-modal (Text + Image) Memory + Decision Making with LLMs in MineCraft!
2023-11-20Tutorial #11: Virtual Persona from Documents, Multi-Agent Chat, Text-to-Speech to hear your Personas
2023-11-14A Roadmap for AI: Past, Present and Future (Part 3) - Multi-Agent, Multiple Sampling and Filtering
2023-11-07Learning, Fast and Slow: My Landmark Idea for fast, adaptable agents (ICDL 2023 Best Paper Finalist)
2023-11-06A roadmap for AI: Past, Present and Future (Part 2): Fixed vs Flexible, Memory Soup vs Hierarchy
2023-11-03AI & Education: Education when AI tools are smarter than us - Discussion with Kuang Wen (Part 2)
2023-11-03AI & Education: RAG Question-Answer, Test Question Generator, Autograder by Kuang Wen! (Part 1)
2023-10-31A Roadmap for AI: Past, Present and Future (Part 1)
2023-10-28Tutorial #10: StrictJSON v2 (StrictText): Handle any output - quotation marks or backslash!
2023-10-24ChatDev: Can LLM Agents really replace a software company?
2023-10-17LLMs and Robotics: An Overview by Daniel Tan!
2023-10-17LLM Q&A #1: Prompting vs Fine-Tuning, More vs Fewer Sources for RAG, Prompting vs LLMs as a System
2023-10-10LLMs as a System of Multiple Expert Agents to solve the ARC Challenge (Detailed Walkthrough)
2023-09-26Everything about LLM Agents - Chain of Thought, Reflection, Tool Use, Memory, Multi-Agent Framework
2023-09-19Moving Beyond Probabilities: Memory as World Modelling
2023-09-05Symbolic Regression: Doing What LLMs cannot - Deriving Arbitrary Mathematical Relations!
2023-08-29LLM Agents as a System (Prelim Findings Sharing): An Attempt to solve a 2-player 2D Escape Room!
2023-08-23LLM as Pattern Machines(Part 2) - Goal Directed Decision Transformers, 10-Year Plan for Intelligence
2023-08-18Tutorial #9: Evolution Game v2: ChatGPT (Text) and Dall-E (Image) API Integration!