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

Hugging Face generators: set a default for max_new_tokens #7365

Closed
anakin87 opened this issue Mar 14, 2024 · 4 comments
Closed

Hugging Face generators: set a default for max_new_tokens #7365

anakin87 opened this issue Mar 14, 2024 · 4 comments
Labels
2.x Related to Haystack v2.0 Contributions wanted! Looking for external contributions good first issue Good for newcomers

Comments

@anakin87
Copy link
Member

We have 4 Hugging Face Generators: HFLocalGenerator, HFTGIGenerator and the corresponding chat ones.

max_new_tokens can be set at initialization inside the generation_kwargs dict (or passed during run).

    generator = HuggingFaceLocalGenerator(
        model="google/flan-t5-large",
        generation_kwargs={"max_new_tokens": 100, "temperature": 0.9})

If not set, the Hugging Face default for max_length (= input prompt + max_new_tokens) is 20, which leads almost always to truncated responses.
Only in HuggingFaceLocalChatGenerator, we set the default to 512, which can be a good default.

For consistency, we should also update the other Hugging Face Generators to provide the same default.

@anakin87 anakin87 added the Contributions wanted! Looking for external contributions label Mar 14, 2024
@anakin87 anakin87 added good first issue Good for newcomers 2.x Related to Haystack v2.0 labels Mar 14, 2024
@CKeibel
Copy link
Contributor

CKeibel commented Mar 15, 2024

Hi @anakin87 !
If no one is working on this issue yet, could I work on this to get started with contributing?

@anakin87
Copy link
Member Author

Feel free to do that!

@CKeibel
Copy link
Contributor

CKeibel commented Mar 15, 2024

Great, I will check it out!

@anakin87
Copy link
Member Author

done in #7370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 Contributions wanted! Looking for external contributions good first issue Good for newcomers
Projects
Development

No branches or pull requests

2 participants