StrictJSON (LLM Output Parser) Ask Me Anything #1

  Рет қаралды 367

John Tan Chong Min

John Tan Chong Min

Күн бұрын

StrictJSON is a python package I created last year in order to parse LLM outputs in a structured format (JSON), with optional type checking!
How to use?
Simply type in a system prompt (what the LLM should do), user prompt (the input to the LLM), and the output_format (the JSON format which you want the output to be in).
It is configurable to use your own LLMs with the llm parameter, be it other APIs like Claude 3 Haiku, or local LLMs like Llama 3 70B. So far, performance has been reliable even for non-OpenAI LLMs.
Here, I show how to use StrictJSON for:
- Simple entity extraction, classification, summarisation
- Knowledge graph parsing and displaying
- Code generation and error correction
- Changing code based on user intent
- Type Checking
- Using your own LLM
- Chain of Thought
- Reflection
- Evaluate Math with Code
- Extract rule-based filters from user text
- Conditional Flow using Multiple Chains of StrictJSON
~~
Repo: github.com/tanchongmin/strict...
Companion Notebook: github.com/tanchongmin/strict...
~~
0:00 Introduction
2:17 Basic Stuff: Classification, Poem Extender
4:35 List/Array Output
5:47 Entity Extraction
12:40 Knowledge Graph Parser
13:52 Knowledge Graph Code Display
15:44 Code Error Correction
25:07 Changing Code Based on User Intent
28:53 Type Checking
37:36 Using your own LLM
47:07 Chain of Thought
52:17 TaskGen Agent Teaser
56:36 Paragraph Extractor
1:03:38 Reflection
1:12:27 Evaluate Math with Code
1:18:29 Extract rule-based filters from user text
1:21:25 Conditional Flow using Multiple Chains of StrictJSON
~~
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: / discord
LinkedIn: / chong-min-tan-94652288
Online AI blog: delvingintotech.wordpress.com/
Twitter: / johntanchongmin
Try out my games here: simmer.io/@chongmin

Пікірлер: 11
@Karl-Asger
@Karl-Asger 2 ай бұрын
Amazing work John, I hope I can be part of future meetings, I love the points that you are most focused on in these developments.
@snehotoshbanerjee1938
@snehotoshbanerjee1938 15 күн бұрын
Cool!
@johntanchongmin
@johntanchongmin 2 ай бұрын
Companion Notebook for this Tutorial: github.com/tanchongmin/strictjson/blob/main/strictjson_AMA_30Apr2024.ipynb
@johntanchongmin
@johntanchongmin 2 ай бұрын
Repo Link: github.com/tanchongmin/strictjson
@ginisksam
@ginisksam 2 ай бұрын
Hi John. Thanks for this package. Can be very powerful and flexible by adding more 'stuff' within the output_format like 'Thoughts', 'Reflection', etc. Will explore further, its so refreshing. BTW I have hooked up to Ollama API running local. Keep up the good work.
@johntanchongmin
@johntanchongmin 2 ай бұрын
Hope you like it :)
@ginisksam
@ginisksam 2 ай бұрын
Hi @@johntanchongmin Having this error ... An exception occurred: "Broad Trip Plan" not in json string output. You must use "###{key}###" to enclose the {key}. Current invalid json format: {... When using local llm. What is the likely cause. Look fwd to your kind guidance. Cheers
@johntanchongmin
@johntanchongmin 2 ай бұрын
@@ginisksam Local LLMs are likely not as good at instruction following. I'll be releasing a patch in a few days. Meanwhile you can add this line to your system prompt: "Begin your response with {{ and end with }}"
@johntanchongmin
@johntanchongmin 2 ай бұрын
@@ginisksam Could you also show me the invalid json format?
@ginisksam
@ginisksam 2 ай бұрын
@@johntanchongmin Here is snippet running cell below from strictjson_AMA...ipynb res2 = strict_json(system_prompt = '''Given the triplet list, write some code to display this as a Knowledge Graph''', user_prompt = triplet_list, output_format = {'Code': 'Code in Python to display knowledge graph from triplet list'}, llm=llm) Error: An exception occurred: list index out of range Current invalid json format: { "'###Code###': " "import networkx as nx " "from networkx.drawing.nx_agraph import write_dot " "from itertools import permutations " " " "triplets = [{ " "'obj1': 'LLM', 'relationship': 'provides', 'obj2': 'Base Functionalities'}, " "'obj1': 'Tutorial.ipynb', 'relationship': 'refers to', 'obj2': 'Base Functionalities'}, " "'obj1': 'int, float, str, dict, list', 'relationship': 'supports', 'obj2': 'Base Functionalities'}, " "'obj1': 'Dict[], List[], Enum[]', 'relationship': 'supported by', 'obj2': 'Base Functionalities'}, " "'obj1': 'bool type forcing', 'relationship': 'handled by', 'obj2': 'Base Functionalities'}, " "'obj1': 'LLM-based error correction', 'relationship': 'used for', 'obj2': 'Base Functionalities'}, " "'obj1': 'Function (renamed from strict_function)', 'relationship': 'available in', 'obj2': 'Base Functionalities'}, " "'obj1': 'OpenAI JSON Mode', 'relationship': 'enabled by', 'obj2': 'Base Functionalities'}, " "'obj1': 'llm variable', 'relationship': 'exposed for', 'obj2': 'strict_json, Function'} " "] " " " "# Create a graph " "G = nx.DiGraph() " " " "# Add nodes and edges from triplets " "for obj1, rel, obj2 in triplets: " " G.add_edge(obj1, obj2, relationship=rel) " ... Thanks for your continous guidance.
TaskGen Ask Me Anything #1
1:54:55
John Tan Chong Min
Рет қаралды 288
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 862 М.
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 45 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 14 МЛН
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 34 МЛН
Chat and RAG with Tabular Databases Using Knowledge Graph and LLM Agents
1:23:34
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 372 М.
DHH - Ruby on Rails, 37signals, and the future of web development
1:09:57
Procedural Generation using Constraint Satisfaction
32:36
Programming Chaos
Рет қаралды 9 М.
Event Driven Architecture EXPLAINED in 15 Minutes
14:55
Continuous Delivery
Рет қаралды 15 М.
The Truth About Learning Python in 2024
9:38
Internet Made Coder
Рет қаралды 147 М.
I wish every AI Engineer could watch this.
33:49
1littlecoder
Рет қаралды 65 М.
СБЕГАЮ ОТ ЗЛЫХ РОДИТЕЛЕЙ в Schoolboy Runaway
44:32
ВСЕ КОНЦОВКИ И СЕКРЕТЫ ПОУ! Bou's Revenge
35:51
Family Play TV
Рет қаралды 324 М.