Skip to content

Add functionary support#784

Merged
abetlen merged 9 commits intomainfrom
add-functionary-support
Nov 3, 2023
Merged

Add functionary support#784
abetlen merged 9 commits intomainfrom
add-functionary-support

Conversation

@abetlen
Copy link
Owner

@abetlen abetlen commented Oct 2, 2023

Overview

Adds support for proper OpenAI function calling using the functionary language model.

This model is capable of performing openai style funciton calling, selecting functions dynamically, and regular chat completions.

Link to model in GGUF format

  • Functionary Custom Format
  • Functionary Response Formatting (tricky)
  • Test with OpenAI tests and instructor library
  • Clean up API

Notes

It was straightforward enough to fit Functionary's prompt formatting into the new format method
image
and the quantized model behaves as expected however it's clear that the current API is inadequate to handle function calling properly
image

To do this correctlly we need to

  • Format the incoming message requests to functionary format
  • Generate up to the end of the assistant message (next : character) to see if any function is called while not returning any of the generated tokens up until that point.
  • If it is perform constrained generation and start returning tokens

Update: It Works!

image

@abetlen abetlen marked this pull request as ready for review November 3, 2023 06:12
@abetlen abetlen merged commit 3af7b21 into main Nov 3, 2023
@abetlen abetlen deleted the add-functionary-support branch November 14, 2023 20:07
@teleprint-me
Copy link
Contributor

teleprint-me commented Nov 26, 2023

I noticed functionary is specific to a model even though grammar is general enough to support any model (unless I'm misunderstanding something here). Not a big deal as I still haven't had time to look at the updates yet. I'll be doing that tonight and tomorrow. I'll (hopefully) know and understand more about the status quo by then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants