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

enhancement: Reduce reliance on docs by expanding kwargs into parameters #7

Merged
merged 6 commits into from
Aug 3, 2023

Conversation

tomaarsen
Copy link
Contributor

@tomaarsen tomaarsen commented Aug 3, 2023

Hello!

Pull Request overview

  • Expand kwargs into parameters to allow IDE support when using huggingface.ChatCompletion.create.
    • Add related docstrings, remove placeholder docstring.
  • Remove some incorrect Optional statements.
  • Rename r to request to improve readability.

Preface

First of all, this PR makes some style decisions, and I don't mean to impose my style onto this project, so feel free to suggest changes if they are not up to your likings.

Details

I've replaced kwargs from huggingface.ChatCompletion.create with the actual arguments used. This nearly matches the ChatCompletionRequest model, with the exception of the user field (which I think might be unused?). Also, create has a debug parameter that the model doesn't.

I've also removed some Optional statements. Note that Optional[X] is equivalent to Union[X, None], and for these parameters, None was not a valid input. Some of the remaining ones, like top_k and frequency_penalty likely also benefit from having the Optional removed, but they technically work with None, so I left them for now. Feel free to let me know if you'd like these removed too.

If desired, I can extrapolate these changes to the Completion and Embedding classes, but I figured I'd let you have a look at this first.

  • Tom Aarsen

Copy link
Owner

@philschmid philschmid left a comment

Choose a reason for hiding this comment

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

You did the work i was too lazy for! Any chance you can include it for the other classes as well? that's the same for all?

@tomaarsen
Copy link
Contributor Author

That's my speciality 😉 I'll extend it to the other classes too! Let me tackle another PR first.

model: Optional[str] = None,
temperature: float = 0.9,
top_p: float = 0.6,
top_k: Optional[int] = 10,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this implementation, top_k can technically be None, but it might be best to simply turn it into top_k: int = 10, as you wouldn't really want users to specify None. Same for frequency_penalty.

Copy link
Owner

Choose a reason for hiding this comment

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

TGI supports none for both and then uses 0 or omits the values basically.

Copy link
Contributor Author

@tomaarsen tomaarsen Aug 3, 2023

Choose a reason for hiding this comment

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

It does, but EasyLLM doesn't:

"top_p": float(r.top_p),

I can fix this though. I'll introduce the possibility for None.

@philschmid
Copy link
Owner

Could you quickly rebase your PR? i merged the fix for model being optional

Some ~5 arguments were listed as Optional[X], which is equivalent to Union[X, None].
However, None caused crashes for these parameters.
and slightly update the docstrings
model: Optional[str] = None,
temperature: float = 0.9,
top_p: float = 0.6,
top_k: Optional[int] = 10,
Copy link
Owner

Choose a reason for hiding this comment

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

TGI supports none for both and then uses 0 or omits the values basically.

easyllm/schema/openai.py Show resolved Hide resolved
@philschmid philschmid merged commit 6657d46 into philschmid:main Aug 3, 2023
2 checks passed
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