Re:OpenAI Function calling and API updates
by misterdata on Tuesday June 13, 2023 @01:29PM
(#36313616)
As they are accepting a JSON schema for the function calls, it is likely they are using token biasing based on the schema (using some kind of state machine that follows along with the tokens and only allows the next token to be a valid one given the grammar/schema). I have successfully implemented this for JSON Schema (limited subset) on llama.cpp. See also e.g. this implementation: https://github.com/1rgs/jsonformer
Re:OpenAI Function calling and API updates
by newhouseb on Tuesday June 13, 2023 @01:35PM
(#36313708)
As someone also building constrained decoders against JSON [1], I was hopeful to see the same but I note the following from their documentation:
The model can choose to call a function; if so, the content will be a stringified JSON object adhering to your custom schema (note: the model may generate invalid JSON or hallucinate parameters).
So sadly, it is just fine tuning. There's no hard biasing applied :(. You were so close, but so far OpenAI![1] https://github.com/newhouseb/clownfish
[2] https://platform.openai.com/docs/guides/gpt/function-calling
Re:OpenAI Function calling and API updates
by civilitty on Tuesday June 13, 2023 @01:43PM
(#36313803)
Or there’s a trade off between more complex schemas and logit bias going off the rails since there’s probably little to no backtracking.
Re:OpenAI Function calling and API updates
by newhouseb on Tuesday June 13, 2023 @10:55PM
(#36320854)
Good point. Backtracking is certainly possible but it is probably tricky to parallelize at scale if you're trying to coalesce and slam through a bunch of concurrent (unrelated) requests with minimal pre-emption.
Re:OpenAI Function calling and API updates
by jumploops on Tuesday June 13, 2023 @01:52PM
(#36313938)
They may have just fine-tuned 3.5 to respond with valid JSON more times than not.
Building magic functions[0] I ran into many examples where JSONSchema broke for gpt-3.5-turbo but worked well for gpt-4.
Re:OpenAI Function calling and API updates
by Mockapapella on Tuesday June 13, 2023 @02:00PM
(#36314072)
This is a really clever approach to tool use. I'll definitely be experimenting with this trick. Previously I had a grotesque cacophony of agents and JSON parsers. I think this will do a lot to help (both the process and my wallet)
There is also an alternative approach for running code with ChatGPT, the way Nekton(https://nekton.ai) does it. It will use ChatGPT to generate typescript code code, and then just run it in the cloud.
In the end you get similar result - AI generated automation, but you have an option to review what the code will actually do before running it.
While using Auto-GPT I realized that for most usecases, a simple script would have suited my needs better (faster, cheaper, deterministic). Then I realized those scripts can (a) be written by GPT, and (b) call into GPT!
Re:OpenAI Function calling and API updates
by singularity2001 on Wednesday June 14, 2023 @12:39AM
(#36321514)
Not sure how well it scales if you need to provide a function definition for every conceivable use case of 'external data': functions": [
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
]
While developing a more-simple LangChain alternative (https://github.com/minimaxir/simpleaichat) I discovered a neat trick for allowing ChatGPT to select tools from a list reliably: put the list of tools into a numbered list, and force the model to return only a single number by using the logit_bias parameter: https://github.com/minimaxir/simpleaichat/blob/main/PROMPTS....
The slight price drop for ChatGPT inputs is of course welcome, since inputs are the bulk of the costs for longer conversations. A 4x context window at 2x the price is a good value too. The notes for the updated ChatGPT also say "more reliable steerability via the system message" which will also be huge if it works as advertised.