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

[Frontend] Support Tool and RAG #3971

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

esmeetu
Copy link
Collaborator

@esmeetu esmeetu commented Apr 10, 2024

This is another function tool implement compared to #3237. This PR is simple and flexible. And this idea was inspired by https://github.com/huggingface/transformers/blob/main/src/transformers/models/cohere/tokenization_cohere_fast.py
That leveraged transformers rich chat template support.

Discussions

  1. Should tools parameters follow openai' design strictly, which have a fixed json format? although this server is named openai_server.
  2. tool_calls in openai response sometimes is unnecessary. For example, if prompt: 'Send email to Roy', after model returns tool call, my task finished. And i don't need tool_calls for summary anymore.
  3. For documents parameter, whether we will use this information for future features? like RAG Speculative decoding and something else that accelerates RAG inference.
  4. Sometimes user using RAG api endpoint as chat, which will lost some precisions. They assemble conversations and documents without using tokenizer's special tokens, which doesn't follow model's training prompt.

TODO

  • Test and example
  • Document for how to use

Further ideas

  1. I think we need [Server] Support openai prefix cache #2515 when using tool call feature. Since tool call list is always fixed, users can get max performance by setting prefix position instead of unstable automatic prefix caching.
    For RAG applications, it's also useful to have a indicator(prefix_stop) to adapt prefix caching.
  2. As we have more custom parameters in api_server. I think it's time to consider a vllm-client. This might be not related to this PR.

@leiwen83
Copy link
Contributor

leiwen83 commented Apr 12, 2024

Hi,

I wonder which version of openai library support this "documents" parameter?
If only for spec infer reason, maybe we could directly reuse "tools", and make its type as "rag_spec_infer"?

And we may need add additional code to tokenizer those rag text?

@esmeetu esmeetu marked this pull request as draft April 14, 2024 04:02
@esmeetu
Copy link
Collaborator Author

esmeetu commented Apr 14, 2024

@leiwen83 Thanks for your feedback.

I wonder which version of openai library support this "documents" parameter?

No, it just a custom parameter in vllm, as we have already a few custom parameter in openai_server.

If only for spec infer reason, maybe we could directly reuse "tools", and make its type as "rag_spec_infer"?

It seems that reusing tools in rag will mislead users to use this api.

And we may need add additional code to tokenizer those rag text?

We leverage the transformers chat template and apply_chat_template function, and we don't need to write custom parser to handle user's RAG documents.

@bohea
Copy link

bohea commented Apr 22, 2024

Hi esmeetu
idea of rich chat template support is great

maybe offer a cohere client compatible api server, cohere_server, is a better choice?

@esmeetu
Copy link
Collaborator Author

esmeetu commented Apr 23, 2024

@bohea Thanks! I think it's a bit early to consider adding another api_server. As we know, Llama3 model's tool use and rag performance is also good.

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.

3 participants