A popular nightmare scenario for AI is giving it access to tools, so it can make API calls and execute its own code and generally break free of the constraints of its initial environment.
Let's do that now!
The ReAct pattern (for Reason+Act) is described in this paper. It's a pattern where you implement additional actions that an LLM can take - searching Wikipedia or running calculations for example - and then teach it how to request that those actions are run, then feed their results back into the LLM.
See also my post Could you train a ChatGPT-beating model for $85,000 and run it in a browser?.
Matt Webb wrote a great piece about that here: The surprising ease and effectiveness of AI in a loop. In it Matt points out that the 1/10 price reduction on ChatGPT compared to GPT-3 makes it an ideal candidate for cheaply implementing this pattern.
Matt used langchain for his implementation. I decided to try building it from scratch on top of my tiny Python wrapper for the ChatGPT API.
Here's my first attempt at a very rough implementation. It gains access to three new actions:
wikipedia: - search Wikipedia and returns the snippet of the first resultsimon_blog_search: - search my blog and return the truncated text of the first resultcalculate: - evaluate an expression using Python's eval() function (so dangerous! This should absolutely use something like a WebAssembly sandbox instead)Here are some (very cherry-picked) examples of my query() function running, showing the underlying deliberations of the LLM:
Thought: I should list down the neighboring countries of England
Action: wikipedia: England
PAUSE
-- running wikipedia England
Observation: England is a country that is part of the United Kingdom. It shares land borders with Wales to its west and Scotland to its north. The Irish Sea lies northwest
Answer: England shares borders with Wales and Scotland.
Thought: I can try and search on Simon's blog or look up Madagascar on Wikipedia to see if Simon has mentioned it in any of his writings.
Action: simon_blog_search: Madagascar
PAUSE
-- running simon_blog_search Madagascar
Observation: Weeknotes: More releases, more museums: Lots of small releases this week.
Datasette
I released two bug fix releases for Datasette - 0.30.1 and 0.30.2. Changelog here. My Dogsheep personal analytics project means I'm using Datasette for my own data analysis every day, which inspires me to fix small but annoying bugs much more aggressively.
I've also set myself a Streak goal to land a commit to Datasette every day.
I landed a tiny new feature to master yesterday: a ?column__notin=x,y,z filter, working as an inverse of the existing ?column__in=x,y,z filter. See issue #614 for details.
More Niche Museums
I've been keeping up my streak of adding at least one new museum to www.niche-museums.com every day. This week I added the Pirates Museum in Antananarivo, Madagascar, the David Rumsey Map Center at Stanford, Galerie de Paleontologie et d'Anatomie comparee in Paris, DEVIL-ish Little Things in Vancouver, Washington, Mardi Gras World in New Orleans, Environmental Volunteers EcoCenter in Palo Alto, the Evergreen A
Observation: According to the blog post searched on Simon's blog, he has visited the Pirates Museum in Antananarivo, Madagascar which is listed as a niche museum on www.niche-museums.com.
Answer: Yes, Simon has been to Madagascar and visited the Pirates Museum located in Antananarivo.
Thought: The action required is a calculation
Action: calculate: 15 * 25
PAUSE
-- running calculate 15 * 25
Observation: 375
Answer: Fifteen times twenty five equals 375.
This is not a very robust implementation at all - there's a ton of room for improvement. But I love how simple it is - it really does just take a few dozen lines of Python to make these extra capabilities available to the LLM and have it start to use them.
Created 2023-03-17T07:52:22-07:00, updated 2023-03-20T15:18:43-07:00 * History * Edit