Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFCL] Add support for Writer models and Palmyra X 004 #755

Merged
merged 8 commits into from
Nov 26, 2024

Conversation

samjulien
Copy link
Contributor

@samjulien samjulien commented Nov 12, 2024

This PR adds support for Writer models and our latest Palmyra X 004 to BFCL. Thank you!

@samjulien samjulien changed the title Add support for Palmyra X 004 from Writer [BFCL] Add support for Writer models and Palmyra X 004 Nov 13, 2024
@samjulien samjulien marked this pull request as ready for review November 13, 2024 22:39
Copy link
Collaborator

@HuanzhiMao HuanzhiMao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @samjulien !

I noticed that here, you intentionally removed all the response field from the function doc.
For model that doesn't support response field, we add those information to the end of the function description because we don't want information loss (code here). Is there a reason why you chose to do it that way?

@samjulien
Copy link
Contributor Author

Thanks for the PR @samjulien !

I noticed that here, you intentionally removed all the response field from the function doc. For model that doesn't support response field, we add those information to the end of the function description because we don't want information loss (code here). Is there a reason why you chose to do it that way?

Ah thank you! I’ll add a check for our models there and remove from our handler.

@samjulien
Copy link
Contributor Author

samjulien commented Nov 25, 2024

Hi @HuanzhiMao, I made that change you suggested and rebased the branch to be updated with main (note: force push), but I'm getting some weird errors now that I wasn't getting before these updates. Looks like it is happening in multi_threaded_inference, getting KeyError: 'function'. I'll keep investigating, but maybe you can take a look/run it locally? Or have you seen this with other providers recently? Anything to go on would be helpful. Thanks!

@HuanzhiMao HuanzhiMao added the BFCL-New Model Add New Model to BFCL label Nov 25, 2024
@HuanzhiMao
Copy link
Collaborator

HuanzhiMao commented Nov 25, 2024

Hey @samjulien, I have submitted a PR to your fork. samjulien#1

Two things I changed:

  1. All the methods ending with _prompting are removed, because they are never used. Palmyra is a Funciton Calling model, and so only those _FC methods will be used.
  2. I made the WriterHandler inherit from the OpenAIHandler since they share the exact same logic for decoding, tool handling, etc. The only difference is _query_FC because writerai use self.client.chat.chat instead of self.client.chat.completions.create

I have tested the code locally and it is working perfectly fine.

@samjulien
Copy link
Contributor Author

Thank you so much @HuanzhiMao, great thinking! I really appreciate you doing that. I've merged it in.

One other question: We don't usually append -FC to palmyra-x-004 since we don't have a separate non-FC model, but it seemed like it is necessary for the tests to run correctly. Am I right on that?

@HuanzhiMao
Copy link
Collaborator

HuanzhiMao commented Nov 26, 2024

Thank you so much @HuanzhiMao, great thinking! I really appreciate you doing that. I've merged it in.

One other question: We don't usually append -FC to palmyra-x-004 since we don't have a separate non-FC model, but it seemed like it is necessary for the tests to run correctly. Am I right on that?

Yes. The -FC is mainly to signal the BFCL user that this is a function calling model (instead of a prompt model). You can see that when we call the endpoint, we remove the -FC in the model name. So under the hood, we are using the palmyra-x-004 model for inference:

api_response = self.client.chat.chat(
messages=message,
model=self.model_name.replace("-FC", ""),
temperature=self.temperature,
tools=tools,
tool_choice="auto",
)

If you don't want the _FC in model name, we can also remove it. Either way is fine.

Copy link
Collaborator

@HuanzhiMao HuanzhiMao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the PR!

@HuanzhiMao
Copy link
Collaborator

Update: I removed the _FC in the model name.

@HuanzhiMao HuanzhiMao merged commit 8ce2d8b into ShishirPatil:main Nov 26, 2024
@samjulien
Copy link
Contributor Author

Thank you so much @HuanzhiMao! Let me know if you need an API key for the leaderboard.

@HuanzhiMao
Copy link
Collaborator

Thank you so much @HuanzhiMao! Let me know if you need an API key for the leaderboard.

DM-ed via Discord.

HuanzhiMao added a commit that referenced this pull request Dec 7, 2024
This PR updates the leaderboard to reflect the change in score due to
the following PR merge:

1. #747 
2. #770 
3. #768 
4. #750 
5. #763 
6. #772 
7. #777 
8. #778 
9. #786 
10. #787 
11. #697 
12. #718 
13. #755 
14. #796 
15. #789 
16. #804 
17. #808 
18. #809
19. #811 
20. #810 

Models were evaluated using checkpoint commit d7e52e5.
@Gdewilde
Copy link

Nice addition. Why is this model not visible on the leaderboard?
Screenshot 2025-01-30 at 23 57 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFCL-New Model Add New Model to BFCL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants